refactor: unregister exec rules after applying them

Remove the unused toRemove vector and defer unregistering exec rules
until after applyStaticRule/applyDynamicRule so exec rules are applied
before being removed from the rule engine.
This commit is contained in:
littleblack111 2025-12-01 18:18:36 +08:00
parent 1ababf4575
commit 3d116f53ca
No known key found for this signature in database
GPG key ID: 45AE0FF5962FA6EF

View file

@ -545,7 +545,6 @@ void CWindowRuleApplicator::readStaticRules() {
static_ = {};
std::vector<SP<CWindowRule>> toRemove;
std::vector<SP<CWindowRule>> execRules;
bool tagsWereChanged = false;
@ -559,7 +558,6 @@ void CWindowRuleApplicator::readStaticRules() {
continue;
if (wr->isExecRule()) {
toRemove.emplace_back(wr);
execRules.emplace_back(wr);
continue;
}
@ -569,10 +567,6 @@ void CWindowRuleApplicator::readStaticRules() {
tagsWereChanged = tagsWereChanged || RES.tagsChanged;
}
for (const auto& wr : toRemove) {
ruleEngine()->unregisterRule(wr);
}
// recheck some props people might wanna use for static rules.
std::underlying_type_t<eRuleProperty> propsToRecheck = RULE_PROP_NONE;
if (tagsWereChanged)
@ -600,6 +594,7 @@ void CWindowRuleApplicator::readStaticRules() {
for (const auto& wr : execRules) {
applyStaticRule(wr);
applyDynamicRule(wr);
ruleEngine()->unregisterRule(wr);
}
}