Skip to content

Commit 68eecf6

Browse files
authored
desktop/windowRule: return reset props from resetProps and recheck them (#12458)
fixes #12457
1 parent f9742ab commit 68eecf6

File tree

2 files changed

+66
-78
lines changed

2 files changed

+66
-78
lines changed

src/desktop/rule/windowRule/WindowRuleApplicator.cpp

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,17 @@ CWindowRuleApplicator::CWindowRuleApplicator(PHLWINDOW w) : m_window(w) {
1818
;
1919
}
2020

21-
void CWindowRuleApplicator::resetProps(std::underlying_type_t<eRuleProperty> props, Types::eOverridePriority prio) {
21+
std::unordered_set<CWindowRuleEffectContainer::storageType> CWindowRuleApplicator::resetProps(std::underlying_type_t<eRuleProperty> props, Types::eOverridePriority prio) {
2222
// TODO: fucking kill me, is there a better way to do this?
2323

24+
std::unordered_set<CWindowRuleEffectContainer::storageType> effectsNuked;
25+
2426
#define UNSET(x) \
2527
if (m_##x.second & props) { \
26-
if (prio == Types::PRIORITY_WINDOW_RULE) \
28+
if (prio == Types::PRIORITY_WINDOW_RULE) { \
29+
effectsNuked.emplace(x##Effect()); \
2730
m_##x.second &= ~props; \
31+
} \
2832
m_##x.first.unset(prio); \
2933
}
3034

@@ -81,6 +85,8 @@ void CWindowRuleApplicator::resetProps(std::underlying_type_t<eRuleProperty> pro
8185

8286
std::erase_if(m_otherProps.props, [props](const auto& el) { return !el.second || el.second->propMask & props; });
8387
}
88+
89+
return effectsNuked;
8490
}
8591

8692
CWindowRuleApplicator::SRuleResult CWindowRuleApplicator::applyDynamicRule(const SP<CWindowRule>& rule) {
@@ -592,31 +598,8 @@ void CWindowRuleApplicator::propertiesChanged(std::underlying_type_t<eRuleProper
592598
if (!m_window || !m_window->m_isMapped || m_window->isHidden())
593599
return;
594600

595-
resetProps(props);
596-
597-
bool needsRelayout = false;
598-
599-
std::unordered_set<CWindowRuleEffectContainer::storageType> effectsNeedingRecheck;
600-
std::unordered_set<SP<CWindowRule>> passedWrs;
601-
602-
for (const auto& r : ruleEngine()->rules()) {
603-
if (r->type() != RULE_TYPE_WINDOW)
604-
continue;
605-
606-
if (!(r->getPropertiesMask() & props))
607-
continue;
608-
609-
auto wr = reinterpretPointerCast<CWindowRule>(r);
610-
611-
if (!wr->matches(m_window.lock()))
612-
continue;
613-
614-
for (const auto& [type, eff] : wr->effects()) {
615-
effectsNeedingRecheck.emplace(type);
616-
}
617-
618-
passedWrs.emplace(std::move(wr));
619-
}
601+
bool needsRelayout = false;
602+
std::unordered_set<CWindowRuleEffectContainer::storageType> effectsNeedingRecheck = resetProps(props);
620603

621604
for (const auto& r : ruleEngine()->rules()) {
622605
if (r->type() != RULE_TYPE_WINDOW)
@@ -627,7 +610,7 @@ void CWindowRuleApplicator::propertiesChanged(std::underlying_type_t<eRuleProper
627610
if (!(WR->getPropertiesMask() & props) && !setsIntersect(WR->effectsSet(), effectsNeedingRecheck))
628611
continue;
629612

630-
if (!std::ranges::contains(passedWrs, WR) && !WR->matches(m_window.lock()))
613+
if (!WR->matches(m_window.lock()))
631614
continue;
632615

633616
const auto RES = applyDynamicRule(WR);

src/desktop/rule/windowRule/WindowRuleApplicator.hpp

Lines changed: 55 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma once
22

33
#include <unordered_map>
4+
#include <unordered_set>
45

56
#include "WindowRuleEffectContainer.hpp"
67
#include "../../DesktopTypes.hpp"
@@ -29,10 +30,11 @@ namespace Desktop::Rule {
2930
CWindowRuleApplicator(CWindowRuleApplicator&) = delete;
3031
CWindowRuleApplicator(CWindowRuleApplicator&&) = delete;
3132

32-
void propertiesChanged(std::underlying_type_t<eRuleProperty> props);
33-
void resetProps(std::underlying_type_t<eRuleProperty> props, Types::eOverridePriority prio = Types::PRIORITY_WINDOW_RULE);
34-
void readStaticRules();
35-
void applyStaticRules();
33+
void propertiesChanged(std::underlying_type_t<eRuleProperty> props);
34+
std::unordered_set<CWindowRuleEffectContainer::storageType> resetProps(std::underlying_type_t<eRuleProperty> props,
35+
Types::eOverridePriority prio = Types::PRIORITY_WINDOW_RULE);
36+
void readStaticRules();
37+
void applyStaticRules();
3638

3739
// static props
3840
struct {
@@ -69,7 +71,7 @@ namespace Desktop::Rule {
6971
} m_otherProps;
7072

7173
#define COMMA ,
72-
#define DEFINE_PROP(type, name, def) \
74+
#define DEFINE_PROP(type, name, def, eff) \
7375
private: \
7476
std::pair<Types::COverridableVar<type>, std::underlying_type_t<eRuleProperty>> m_##name = {def, RULE_PROP_NONE}; \
7577
\
@@ -79,54 +81,57 @@ namespace Desktop::Rule {
7981
} \
8082
void name##Override(const Types::COverridableVar<type>& other) { \
8183
m_##name.first = other; \
84+
} \
85+
eWindowRuleEffect name##Effect() { \
86+
return eff; \
8287
}
8388

8489
// dynamic props
85-
DEFINE_PROP(Types::SAlphaValue, alpha, Types::SAlphaValue{})
86-
DEFINE_PROP(Types::SAlphaValue, alphaInactive, Types::SAlphaValue{})
87-
DEFINE_PROP(Types::SAlphaValue, alphaFullscreen, Types::SAlphaValue{})
88-
89-
DEFINE_PROP(bool, allowsInput, false)
90-
DEFINE_PROP(bool, decorate, true)
91-
DEFINE_PROP(bool, focusOnActivate, false)
92-
DEFINE_PROP(bool, keepAspectRatio, false)
93-
DEFINE_PROP(bool, nearestNeighbor, false)
94-
DEFINE_PROP(bool, noAnim, false)
95-
DEFINE_PROP(bool, noBlur, false)
96-
DEFINE_PROP(bool, noDim, false)
97-
DEFINE_PROP(bool, noFocus, false)
98-
DEFINE_PROP(bool, noMaxSize, false)
99-
DEFINE_PROP(bool, noShadow, false)
100-
DEFINE_PROP(bool, noShortcutsInhibit, false)
101-
DEFINE_PROP(bool, opaque, false)
102-
DEFINE_PROP(bool, dimAround, false)
103-
DEFINE_PROP(bool, RGBX, false)
104-
DEFINE_PROP(bool, syncFullscreen, true)
105-
DEFINE_PROP(bool, tearing, false)
106-
DEFINE_PROP(bool, xray, false)
107-
DEFINE_PROP(bool, renderUnfocused, false)
108-
DEFINE_PROP(bool, noFollowMouse, false)
109-
DEFINE_PROP(bool, noScreenShare, false)
110-
DEFINE_PROP(bool, noVRR, false)
111-
DEFINE_PROP(bool, persistentSize, false)
112-
DEFINE_PROP(bool, stayFocused, false)
113-
114-
DEFINE_PROP(int, idleInhibitMode, false)
115-
116-
DEFINE_PROP(Hyprlang::INT, borderSize, {std::string("general:border_size") COMMA sc<Hyprlang::INT>(0) COMMA std::nullopt})
117-
DEFINE_PROP(Hyprlang::INT, rounding, {std::string("decoration:rounding") COMMA sc<Hyprlang::INT>(0) COMMA std::nullopt})
118-
119-
DEFINE_PROP(Hyprlang::FLOAT, roundingPower, {std::string("decoration:rounding_power")})
120-
DEFINE_PROP(Hyprlang::FLOAT, scrollMouse, {std::string("input:scroll_factor")})
121-
DEFINE_PROP(Hyprlang::FLOAT, scrollTouchpad, {std::string("input:touchpad:scroll_factor")})
122-
123-
DEFINE_PROP(std::string, animationStyle, std::string(""))
124-
125-
DEFINE_PROP(Vector2D, maxSize, Vector2D{})
126-
DEFINE_PROP(Vector2D, minSize, Vector2D{})
127-
128-
DEFINE_PROP(CGradientValueData, activeBorderColor, {})
129-
DEFINE_PROP(CGradientValueData, inactiveBorderColor, {})
90+
DEFINE_PROP(Types::SAlphaValue, alpha, Types::SAlphaValue{}, WINDOW_RULE_EFFECT_OPACITY)
91+
DEFINE_PROP(Types::SAlphaValue, alphaInactive, Types::SAlphaValue{}, WINDOW_RULE_EFFECT_OPACITY)
92+
DEFINE_PROP(Types::SAlphaValue, alphaFullscreen, Types::SAlphaValue{}, WINDOW_RULE_EFFECT_OPACITY)
93+
94+
DEFINE_PROP(bool, allowsInput, false, WINDOW_RULE_EFFECT_ALLOWS_INPUT)
95+
DEFINE_PROP(bool, decorate, true, WINDOW_RULE_EFFECT_DECORATE)
96+
DEFINE_PROP(bool, focusOnActivate, false, WINDOW_RULE_EFFECT_FOCUS_ON_ACTIVATE)
97+
DEFINE_PROP(bool, keepAspectRatio, false, WINDOW_RULE_EFFECT_KEEP_ASPECT_RATIO)
98+
DEFINE_PROP(bool, nearestNeighbor, false, WINDOW_RULE_EFFECT_NEAREST_NEIGHBOR)
99+
DEFINE_PROP(bool, noAnim, false, WINDOW_RULE_EFFECT_NO_ANIM)
100+
DEFINE_PROP(bool, noBlur, false, WINDOW_RULE_EFFECT_NO_BLUR)
101+
DEFINE_PROP(bool, noDim, false, WINDOW_RULE_EFFECT_NO_DIM)
102+
DEFINE_PROP(bool, noFocus, false, WINDOW_RULE_EFFECT_NO_FOCUS)
103+
DEFINE_PROP(bool, noMaxSize, false, WINDOW_RULE_EFFECT_NO_MAX_SIZE)
104+
DEFINE_PROP(bool, noShadow, false, WINDOW_RULE_EFFECT_NO_SHADOW)
105+
DEFINE_PROP(bool, noShortcutsInhibit, false, WINDOW_RULE_EFFECT_NO_SHORTCUTS_INHIBIT)
106+
DEFINE_PROP(bool, opaque, false, WINDOW_RULE_EFFECT_OPAQUE)
107+
DEFINE_PROP(bool, dimAround, false, WINDOW_RULE_EFFECT_DIM_AROUND)
108+
DEFINE_PROP(bool, RGBX, false, WINDOW_RULE_EFFECT_FORCE_RGBX)
109+
DEFINE_PROP(bool, syncFullscreen, true, WINDOW_RULE_EFFECT_SYNC_FULLSCREEN)
110+
DEFINE_PROP(bool, tearing, false, WINDOW_RULE_EFFECT_IMMEDIATE)
111+
DEFINE_PROP(bool, xray, false, WINDOW_RULE_EFFECT_XRAY)
112+
DEFINE_PROP(bool, renderUnfocused, false, WINDOW_RULE_EFFECT_RENDER_UNFOCUSED)
113+
DEFINE_PROP(bool, noFollowMouse, false, WINDOW_RULE_EFFECT_NO_FOLLOW_MOUSE)
114+
DEFINE_PROP(bool, noScreenShare, false, WINDOW_RULE_EFFECT_NO_SCREEN_SHARE)
115+
DEFINE_PROP(bool, noVRR, false, WINDOW_RULE_EFFECT_NO_VRR)
116+
DEFINE_PROP(bool, persistentSize, false, WINDOW_RULE_EFFECT_PERSISTENT_SIZE)
117+
DEFINE_PROP(bool, stayFocused, false, WINDOW_RULE_EFFECT_STAY_FOCUSED)
118+
119+
DEFINE_PROP(int, idleInhibitMode, false, WINDOW_RULE_EFFECT_IDLE_INHIBIT)
120+
121+
DEFINE_PROP(Hyprlang::INT, borderSize, {std::string("general:border_size") COMMA sc<Hyprlang::INT>(0) COMMA std::nullopt}, WINDOW_RULE_EFFECT_BORDER_SIZE)
122+
DEFINE_PROP(Hyprlang::INT, rounding, {std::string("decoration:rounding") COMMA sc<Hyprlang::INT>(0) COMMA std::nullopt}, WINDOW_RULE_EFFECT_ROUNDING)
123+
124+
DEFINE_PROP(Hyprlang::FLOAT, roundingPower, {std::string("decoration:rounding_power")}, WINDOW_RULE_EFFECT_ROUNDING_POWER)
125+
DEFINE_PROP(Hyprlang::FLOAT, scrollMouse, {std::string("input:scroll_factor")}, WINDOW_RULE_EFFECT_SCROLL_MOUSE)
126+
DEFINE_PROP(Hyprlang::FLOAT, scrollTouchpad, {std::string("input:touchpad:scroll_factor")}, WINDOW_RULE_EFFECT_SCROLL_TOUCHPAD)
127+
128+
DEFINE_PROP(std::string, animationStyle, std::string(""), WINDOW_RULE_EFFECT_ANIMATION)
129+
130+
DEFINE_PROP(Vector2D, maxSize, Vector2D{}, WINDOW_RULE_EFFECT_MAX_SIZE)
131+
DEFINE_PROP(Vector2D, minSize, Vector2D{}, WINDOW_RULE_EFFECT_MIN_SIZE)
132+
133+
DEFINE_PROP(CGradientValueData, activeBorderColor, {}, WINDOW_RULE_EFFECT_BORDER_COLOR)
134+
DEFINE_PROP(CGradientValueData, inactiveBorderColor, {}, WINDOW_RULE_EFFECT_BORDER_COLOR)
130135

131136
std::vector<std::pair<std::string, std::underlying_type_t<eRuleProperty>>> m_dynamicTags;
132137
CTagKeeper m_tagKeeper;

0 commit comments

Comments
 (0)