Skip to content

Commit

Permalink
fix: repoll after inhibitor idled (#15)
Browse files Browse the repository at this point in the history
* yep, but how to trigger it?

* stupid yet works

* forgot about lock
  • Loading branch information
grappas authored Feb 27, 2024
1 parent 790988d commit afee849
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/config/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
1 change: 1 addition & 0 deletions src/config/ConfigManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class CConfigManager {
std::string onResume = "";
};

std::string getOnTimeoutCommand();
std::vector<STimeoutRule> getRules();
void* const* getValuePtr(const std::string& name);

Expand Down
13 changes: 10 additions & 3 deletions src/core/Hypridle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions src/core/Hypridle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class CHypridle {
void enterEventLoop();

bool m_bTerminate = false;
bool isIdled = false;
int64_t m_iInhibitLocks = 0;

struct {
Expand Down

0 comments on commit afee849

Please sign in to comment.