mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-08-10 00:51:58 -07:00
desktop: cleanup code and use std::ranges (#10289)
This commit is contained in:
@@ -15,10 +15,9 @@ static const auto RULES_PREFIX = std::unordered_set<std::string>{
|
||||
|
||||
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<std::string*>(&m_rule) = "prop " + rule;
|
||||
m_ruleType = RULE_PROP;
|
||||
Debug::log(LOG, "CWindowRule: direct prop rule found, rewritten {} -> {}", rule, m_rule);
|
||||
|
Reference in New Issue
Block a user