From 70cdd819e4bee3c4dcea6961d32e61e6afe4eeb0 Mon Sep 17 00:00:00 2001 From: ItsOhen Date: Thu, 26 Feb 2026 19:13:49 +0100 Subject: desktop/rules: use pid for exec rules (#13374) --- src/desktop/rule/windowRule/WindowRule.cpp | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'src/desktop/rule/windowRule/WindowRule.cpp') diff --git a/src/desktop/rule/windowRule/WindowRule.cpp b/src/desktop/rule/windowRule/WindowRule.cpp index fdc2de62..b93dddec 100644 --- a/src/desktop/rule/windowRule/WindowRule.cpp +++ b/src/desktop/rule/windowRule/WindowRule.cpp @@ -104,20 +104,24 @@ bool CWindowRule::matches(PHLWINDOW w, bool allowEnvLookup) { if (!w->xdgTag().has_value() || !engine->match(*w->xdgTag())) return false; break; + case RULE_PROP_EXEC_TOKEN: - // this is only allowed on static rules, we don't need it on dynamic plus it's expensive if (!allowEnvLookup) break; - const auto ENV = w->getEnv(); + const auto ENV = w->getEnv(); + bool match = false; + if (ENV.contains(EXEC_RULE_ENV_NAME)) { - const auto TKN = ENV.at(EXEC_RULE_ENV_NAME); - if (!engine->match(TKN)) - return false; - break; + if (engine->match(ENV.at(EXEC_RULE_ENV_NAME))) + match = true; + } else if (m_matchEngines.contains(RULE_PROP_EXEC_PID)) { + if (m_matchEngines.at(RULE_PROP_EXEC_PID)->match(w->getPID())) + match = true; } - - return false; + if (!match) + return false; + break; } } @@ -153,11 +157,6 @@ SP CWindowRule::buildFromExecString(std::string&& s) { wr->addEffect(*EFFECT, std::string{"1"}); } - const auto TOKEN = g_pTokenManager->registerNewToken(nullptr, std::chrono::seconds(1)); - - wr->markAsExecRule(TOKEN, false /* TODO: could be nice. */); - wr->registerMatch(RULE_PROP_EXEC_TOKEN, TOKEN); - return wr; } -- cgit v1.2.3