desktop/windowRule: return reset props from resetProps and recheck them (#12458)
fixes #12457
This commit is contained in:
parent
f9742ab501
commit
68eecf61cd
2 changed files with 59 additions and 71 deletions
|
|
@ -18,13 +18,17 @@ CWindowRuleApplicator::CWindowRuleApplicator(PHLWINDOW w) : m_window(w) {
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWindowRuleApplicator::resetProps(std::underlying_type_t<eRuleProperty> props, Types::eOverridePriority prio) {
|
std::unordered_set<CWindowRuleEffectContainer::storageType> CWindowRuleApplicator::resetProps(std::underlying_type_t<eRuleProperty> props, Types::eOverridePriority prio) {
|
||||||
// TODO: fucking kill me, is there a better way to do this?
|
// TODO: fucking kill me, is there a better way to do this?
|
||||||
|
|
||||||
|
std::unordered_set<CWindowRuleEffectContainer::storageType> effectsNuked;
|
||||||
|
|
||||||
#define UNSET(x) \
|
#define UNSET(x) \
|
||||||
if (m_##x.second & props) { \
|
if (m_##x.second & props) { \
|
||||||
if (prio == Types::PRIORITY_WINDOW_RULE) \
|
if (prio == Types::PRIORITY_WINDOW_RULE) { \
|
||||||
|
effectsNuked.emplace(x##Effect()); \
|
||||||
m_##x.second &= ~props; \
|
m_##x.second &= ~props; \
|
||||||
|
} \
|
||||||
m_##x.first.unset(prio); \
|
m_##x.first.unset(prio); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -81,6 +85,8 @@ void CWindowRuleApplicator::resetProps(std::underlying_type_t<eRuleProperty> pro
|
||||||
|
|
||||||
std::erase_if(m_otherProps.props, [props](const auto& el) { return !el.second || el.second->propMask & props; });
|
std::erase_if(m_otherProps.props, [props](const auto& el) { return !el.second || el.second->propMask & props; });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return effectsNuked;
|
||||||
}
|
}
|
||||||
|
|
||||||
CWindowRuleApplicator::SRuleResult CWindowRuleApplicator::applyDynamicRule(const SP<CWindowRule>& rule) {
|
CWindowRuleApplicator::SRuleResult CWindowRuleApplicator::applyDynamicRule(const SP<CWindowRule>& rule) {
|
||||||
|
|
@ -592,31 +598,8 @@ void CWindowRuleApplicator::propertiesChanged(std::underlying_type_t<eRuleProper
|
||||||
if (!m_window || !m_window->m_isMapped || m_window->isHidden())
|
if (!m_window || !m_window->m_isMapped || m_window->isHidden())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
resetProps(props);
|
bool needsRelayout = false;
|
||||||
|
std::unordered_set<CWindowRuleEffectContainer::storageType> effectsNeedingRecheck = resetProps(props);
|
||||||
bool needsRelayout = false;
|
|
||||||
|
|
||||||
std::unordered_set<CWindowRuleEffectContainer::storageType> effectsNeedingRecheck;
|
|
||||||
std::unordered_set<SP<CWindowRule>> passedWrs;
|
|
||||||
|
|
||||||
for (const auto& r : ruleEngine()->rules()) {
|
|
||||||
if (r->type() != RULE_TYPE_WINDOW)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!(r->getPropertiesMask() & props))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
auto wr = reinterpretPointerCast<CWindowRule>(r);
|
|
||||||
|
|
||||||
if (!wr->matches(m_window.lock()))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
for (const auto& [type, eff] : wr->effects()) {
|
|
||||||
effectsNeedingRecheck.emplace(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
passedWrs.emplace(std::move(wr));
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const auto& r : ruleEngine()->rules()) {
|
for (const auto& r : ruleEngine()->rules()) {
|
||||||
if (r->type() != RULE_TYPE_WINDOW)
|
if (r->type() != RULE_TYPE_WINDOW)
|
||||||
|
|
@ -627,7 +610,7 @@ void CWindowRuleApplicator::propertiesChanged(std::underlying_type_t<eRuleProper
|
||||||
if (!(WR->getPropertiesMask() & props) && !setsIntersect(WR->effectsSet(), effectsNeedingRecheck))
|
if (!(WR->getPropertiesMask() & props) && !setsIntersect(WR->effectsSet(), effectsNeedingRecheck))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!std::ranges::contains(passedWrs, WR) && !WR->matches(m_window.lock()))
|
if (!WR->matches(m_window.lock()))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const auto RES = applyDynamicRule(WR);
|
const auto RES = applyDynamicRule(WR);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
#include <unordered_set>
|
||||||
|
|
||||||
#include "WindowRuleEffectContainer.hpp"
|
#include "WindowRuleEffectContainer.hpp"
|
||||||
#include "../../DesktopTypes.hpp"
|
#include "../../DesktopTypes.hpp"
|
||||||
|
|
@ -29,10 +30,11 @@ namespace Desktop::Rule {
|
||||||
CWindowRuleApplicator(CWindowRuleApplicator&) = delete;
|
CWindowRuleApplicator(CWindowRuleApplicator&) = delete;
|
||||||
CWindowRuleApplicator(CWindowRuleApplicator&&) = delete;
|
CWindowRuleApplicator(CWindowRuleApplicator&&) = delete;
|
||||||
|
|
||||||
void propertiesChanged(std::underlying_type_t<eRuleProperty> props);
|
void propertiesChanged(std::underlying_type_t<eRuleProperty> props);
|
||||||
void resetProps(std::underlying_type_t<eRuleProperty> props, Types::eOverridePriority prio = Types::PRIORITY_WINDOW_RULE);
|
std::unordered_set<CWindowRuleEffectContainer::storageType> resetProps(std::underlying_type_t<eRuleProperty> props,
|
||||||
void readStaticRules();
|
Types::eOverridePriority prio = Types::PRIORITY_WINDOW_RULE);
|
||||||
void applyStaticRules();
|
void readStaticRules();
|
||||||
|
void applyStaticRules();
|
||||||
|
|
||||||
// static props
|
// static props
|
||||||
struct {
|
struct {
|
||||||
|
|
@ -69,7 +71,7 @@ namespace Desktop::Rule {
|
||||||
} m_otherProps;
|
} m_otherProps;
|
||||||
|
|
||||||
#define COMMA ,
|
#define COMMA ,
|
||||||
#define DEFINE_PROP(type, name, def) \
|
#define DEFINE_PROP(type, name, def, eff) \
|
||||||
private: \
|
private: \
|
||||||
std::pair<Types::COverridableVar<type>, std::underlying_type_t<eRuleProperty>> m_##name = {def, RULE_PROP_NONE}; \
|
std::pair<Types::COverridableVar<type>, std::underlying_type_t<eRuleProperty>> m_##name = {def, RULE_PROP_NONE}; \
|
||||||
\
|
\
|
||||||
|
|
@ -79,54 +81,57 @@ namespace Desktop::Rule {
|
||||||
} \
|
} \
|
||||||
void name##Override(const Types::COverridableVar<type>& other) { \
|
void name##Override(const Types::COverridableVar<type>& other) { \
|
||||||
m_##name.first = other; \
|
m_##name.first = other; \
|
||||||
|
} \
|
||||||
|
eWindowRuleEffect name##Effect() { \
|
||||||
|
return eff; \
|
||||||
}
|
}
|
||||||
|
|
||||||
// dynamic props
|
// dynamic props
|
||||||
DEFINE_PROP(Types::SAlphaValue, alpha, Types::SAlphaValue{})
|
DEFINE_PROP(Types::SAlphaValue, alpha, Types::SAlphaValue{}, WINDOW_RULE_EFFECT_OPACITY)
|
||||||
DEFINE_PROP(Types::SAlphaValue, alphaInactive, Types::SAlphaValue{})
|
DEFINE_PROP(Types::SAlphaValue, alphaInactive, Types::SAlphaValue{}, WINDOW_RULE_EFFECT_OPACITY)
|
||||||
DEFINE_PROP(Types::SAlphaValue, alphaFullscreen, Types::SAlphaValue{})
|
DEFINE_PROP(Types::SAlphaValue, alphaFullscreen, Types::SAlphaValue{}, WINDOW_RULE_EFFECT_OPACITY)
|
||||||
|
|
||||||
DEFINE_PROP(bool, allowsInput, false)
|
DEFINE_PROP(bool, allowsInput, false, WINDOW_RULE_EFFECT_ALLOWS_INPUT)
|
||||||
DEFINE_PROP(bool, decorate, true)
|
DEFINE_PROP(bool, decorate, true, WINDOW_RULE_EFFECT_DECORATE)
|
||||||
DEFINE_PROP(bool, focusOnActivate, false)
|
DEFINE_PROP(bool, focusOnActivate, false, WINDOW_RULE_EFFECT_FOCUS_ON_ACTIVATE)
|
||||||
DEFINE_PROP(bool, keepAspectRatio, false)
|
DEFINE_PROP(bool, keepAspectRatio, false, WINDOW_RULE_EFFECT_KEEP_ASPECT_RATIO)
|
||||||
DEFINE_PROP(bool, nearestNeighbor, false)
|
DEFINE_PROP(bool, nearestNeighbor, false, WINDOW_RULE_EFFECT_NEAREST_NEIGHBOR)
|
||||||
DEFINE_PROP(bool, noAnim, false)
|
DEFINE_PROP(bool, noAnim, false, WINDOW_RULE_EFFECT_NO_ANIM)
|
||||||
DEFINE_PROP(bool, noBlur, false)
|
DEFINE_PROP(bool, noBlur, false, WINDOW_RULE_EFFECT_NO_BLUR)
|
||||||
DEFINE_PROP(bool, noDim, false)
|
DEFINE_PROP(bool, noDim, false, WINDOW_RULE_EFFECT_NO_DIM)
|
||||||
DEFINE_PROP(bool, noFocus, false)
|
DEFINE_PROP(bool, noFocus, false, WINDOW_RULE_EFFECT_NO_FOCUS)
|
||||||
DEFINE_PROP(bool, noMaxSize, false)
|
DEFINE_PROP(bool, noMaxSize, false, WINDOW_RULE_EFFECT_NO_MAX_SIZE)
|
||||||
DEFINE_PROP(bool, noShadow, false)
|
DEFINE_PROP(bool, noShadow, false, WINDOW_RULE_EFFECT_NO_SHADOW)
|
||||||
DEFINE_PROP(bool, noShortcutsInhibit, false)
|
DEFINE_PROP(bool, noShortcutsInhibit, false, WINDOW_RULE_EFFECT_NO_SHORTCUTS_INHIBIT)
|
||||||
DEFINE_PROP(bool, opaque, false)
|
DEFINE_PROP(bool, opaque, false, WINDOW_RULE_EFFECT_OPAQUE)
|
||||||
DEFINE_PROP(bool, dimAround, false)
|
DEFINE_PROP(bool, dimAround, false, WINDOW_RULE_EFFECT_DIM_AROUND)
|
||||||
DEFINE_PROP(bool, RGBX, false)
|
DEFINE_PROP(bool, RGBX, false, WINDOW_RULE_EFFECT_FORCE_RGBX)
|
||||||
DEFINE_PROP(bool, syncFullscreen, true)
|
DEFINE_PROP(bool, syncFullscreen, true, WINDOW_RULE_EFFECT_SYNC_FULLSCREEN)
|
||||||
DEFINE_PROP(bool, tearing, false)
|
DEFINE_PROP(bool, tearing, false, WINDOW_RULE_EFFECT_IMMEDIATE)
|
||||||
DEFINE_PROP(bool, xray, false)
|
DEFINE_PROP(bool, xray, false, WINDOW_RULE_EFFECT_XRAY)
|
||||||
DEFINE_PROP(bool, renderUnfocused, false)
|
DEFINE_PROP(bool, renderUnfocused, false, WINDOW_RULE_EFFECT_RENDER_UNFOCUSED)
|
||||||
DEFINE_PROP(bool, noFollowMouse, false)
|
DEFINE_PROP(bool, noFollowMouse, false, WINDOW_RULE_EFFECT_NO_FOLLOW_MOUSE)
|
||||||
DEFINE_PROP(bool, noScreenShare, false)
|
DEFINE_PROP(bool, noScreenShare, false, WINDOW_RULE_EFFECT_NO_SCREEN_SHARE)
|
||||||
DEFINE_PROP(bool, noVRR, false)
|
DEFINE_PROP(bool, noVRR, false, WINDOW_RULE_EFFECT_NO_VRR)
|
||||||
DEFINE_PROP(bool, persistentSize, false)
|
DEFINE_PROP(bool, persistentSize, false, WINDOW_RULE_EFFECT_PERSISTENT_SIZE)
|
||||||
DEFINE_PROP(bool, stayFocused, false)
|
DEFINE_PROP(bool, stayFocused, false, WINDOW_RULE_EFFECT_STAY_FOCUSED)
|
||||||
|
|
||||||
DEFINE_PROP(int, idleInhibitMode, false)
|
DEFINE_PROP(int, idleInhibitMode, false, WINDOW_RULE_EFFECT_IDLE_INHIBIT)
|
||||||
|
|
||||||
DEFINE_PROP(Hyprlang::INT, borderSize, {std::string("general:border_size") COMMA sc<Hyprlang::INT>(0) COMMA std::nullopt})
|
DEFINE_PROP(Hyprlang::INT, borderSize, {std::string("general:border_size") COMMA sc<Hyprlang::INT>(0) COMMA std::nullopt}, WINDOW_RULE_EFFECT_BORDER_SIZE)
|
||||||
DEFINE_PROP(Hyprlang::INT, rounding, {std::string("decoration:rounding") COMMA sc<Hyprlang::INT>(0) COMMA std::nullopt})
|
DEFINE_PROP(Hyprlang::INT, rounding, {std::string("decoration:rounding") COMMA sc<Hyprlang::INT>(0) COMMA std::nullopt}, WINDOW_RULE_EFFECT_ROUNDING)
|
||||||
|
|
||||||
DEFINE_PROP(Hyprlang::FLOAT, roundingPower, {std::string("decoration:rounding_power")})
|
DEFINE_PROP(Hyprlang::FLOAT, roundingPower, {std::string("decoration:rounding_power")}, WINDOW_RULE_EFFECT_ROUNDING_POWER)
|
||||||
DEFINE_PROP(Hyprlang::FLOAT, scrollMouse, {std::string("input:scroll_factor")})
|
DEFINE_PROP(Hyprlang::FLOAT, scrollMouse, {std::string("input:scroll_factor")}, WINDOW_RULE_EFFECT_SCROLL_MOUSE)
|
||||||
DEFINE_PROP(Hyprlang::FLOAT, scrollTouchpad, {std::string("input:touchpad:scroll_factor")})
|
DEFINE_PROP(Hyprlang::FLOAT, scrollTouchpad, {std::string("input:touchpad:scroll_factor")}, WINDOW_RULE_EFFECT_SCROLL_TOUCHPAD)
|
||||||
|
|
||||||
DEFINE_PROP(std::string, animationStyle, std::string(""))
|
DEFINE_PROP(std::string, animationStyle, std::string(""), WINDOW_RULE_EFFECT_ANIMATION)
|
||||||
|
|
||||||
DEFINE_PROP(Vector2D, maxSize, Vector2D{})
|
DEFINE_PROP(Vector2D, maxSize, Vector2D{}, WINDOW_RULE_EFFECT_MAX_SIZE)
|
||||||
DEFINE_PROP(Vector2D, minSize, Vector2D{})
|
DEFINE_PROP(Vector2D, minSize, Vector2D{}, WINDOW_RULE_EFFECT_MIN_SIZE)
|
||||||
|
|
||||||
DEFINE_PROP(CGradientValueData, activeBorderColor, {})
|
DEFINE_PROP(CGradientValueData, activeBorderColor, {}, WINDOW_RULE_EFFECT_BORDER_COLOR)
|
||||||
DEFINE_PROP(CGradientValueData, inactiveBorderColor, {})
|
DEFINE_PROP(CGradientValueData, inactiveBorderColor, {}, WINDOW_RULE_EFFECT_BORDER_COLOR)
|
||||||
|
|
||||||
std::vector<std::pair<std::string, std::underlying_type_t<eRuleProperty>>> m_dynamicTags;
|
std::vector<std::pair<std::string, std::underlying_type_t<eRuleProperty>>> m_dynamicTags;
|
||||||
CTagKeeper m_tagKeeper;
|
CTagKeeper m_tagKeeper;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue