From f01e3043b81d1ad7d886f0502b445bdf3cea0ccc Mon Sep 17 00:00:00 2001 From: s1dd <140317709+nots1dd@users.noreply.github.com> Date: Fri, 9 May 2025 00:31:49 +0530 Subject: desktop: cleanup code and use std::ranges (#10289) --- src/desktop/WindowRule.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src/desktop/WindowRule.cpp') diff --git a/src/desktop/WindowRule.cpp b/src/desktop/WindowRule.cpp index db1b0dde..48bf2ff0 100644 --- a/src/desktop/WindowRule.cpp +++ b/src/desktop/WindowRule.cpp @@ -15,10 +15,9 @@ static const auto RULES_PREFIX = std::unordered_set{ CWindowRule::CWindowRule(const std::string& rule, const std::string& value, bool isV2, bool isExecRule) : m_value(value), m_rule(rule), m_v2(isV2), m_execRule(isExecRule) { const auto VALS = CVarList(rule, 2, ' '); - const bool VALID = RULES.contains(rule) || std::any_of(RULES_PREFIX.begin(), RULES_PREFIX.end(), [&rule](auto prefix) { return rule.starts_with(prefix); }) || - (NWindowProperties::boolWindowProperties.find(VALS[0]) != NWindowProperties::boolWindowProperties.end()) || - (NWindowProperties::intWindowProperties.find(VALS[0]) != NWindowProperties::intWindowProperties.end()) || - (NWindowProperties::floatWindowProperties.find(VALS[0]) != NWindowProperties::floatWindowProperties.end()); + const bool VALID = RULES.contains(rule) || std::ranges::any_of(RULES_PREFIX, [&rule](auto prefix) { return rule.starts_with(prefix); }) || + (NWindowProperties::boolWindowProperties.contains(VALS[0])) || (NWindowProperties::intWindowProperties.contains(VALS[0])) || + (NWindowProperties::floatWindowProperties.contains(VALS[0])); if (!VALID) return; @@ -84,9 +83,9 @@ CWindowRule::CWindowRule(const std::string& rule, const std::string& value, bool else { // check if this is a prop. const CVarList VARS(rule, 0, 's', true); - if (NWindowProperties::intWindowProperties.find(VARS[0]) != NWindowProperties::intWindowProperties.end() || - NWindowProperties::boolWindowProperties.find(VARS[0]) != NWindowProperties::boolWindowProperties.end() || - NWindowProperties::floatWindowProperties.find(VARS[0]) != NWindowProperties::floatWindowProperties.end()) { + const bool ISPROP = NWindowProperties::intWindowProperties.contains(VARS[0]) || NWindowProperties::boolWindowProperties.contains(VARS[0]) || + NWindowProperties::floatWindowProperties.contains(VARS[0]); + if (ISPROP) { *const_cast(&m_rule) = "prop " + rule; m_ruleType = RULE_PROP; Debug::log(LOG, "CWindowRule: direct prop rule found, rewritten {} -> {}", rule, m_rule); -- cgit v1.2.3