idle-inhibit: don't destroy inhibitor on surface destroy

fixes #5731
This commit is contained in:
Vaxry 2024-04-24 19:15:01 +01:00
parent 4540d8ccd5
commit d86eec332f
2 changed files with 12 additions and 3 deletions

View file

@ -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,6 +21,7 @@ CIdleInhibitorResource::CIdleInhibitorResource(SP<CZwpIdleInhibitorV1> resource_
CIdleInhibitorResource::~CIdleInhibitorResource() {
hyprListener_surfaceDestroy.removeCallback();
if (!destroySent)
events.destroy.emit();
}

View file

@ -34,6 +34,7 @@ class CIdleInhibitorResource {
private:
SP<CZwpIdleInhibitorV1> resource;
wlr_surface* surface = nullptr;
bool destroySent = false;
DYNLISTENER(surfaceDestroy);
};