From 0d0e57ce2b019854034e05042ea59254b51e4d34 Mon Sep 17 00:00:00 2001 From: Martin Schrodt Date: Wed, 1 Apr 2026 20:29:27 +0300 Subject: [PATCH] core: don't skip on-resume when on-timeout already fired When on-timeout has executed (e.g. DPMS off) and a ScreenSaver inhibit lock arrives afterward (e.g. from a notification sound), on-resume was blocked by the inhibit check, leaving monitors stuck off. Track per-listener whether on-timeout actually executed. On resume, check this flag instead of the inhibit lock count: if on-timeout ran, on-resume must run unconditionally. If on-timeout was itself inhibited, skip on-resume symmetrically. Fixes #128 --- src/core/Hypridle.cpp | 9 +++++++-- src/core/Hypridle.hpp | 9 +++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/core/Hypridle.cpp b/src/core/Hypridle.cpp index 5edc32f..3519a9d 100644 --- a/src/core/Hypridle.cpp +++ b/src/core/Hypridle.cpp @@ -269,17 +269,22 @@ void CHypridle::onIdled(SIdleListener* pListener) { } Debug::log(LOG, "Running {}", pListener->onTimeout); + pListener->onTimeoutFired = true; spawn(pListener->onTimeout); } void CHypridle::onResumed(SIdleListener* pListener) { Debug::log(LOG, "Resumed: rule {:x}", (uintptr_t)pListener); isIdled = false; - if (g_pHypridle->m_iInhibitLocks > 0 && !pListener->ignoreInhibit) { - Debug::log(LOG, "Ignoring from onResumed(), inhibit locks: {}", g_pHypridle->m_iInhibitLocks); + + // If on-timeout never actually executed (was inhibited), skip on-resume too + if (!pListener->onTimeoutFired) { + Debug::log(LOG, "Skipping onResumed: onTimeout was inhibited for rule {:x}", (uintptr_t)pListener); return; } + pListener->onTimeoutFired = false; + if (pListener->onRestore.empty()) { Debug::log(LOG, "Ignoring, onRestore is empty."); return; diff --git a/src/core/Hypridle.hpp b/src/core/Hypridle.hpp index 11bab5d..c64d95b 100644 --- a/src/core/Hypridle.hpp +++ b/src/core/Hypridle.hpp @@ -17,10 +17,11 @@ class CHypridle { CHypridle(); struct SIdleListener { - SP notification = nullptr; - std::string onTimeout = ""; - std::string onRestore = ""; - bool ignoreInhibit = false; + SP notification = nullptr; + std::string onTimeout = ""; + std::string onRestore = ""; + bool ignoreInhibit = false; + bool onTimeoutFired = false; }; struct SDbusInhibitCookie {