From dab50b3ef3a1bad7f68320538223b6b41d1c6012 Mon Sep 17 00:00:00 2001 From: Vaxry <43317083+vaxerski@users.noreply.github.com> Date: Mon, 16 Dec 2024 19:05:24 +0100 Subject: core: Optimize window/layer rule application and scanning (#8735) Optimizes window and layer rule parsing and later usage. --- src/desktop/LayerRule.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/desktop/LayerRule.cpp (limited to 'src/desktop/LayerRule.cpp') diff --git a/src/desktop/LayerRule.cpp b/src/desktop/LayerRule.cpp new file mode 100644 index 00000000..d82e4d30 --- /dev/null +++ b/src/desktop/LayerRule.cpp @@ -0,0 +1,37 @@ +#include "LayerRule.hpp" +#include +#include +#include "../debug/Log.hpp" + +static const auto RULES = std::unordered_set{"noanim", "blur", "blurpopups", "dimaround"}; +static const auto RULES_PREFIX = std::unordered_set{"ignorealpha", "ignorezero", "xray", "animation", "order"}; + +CLayerRule::CLayerRule(const std::string& rule_, const std::string& ns_) : targetNamespace(ns_), rule(rule_) { + const bool VALID = RULES.contains(rule) || std::any_of(RULES_PREFIX.begin(), RULES_PREFIX.end(), [&rule_](const auto& prefix) { return rule_.starts_with(prefix); }); + + if (!VALID) + return; + + if (rule == "noanim") + ruleType = RULE_NOANIM; + else if (rule == "blur") + ruleType = RULE_BLUR; + else if (rule == "blurpopups") + ruleType = RULE_BLURPOPUPS; + else if (rule == "dimaround") + ruleType = RULE_DIMAROUND; + else if (rule.starts_with("ignorealpha")) + ruleType = RULE_IGNOREALPHA; + else if (rule.starts_with("ignorezero")) + ruleType = RULE_IGNOREZERO; + else if (rule.starts_with("xray")) + ruleType = RULE_XRAY; + else if (rule.starts_with("animation")) + ruleType = RULE_ANIMATION; + else if (rule.starts_with("order")) + ruleType = RULE_ORDER; + else { + Debug::log(ERR, "CLayerRule: didn't match a rule that was found valid?!"); + ruleType = RULE_INVALID; + } +} \ No newline at end of file -- cgit v1.2.3