fix: repoll after inhibitor idled (#15)

* yep, but how to trigger it?

* stupid yet works

* forgot about lock
This commit is contained in:
Jakub Konior 2024-02-27 22:22:15 +01:00 committed by GitHub
parent 790988d116
commit afee84925a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 16 additions and 3 deletions

View file

@ -80,6 +80,10 @@ std::vector<CConfigManager::STimeoutRule> CConfigManager::getRules() {
return m_vRules;
}
std::string CConfigManager::getOnTimeoutCommand() {
return m_vRules.front().onTimeout;
}
void* const* CConfigManager::getValuePtr(const std::string& name) {
return m_config.getConfigValuePtr(name.c_str())->getDataStaticPtr();
}

View file

@ -18,6 +18,7 @@ class CConfigManager {
std::string onResume = "";
};
std::string getOnTimeoutCommand();
std::vector<STimeoutRule> getRules();
void* const* getValuePtr(const std::string& name);

View file

@ -261,7 +261,7 @@ static void spawn(const std::string& args) {
void CHypridle::onIdled(SIdleListener* pListener) {
Debug::log(LOG, "Idled: rule {:x}", (uintptr_t)pListener);
isIdled = true;
if (g_pHypridle->m_iInhibitLocks > 0) {
Debug::log(LOG, "Ignoring from onIdled(), inhibit locks: {}", g_pHypridle->m_iInhibitLocks);
return;
@ -278,7 +278,7 @@ void CHypridle::onIdled(SIdleListener* pListener) {
void CHypridle::onResumed(SIdleListener* pListener) {
Debug::log(LOG, "Resumed: rule {:x}", (uintptr_t)pListener);
isIdled = false;
if (g_pHypridle->m_iInhibitLocks > 0) {
Debug::log(LOG, "Ignoring from onResumed(), inhibit locks: {}", g_pHypridle->m_iInhibitLocks);
return;
@ -301,8 +301,15 @@ void CHypridle::onInhibit(bool lock) {
// you have been warned.
m_iInhibitLocks = 0;
Debug::log(WARN, "BUG THIS: inhibit locks < 0. Brought back to 0.");
} else
} else if (m_iInhibitLocks > 0) {
Debug::log(LOG, "Inhibit locks: {}", m_iInhibitLocks);
} else {
Debug::log(LOG, "Inhibit locks: {}", m_iInhibitLocks);
if (isIdled && lock) {
Debug::log(LOG, "Running from onInhibit() isIdled = true {}", g_pConfigManager->getOnTimeoutCommand());
spawn(g_pConfigManager->getOnTimeoutCommand());
}
}
}
CHypridle::SDbusInhibitCookie CHypridle::getDbusInhibitCookie(uint32_t cookie) {

View file

@ -42,6 +42,7 @@ class CHypridle {
void enterEventLoop();
bool m_bTerminate = false;
bool isIdled = false;
int64_t m_iInhibitLocks = 0;
struct {