From 94bd4123c6e8fd3162e245b0d568c9d6dfd75780 Mon Sep 17 00:00:00 2001 From: ItsOhen Date: Sun, 15 Mar 2026 20:32:05 +0100 Subject: desktop/rules: fix static rules and content type. (#13725) Hopefully for the last time in a while. Also a lot easier to add in new static types with the recheck done in window map instead of the rule. --- .../rule/windowRule/WindowRuleApplicator.cpp | 41 +++++++++++----------- 1 file changed, 21 insertions(+), 20 deletions(-) (limited to 'src/desktop/rule/windowRule/WindowRuleApplicator.cpp') diff --git a/src/desktop/rule/windowRule/WindowRuleApplicator.cpp b/src/desktop/rule/windowRule/WindowRuleApplicator.cpp index 07cb5f64..dd0e7fb8 100644 --- a/src/desktop/rule/windowRule/WindowRuleApplicator.cpp +++ b/src/desktop/rule/windowRule/WindowRuleApplicator.cpp @@ -547,9 +547,10 @@ CWindowRuleApplicator::SRuleResult CWindowRuleApplicator::applyStaticRule(const return SRuleResult{}; } -void CWindowRuleApplicator::readStaticRules(bool preRead) { +// +bool CWindowRuleApplicator::readStaticRules(bool preRead) { if (!m_window) - return; + return false; static_ = {}; @@ -575,35 +576,35 @@ void CWindowRuleApplicator::readStaticRules(bool preRead) { tagsWereChanged = tagsWereChanged || RES.tagsChanged; } - // recheck some props people might wanna use for static rules. - std::underlying_type_t propsToRecheck = RULE_PROP_NONE; + // set a recheck for some props people might wanna use for static rules. if (tagsWereChanged) propsToRecheck |= RULE_PROP_TAG; if (static_.content != NContentType::CONTENT_TYPE_NONE) propsToRecheck |= RULE_PROP_CONTENT; - if (propsToRecheck != RULE_PROP_NONE) { - for (const auto& r : ruleEngine()->rules()) { - if (r->type() != RULE_TYPE_WINDOW) - continue; + for (const auto& wr : execRules) { + applyStaticRule(wr); + applyDynamicRule(wr); + if (!preRead) + ruleEngine()->unregisterRule(wr); + } + return (propsToRecheck != RULE_PROP_NONE); +} - if (!(r->getPropertiesMask() & propsToRecheck)) - continue; +void CWindowRuleApplicator::recheckStaticRules() { + for (const auto& r : ruleEngine()->rules()) { + if (r->type() != RULE_TYPE_WINDOW) + continue; - auto wr = reinterpretPointerCast(r); + if (!(r->getPropertiesMask() & propsToRecheck)) + continue; - if (!wr->matches(m_window.lock(), true)) - continue; + auto wr = reinterpretPointerCast(r); - applyStaticRule(wr); - } - } + if (!wr->matches(m_window.lock(), true)) + continue; - for (const auto& wr : execRules) { applyStaticRule(wr); - applyDynamicRule(wr); - if (!preRead) - ruleEngine()->unregisterRule(wr); } } -- cgit v1.2.3