From 97886cf0dab39ce4b7887e549b93ccec30156ddc Mon Sep 17 00:00:00 2001 From: Vaxry Date: Tue, 28 Apr 2026 15:55:41 +0100 Subject: desktop/rule: cleanup inheritance, use templates to avoid dup --- src/desktop/rule/windowRule/WindowRule.hpp | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) (limited to 'src/desktop/rule/windowRule/WindowRule.hpp') diff --git a/src/desktop/rule/windowRule/WindowRule.hpp b/src/desktop/rule/windowRule/WindowRule.hpp index 19560c15..61fc1520 100644 --- a/src/desktop/rule/windowRule/WindowRule.hpp +++ b/src/desktop/rule/windowRule/WindowRule.hpp @@ -1,6 +1,6 @@ #pragma once -#include "../Rule.hpp" +#include "../RuleWithEffects.hpp" #include "../../DesktopTypes.hpp" #include "../../types/OverridableVar.hpp" #include "WindowRuleEffectContainer.hpp" @@ -33,14 +33,18 @@ namespace Desktop::Rule { using WindowRuleEffectValue = std::variant, SFullscreenStateRule, SOpacityRule, SBorderColorRule>; struct SWindowRuleEffect { + using storageType = CWindowRuleEffectContainer::storageType; + using valueType = WindowRuleEffectValue; + CWindowRuleEffectContainer::storageType key = WINDOW_RULE_EFFECT_NONE; std::string raw; WindowRuleEffectValue value; }; - class CWindowRule : public IRule { + class CWindowRule : public CRuleWithEffects { private: - using storageType = CWindowRuleEffectContainer::storageType; + using Base = CRuleWithEffects; + using storageType = Base::storageType; public: CWindowRule(const std::string& name = ""); @@ -52,20 +56,9 @@ namespace Desktop::Rule { static std::expected, std::string> buildFromExecString(std::string&&); - virtual eRuleType type(); - - std::expected addEffect(storageType e, const std::string& result); - const std::vector& effects(); - const std::unordered_set& effectsSet(); - - void setEnabled(bool enable); - bool isEnabled() const; - bool matches(PHLWINDOW w, bool allowEnvLookup = false); private: - std::vector m_effects; - std::unordered_set m_effectSet; - bool m_enabled = true; + std::expected parseEffect(storageType e, const std::string& result) override; }; }; -- cgit v1.2.3