summaryrefslogtreecommitdiff
path: root/src/managers/input/IdleInhibitor.cpp
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2024-04-12 00:17:50 +0100
committerVaxry <vaxry@vaxry.net>2024-04-12 00:18:58 +0100
commitb1a94302897ae559c877471f7d365651bcd24ad4 (patch)
tree3f877d6a4c0b95963678efe5bef0c3e7be1d9885 /src/managers/input/IdleInhibitor.cpp
parente0a7cf5c3006e9b7acd26551f14ef7b06d5a11ab (diff)
inhibitor: always destroy on window unmap
ref #5555
Diffstat (limited to 'src/managers/input/IdleInhibitor.cpp')
-rw-r--r--src/managers/input/IdleInhibitor.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/managers/input/IdleInhibitor.cpp b/src/managers/input/IdleInhibitor.cpp
index 7e7ee3c9..72f60702 100644
--- a/src/managers/input/IdleInhibitor.cpp
+++ b/src/managers/input/IdleInhibitor.cpp
@@ -10,6 +10,16 @@ void Events::listener_newIdleInhibitor(wl_listener* listener, void* data) {
g_pInputManager->newIdleInhibitor(WLRIDLEINHIBITOR);
}
+static void destroyInhibitor(SIdleInhibitor* inhibitor) {
+ g_pHookSystem->unhook(inhibitor->onWindowDestroy);
+
+ g_pInputManager->m_lIdleInhibitors.remove(*inhibitor);
+
+ Debug::log(LOG, "Destroyed an idleinhibitor");
+
+ g_pInputManager->recheckIdleInhibitorStatus();
+}
+
void CInputManager::newIdleInhibitor(wlr_idle_inhibitor_v1* pInhibitor) {
const auto PINHIBIT = &m_lIdleInhibitors.emplace_back();
@@ -17,16 +27,17 @@ void CInputManager::newIdleInhibitor(wlr_idle_inhibitor_v1* pInhibitor) {
PINHIBIT->pWlrInhibitor = pInhibitor;
+ PINHIBIT->onWindowDestroy = g_pHookSystem->hookDynamic("closeWindow", [PINHIBIT](void* self, SCallbackInfo& info, std::any data) {
+ if (PINHIBIT->pWindow == std::any_cast<CWindow*>(data))
+ destroyInhibitor(PINHIBIT);
+ });
+
PINHIBIT->hyprListener_Destroy.initCallback(
&pInhibitor->events.destroy,
[](void* owner, void* data) {
const auto PINH = (SIdleInhibitor*)owner;
- g_pInputManager->m_lIdleInhibitors.remove(*PINH);
-
- Debug::log(LOG, "Destroyed an idleinhibitor");
-
- g_pInputManager->recheckIdleInhibitorStatus();
+ destroyInhibitor(PINH);
},
PINHIBIT, "IdleInhibitor");