core: re-register all notifications when idled and inhibit was released (#72)

This commit is contained in:
Elvyria 2024-06-22 18:00:57 +03:00 committed by GitHub
parent cb169c4e06
commit 7c5747b785
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 18 additions and 11 deletions

View File

@ -297,21 +297,28 @@ void CHypridle::onResumed(SIdleListener* pListener) {
void CHypridle::onInhibit(bool lock) { void CHypridle::onInhibit(bool lock) {
m_iInhibitLocks += lock ? 1 : -1; m_iInhibitLocks += lock ? 1 : -1;
if (m_iInhibitLocks < 0) { if (m_iInhibitLocks < 0) {
// what would be safer appending one or setting to 0? Debug::log(WARN, "BUG THIS: inhibit locks < 0: {}", m_iInhibitLocks);
// what if would be equal -2?
// you have been warned.
m_iInhibitLocks = 0; m_iInhibitLocks = 0;
Debug::log(WARN, "BUG THIS: inhibit locks < 0. Brought back to 0."); }
} else if (m_iInhibitLocks > 0) {
Debug::log(LOG, "Inhibit locks: {}", m_iInhibitLocks); if (m_iInhibitLocks == 0 && isIdled) {
} else { const auto RULES = g_pConfigManager->getRules();
Debug::log(LOG, "Inhibit locks: {}", m_iInhibitLocks);
if (isIdled && lock) { for (size_t i = 0; i < RULES.size(); ++i) {
Debug::log(LOG, "Running from onInhibit() isIdled = true {}", g_pConfigManager->getOnTimeoutCommand()); auto& l = m_sWaylandIdleState.listeners[i];
spawn(g_pConfigManager->getOnTimeoutCommand()); const auto& r = RULES[i];
ext_idle_notification_v1_destroy(l.notification);
l.notification = ext_idle_notifier_v1_get_idle_notification(m_sWaylandIdleState.notifier, r.timeout * 1000 /* ms */, m_sWaylandState.seat);
ext_idle_notification_v1_add_listener(l.notification, &idleListener, &l);
} }
} }
Debug::log(LOG, "Inhibit locks: {}", m_iInhibitLocks);
} }
CHypridle::SDbusInhibitCookie CHypridle::getDbusInhibitCookie(uint32_t cookie) { CHypridle::SDbusInhibitCookie CHypridle::getDbusInhibitCookie(uint32_t cookie) {