summaryrefslogtreecommitdiff
path: root/src/desktop/rule/windowRule/WindowRuleApplicator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/desktop/rule/windowRule/WindowRuleApplicator.cpp')
-rw-r--r--src/desktop/rule/windowRule/WindowRuleApplicator.cpp94
1 files changed, 43 insertions, 51 deletions
diff --git a/src/desktop/rule/windowRule/WindowRuleApplicator.cpp b/src/desktop/rule/windowRule/WindowRuleApplicator.cpp
index a9e82ef5..4af0d2ba 100644
--- a/src/desktop/rule/windowRule/WindowRuleApplicator.cpp
+++ b/src/desktop/rule/windowRule/WindowRuleApplicator.cpp
@@ -9,70 +9,62 @@
#include <hyprutils/string/String.hpp>
#include <hyprutils/string/VarList.hpp>
#include <hyprutils/string/VarList2.hpp>
+#include <tuple>
using namespace Hyprutils::String;
using namespace Desktop;
using namespace Desktop::Rule;
+namespace {
+ template <typename T, typename TEffect>
+ 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,
+ std::unordered_set<Desktop::Rule::CWindowRuleEffectContainer::storageType>& effectsNuked, TEffect&& effect) {
+ auto& [value, propMask] = prop;
+
+ if (!(propMask & props))
+ return;
+
+ if (prio == Desktop::Types::PRIORITY_WINDOW_RULE) {
+ effectsNuked.emplace(effect());
+ propMask &= ~props;
+ }
+
+ value.unset(prio);
+ }
+}
+
CWindowRuleApplicator::CWindowRuleApplicator(PHLWINDOW w) : m_window(w) {
;
}
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?
-
std::unordered_set<CWindowRuleEffectContainer::storageType> effectsNuked;
-#define UNSET(x) \
- if (m_##x.second & props) { \
- if (prio == Types::PRIORITY_WINDOW_RULE) { \
- effectsNuked.emplace(x##Effect()); \
- m_##x.second &= ~props; \
- } \
- m_##x.first.unset(prio); \
- }
-
- UNSET(alpha)
- UNSET(alphaInactive)
- UNSET(alphaFullscreen)
- UNSET(allowsInput)
- UNSET(decorate)
- UNSET(focusOnActivate)
- UNSET(keepAspectRatio)
- UNSET(nearestNeighbor)
- UNSET(noAnim)
- UNSET(noBlur)
- UNSET(noDim)
- UNSET(noFocus)
- UNSET(noMaxSize)
- UNSET(noShadow)
- UNSET(noShortcutsInhibit)
- UNSET(opaque)
- UNSET(dimAround)
- UNSET(RGBX)
- UNSET(syncFullscreen)
- UNSET(tearing)
- UNSET(xray)
- UNSET(renderUnfocused)
- UNSET(noFollowMouse)
- UNSET(noScreenShare)
- UNSET(noVRR)
- UNSET(persistentSize)
- UNSET(stayFocused)
- UNSET(idleInhibitMode)
- UNSET(borderSize)
- UNSET(rounding)
- UNSET(roundingPower)
- UNSET(scrollMouse)
- UNSET(scrollTouchpad)
- UNSET(animationStyle)
- UNSET(maxSize)
- UNSET(minSize)
- UNSET(activeBorderColor)
- UNSET(inactiveBorderColor)
-
-#undef UNSET
+ std::apply([&](auto&&... prop) { (resetRuleProp(prop.first.get(), props, prio, effectsNuked, prop.second), ...); },
+ std::make_tuple(
+ std::pair{std::ref(m_alpha), [this] { return alphaEffect(); }}, std::pair{std::ref(m_alphaInactive), [this] { return alphaInactiveEffect(); }},
+ std::pair{std::ref(m_alphaFullscreen), [this] { return alphaFullscreenEffect(); }}, std::pair{std::ref(m_allowsInput), [this] { return allowsInputEffect(); }},
+ std::pair{std::ref(m_decorate), [this] { return decorateEffect(); }}, std::pair{std::ref(m_focusOnActivate), [this] { return focusOnActivateEffect(); }},
+ std::pair{std::ref(m_keepAspectRatio), [this] { return keepAspectRatioEffect(); }},
+ std::pair{std::ref(m_nearestNeighbor), [this] { return nearestNeighborEffect(); }}, std::pair{std::ref(m_noAnim), [this] { return noAnimEffect(); }},
+ std::pair{std::ref(m_noBlur), [this] { return noBlurEffect(); }}, std::pair{std::ref(m_noDim), [this] { return noDimEffect(); }},
+ std::pair{std::ref(m_noFocus), [this] { return noFocusEffect(); }}, std::pair{std::ref(m_noMaxSize), [this] { return noMaxSizeEffect(); }},
+ std::pair{std::ref(m_noShadow), [this] { return noShadowEffect(); }}, std::pair{std::ref(m_noShortcutsInhibit), [this] { return noShortcutsInhibitEffect(); }},
+ std::pair{std::ref(m_opaque), [this] { return opaqueEffect(); }}, std::pair{std::ref(m_dimAround), [this] { return dimAroundEffect(); }},
+ std::pair{std::ref(m_RGBX), [this] { return RGBXEffect(); }}, std::pair{std::ref(m_syncFullscreen), [this] { return syncFullscreenEffect(); }},
+ std::pair{std::ref(m_tearing), [this] { return tearingEffect(); }}, std::pair{std::ref(m_xray), [this] { return xrayEffect(); }},
+ std::pair{std::ref(m_renderUnfocused), [this] { return renderUnfocusedEffect(); }},
+ std::pair{std::ref(m_noFollowMouse), [this] { return noFollowMouseEffect(); }}, std::pair{std::ref(m_noScreenShare), [this] { return noScreenShareEffect(); }},
+ std::pair{std::ref(m_noVRR), [this] { return noVRREffect(); }}, std::pair{std::ref(m_persistentSize), [this] { return persistentSizeEffect(); }},
+ std::pair{std::ref(m_stayFocused), [this] { return stayFocusedEffect(); }}, std::pair{std::ref(m_idleInhibitMode), [this] { return idleInhibitModeEffect(); }},
+ std::pair{std::ref(m_borderSize), [this] { return borderSizeEffect(); }}, std::pair{std::ref(m_rounding), [this] { return roundingEffect(); }},
+ std::pair{std::ref(m_roundingPower), [this] { return roundingPowerEffect(); }}, std::pair{std::ref(m_scrollMouse), [this] { return scrollMouseEffect(); }},
+ std::pair{std::ref(m_scrollTouchpad), [this] { return scrollTouchpadEffect(); }},
+ std::pair{std::ref(m_animationStyle), [this] { return animationStyleEffect(); }}, std::pair{std::ref(m_maxSize), [this] { return maxSizeEffect(); }},
+ std::pair{std::ref(m_minSize), [this] { return minSizeEffect(); }}, std::pair{std::ref(m_activeBorderColor), [this] { return activeBorderColorEffect(); }},
+ std::pair{std::ref(m_inactiveBorderColor), [this] { return inactiveBorderColorEffect(); }}));
if (prio == Types::PRIORITY_WINDOW_RULE) {
std::erase_if(m_dynamicTags, [props, this](const auto& el) {