summaryrefslogtreecommitdiff
path: root/src/desktop/rule/layerRule/LayerRuleApplicator.cpp
diff options
context:
space:
mode:
authorPppp1116 <pcaiadoguerreiro@gmail.com>2026-04-08 12:06:58 +0100
committerGitHub <noreply@github.com>2026-04-08 12:06:58 +0100
commitfb46d16fc2bedea96b6b2a4d005ec66d701431aa (patch)
tree7211d5a9491e3eb924c202dc46182062eceebd45 /src/desktop/rule/layerRule/LayerRuleApplicator.cpp
parentaa8cea66712e4a597d6ebe9c2e82f221c4c7e4e6 (diff)
rules: make rule prop reset less cursed (#14003)
Diffstat (limited to 'src/desktop/rule/layerRule/LayerRuleApplicator.cpp')
-rw-r--r--src/desktop/rule/layerRule/LayerRuleApplicator.cpp40
1 files changed, 19 insertions, 21 deletions
diff --git a/src/desktop/rule/layerRule/LayerRuleApplicator.cpp b/src/desktop/rule/layerRule/LayerRuleApplicator.cpp
index fec3a5b2..8c157dae 100644
--- a/src/desktop/rule/layerRule/LayerRuleApplicator.cpp
+++ b/src/desktop/rule/layerRule/LayerRuleApplicator.cpp
@@ -5,36 +5,34 @@
#include "../../types/OverridableVar.hpp"
#include "../../../helpers/MiscFunctions.hpp"
#include "../../../event/EventBus.hpp"
+#include <tuple>
using namespace Desktop;
using namespace Desktop::Rule;
+namespace {
+ template <typename T>
+ void resetRuleProp(std::pair<Desktop::Types::COverridableVar<T>, std::underlying_type_t<Desktop::Rule::eRuleProperty>>& prop,
+ std::underlying_type_t<Desktop::Rule::eRuleProperty> props, Desktop::Types::eOverridePriority prio) {
+ auto& [value, propMask] = prop;
+
+ if (!(propMask & props))
+ return;
+
+ if (prio == Desktop::Types::PRIORITY_WINDOW_RULE)
+ propMask &= ~props;
+
+ value.unset(prio);
+ }
+}
+
CLayerRuleApplicator::CLayerRuleApplicator(PHLLS ls) : m_ls(ls) {
;
}
void CLayerRuleApplicator::resetProps(std::underlying_type_t<eRuleProperty> props, Types::eOverridePriority prio) {
- // TODO: fucking kill me, is there a better way to do this?
-
-#define UNSET(x) \
- if (m_##x.second & props) { \
- if (prio == Types::PRIORITY_WINDOW_RULE) \
- m_##x.second &= ~props; \
- m_##x.first.unset(prio); \
- }
-
- UNSET(noanim)
- UNSET(blur)
- UNSET(blurPopups)
- UNSET(dimAround)
- UNSET(xray)
- UNSET(noScreenShare)
- UNSET(order)
- UNSET(aboveLock)
- UNSET(ignoreAlpha)
- UNSET(animationStyle)
-
-#undef UNSET
+ std::apply([&](auto&... prop) { (resetRuleProp(prop, props, prio), ...); },
+ std::forward_as_tuple(m_noanim, m_blur, m_blurPopups, m_dimAround, m_xray, m_noScreenShare, m_order, m_aboveLock, m_ignoreAlpha, m_animationStyle));
if (prio == Types::PRIORITY_WINDOW_RULE)
std::erase_if(m_otherProps.props, [props](const auto& el) { return !el.second || el.second->propMask & props; });