diff options
| author | Vaxry <43317083+vaxerski@users.noreply.github.com> | 2025-11-17 18:34:02 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-11-17 18:34:02 +0000 |
| commit | c2670e9ab90bd657e87a1da2c5322e9007dce01f (patch) | |
| tree | cd033fe3a9b87b1b0d457df043ecc50929ad3c8d /src/desktop/rule/Engine.cpp | |
| parent | 95ee08b3403b90e2930d46425cada1d280f3524e (diff) | |
windowrules: rewrite completely (#12269)
Reworks the window rule syntax completely
---------
Co-authored-by: Mihai Fufezan <mihai@fufexan.net>
Diffstat (limited to 'src/desktop/rule/Engine.cpp')
| -rw-r--r-- | src/desktop/rule/Engine.cpp | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/desktop/rule/Engine.cpp b/src/desktop/rule/Engine.cpp new file mode 100644 index 00000000..3232035d --- /dev/null +++ b/src/desktop/rule/Engine.cpp @@ -0,0 +1,56 @@ +#include "Engine.hpp" +#include "Rule.hpp" +#include "../LayerSurface.hpp" +#include "../../Compositor.hpp" + +using namespace Desktop; +using namespace Desktop::Rule; + +SP<CRuleEngine> Rule::ruleEngine() { + static SP<CRuleEngine> engine = makeShared<CRuleEngine>(); + return engine; +} + +void CRuleEngine::registerRule(SP<IRule>&& rule) { + m_rules.emplace_back(std::move(rule)); +} + +void CRuleEngine::unregisterRule(const std::string& name) { + if (name.empty()) + return; + + std::erase_if(m_rules, [&name](const auto& el) { return el->name() == name; }); +} + +void CRuleEngine::unregisterRule(const SP<IRule>& rule) { + std::erase(m_rules, rule); + cleanExecRules(); +} + +void CRuleEngine::cleanExecRules() { + std::erase_if(m_rules, [](const auto& e) { return e->isExecRule() && e->execExpired(); }); +} + +void CRuleEngine::updateAllRules() { + cleanExecRules(); + for (const auto& w : g_pCompositor->m_windows) { + if (!validMapped(w) || w->isHidden()) + continue; + + w->m_ruleApplicator->propertiesChanged(RULE_PROP_ALL); + } + for (const auto& ls : g_pCompositor->m_layers) { + if (!validMapped(ls)) + continue; + + ls->m_ruleApplicator->propertiesChanged(RULE_PROP_ALL); + } +} + +void CRuleEngine::clearAllRules() { + std::erase_if(m_rules, [](const auto& e) { return !e->isExecRule() || e->execExpired(); }); +} + +const std::vector<SP<IRule>>& CRuleEngine::rules() { + return m_rules; +} |
