Skip to content

Commit

Permalink
idleinhibit: added less than 0 inhibitor mitigation (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
grappas authored Feb 19, 2024
1 parent f4659b1 commit c26683b
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/core/Hypridle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ void CHypridle::onIdled(SIdleListener* pListener) {
Debug::log(LOG, "Idled: rule {:x}", (uintptr_t)pListener);

if (g_pHypridle->m_iInhibitLocks > 0) {
Debug::log(LOG, "Ignoring, inhibit locks: {}", g_pHypridle->m_iInhibitLocks);
Debug::log(LOG, "Ignoring from onIdled(), inhibit locks: {}", g_pHypridle->m_iInhibitLocks);
return;
}

Expand All @@ -278,7 +278,7 @@ void CHypridle::onResumed(SIdleListener* pListener) {
Debug::log(LOG, "Resumed: rule {:x}", (uintptr_t)pListener);

if (g_pHypridle->m_iInhibitLocks > 0) {
Debug::log(LOG, "Ignoring, inhibit locks: {}", g_pHypridle->m_iInhibitLocks);
Debug::log(LOG, "Ignoring from onResumed(), inhibit locks: {}", g_pHypridle->m_iInhibitLocks);
return;
}

Expand All @@ -293,9 +293,13 @@ void CHypridle::onResumed(SIdleListener* pListener) {

void CHypridle::onInhibit(bool lock) {
m_iInhibitLocks += lock ? 1 : -1;
if (m_iInhibitLocks < 0)
Debug::log(WARN, "BUG THIS: inhibit locks < 0");
else
if (m_iInhibitLocks < 0) {
// what would be safer appending one or setting to 0?
// what if would be equal -2?
// you have been warned.
m_iInhibitLocks = 0;
Debug::log(WARN, "BUG THIS: inhibit locks < 0. Brought back to 0.");
} else
Debug::log(LOG, "Inhibit locks: {}", m_iInhibitLocks);
}

Expand Down

0 comments on commit c26683b

Please sign in to comment.