Fix exec-once being wack on launch

This commit is contained in:
vaxerski 2022-04-12 20:02:57 +02:00
parent 4bd23604f8
commit 17f63bf3e8
3 changed files with 22 additions and 1 deletions

View file

@ -263,7 +263,7 @@ void CConfigManager::parseLine(std::string& line) {
return; return;
} else if (COMMAND == "exec-once") { } else if (COMMAND == "exec-once") {
if (isFirstLaunch) { if (isFirstLaunch) {
handleRawExec(COMMAND, VALUE); firstExecRequests.push_back(VALUE);
} }
return; return;
} else if (COMMAND == "monitor") { } else if (COMMAND == "monitor") {
@ -478,4 +478,17 @@ std::vector<SWindowRule> CConfigManager::getMatchingRules(CWindow* pWindow) {
} }
return returns; return returns;
}
void CConfigManager::dispatchExecOnce() {
if (firstExecDispatched || isFirstLaunch)
return;
firstExecDispatched = true;
for (auto& c : firstExecRequests) {
handleRawExec("", c);
}
firstExecRequests.clear(); // free some kb of memory :P
} }

View file

@ -51,6 +51,9 @@ public:
std::vector<SWindowRule> getMatchingRules(CWindow*); std::vector<SWindowRule> getMatchingRules(CWindow*);
// no-op when done.
void dispatchExecOnce();
private: private:
std::unordered_map<std::string, SConfigValue> configValues; std::unordered_map<std::string, SConfigValue> configValues;
time_t lastModifyTime = 0; // for reloading the config if changed time_t lastModifyTime = 0; // for reloading the config if changed
@ -64,6 +67,9 @@ private:
std::deque<SMonitorRule> m_dMonitorRules; std::deque<SMonitorRule> m_dMonitorRules;
std::deque<SWindowRule> m_dWindowRules; std::deque<SWindowRule> m_dWindowRules;
bool firstExecDispatched = false;
std::deque<std::string> firstExecRequests;
// internal methods // internal methods
void loadConfigLoadVars(); void loadConfigLoadVars();
SConfigValue getConfigValueSafe(std::string); SConfigValue getConfigValueSafe(std::string);

View file

@ -118,6 +118,8 @@ void Events::listener_monitorFrame(void* owner, void* data) {
g_pCompositor->sanityCheckWorkspaces(); g_pCompositor->sanityCheckWorkspaces();
g_pAnimationManager->tick(); g_pAnimationManager->tick();
g_pCompositor->cleanupWindows(); g_pCompositor->cleanupWindows();
g_pConfigManager->dispatchExecOnce(); // We exec-once when at least one monitor starts refreshing, meaning stuff has init'd
} }
timespec now; timespec now;