diff options
author | Vaxry <[email protected]> | 2024-04-24 19:15:01 +0100 |
---|---|---|
committer | Vaxry <[email protected]> | 2024-04-24 19:15:01 +0100 |
commit | d86eec332fb3843d24b1f79ecc36f792b5d04773 (patch) | |
tree | 673cebef7af59a1118cd1b4be688e732d4fbf390 | |
parent | 4540d8ccd51e485485af364a951ea7df240585be (diff) | |
download | Hyprland-d86eec332fb3843d24b1f79ecc36f792b5d04773.tar.gz Hyprland-d86eec332fb3843d24b1f79ecc36f792b5d04773.zip |
idle-inhibit: don't destroy inhibitor on surface destroy
fixes #5731
-rw-r--r-- | src/protocols/IdleInhibit.cpp | 12 | ||||
-rw-r--r-- | src/protocols/IdleInhibit.hpp | 3 |
2 files changed, 12 insertions, 3 deletions
diff --git a/src/protocols/IdleInhibit.cpp b/src/protocols/IdleInhibit.cpp index 0b90e284..0119755f 100644 --- a/src/protocols/IdleInhibit.cpp +++ b/src/protocols/IdleInhibit.cpp @@ -6,7 +6,14 @@ CIdleInhibitor::CIdleInhibitor(SP<CIdleInhibitorResource> resource_, wlr_surface CIdleInhibitorResource::CIdleInhibitorResource(SP<CZwpIdleInhibitorV1> resource_, wlr_surface* surface_) : resource(resource_), surface(surface_) { hyprListener_surfaceDestroy.initCallback( - &surface->events.destroy, [this](void* owner, void* data) { PROTO::idleInhibit->removeInhibitor(this); }, this, "CIdleInhibitorResource"); + &surface->events.destroy, + [this](void* owner, void* data) { + surface = nullptr; + hyprListener_surfaceDestroy.removeCallback(); + destroySent = true; + events.destroy.emit(); + }, + this, "CIdleInhibitorResource"); resource->setOnDestroy([this](CZwpIdleInhibitorV1* p) { PROTO::idleInhibit->removeInhibitor(this); }); resource->setDestroy([this](CZwpIdleInhibitorV1* p) { PROTO::idleInhibit->removeInhibitor(this); }); @@ -14,7 +21,8 @@ CIdleInhibitorResource::CIdleInhibitorResource(SP<CZwpIdleInhibitorV1> resource_ CIdleInhibitorResource::~CIdleInhibitorResource() { hyprListener_surfaceDestroy.removeCallback(); - events.destroy.emit(); + if (!destroySent) + events.destroy.emit(); } CIdleInhibitProtocol::CIdleInhibitProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { diff --git a/src/protocols/IdleInhibit.hpp b/src/protocols/IdleInhibit.hpp index 3ea8f691..b59e8789 100644 --- a/src/protocols/IdleInhibit.hpp +++ b/src/protocols/IdleInhibit.hpp @@ -33,7 +33,8 @@ class CIdleInhibitorResource { private: SP<CZwpIdleInhibitorV1> resource; - wlr_surface* surface = nullptr; + wlr_surface* surface = nullptr; + bool destroySent = false; DYNLISTENER(surfaceDestroy); }; |