summaryrefslogtreecommitdiff
path: root/src/desktop/rule/windowRule/WindowRule.hpp
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2026-04-28 15:55:41 +0100
committerVaxry <43317083+vaxerski@users.noreply.github.com>2026-04-28 16:52:41 +0100
commit97886cf0dab39ce4b7887e549b93ccec30156ddc (patch)
tree14b9c3b575b0a2f38b009d8267ef929109b0d33b /src/desktop/rule/windowRule/WindowRule.hpp
parent89e2380da8d432a84ab93345d82389010172adcf (diff)
desktop/rule: cleanup inheritance, use templates to avoid dup
Diffstat (limited to 'src/desktop/rule/windowRule/WindowRule.hpp')
-rw-r--r--src/desktop/rule/windowRule/WindowRule.hpp23
1 files changed, 8 insertions, 15 deletions
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<std::monostate, bool, int64_t, float, std::string, std::vector<std::string>, 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<SWindowRuleEffect, RULE_TYPE_WINDOW> {
private:
- using storageType = CWindowRuleEffectContainer::storageType;
+ using Base = CRuleWithEffects<SWindowRuleEffect, RULE_TYPE_WINDOW>;
+ using storageType = Base::storageType;
public:
CWindowRule(const std::string& name = "");
@@ -52,20 +56,9 @@ namespace Desktop::Rule {
static std::expected<SP<CWindowRule>, std::string> buildFromExecString(std::string&&);
- virtual eRuleType type();
-
- std::expected<void, std::string> addEffect(storageType e, const std::string& result);
- const std::vector<SWindowRuleEffect>& effects();
- const std::unordered_set<storageType>& effectsSet();
-
- void setEnabled(bool enable);
- bool isEnabled() const;
-
bool matches(PHLWINDOW w, bool allowEnvLookup = false);
private:
- std::vector<SWindowRuleEffect> m_effects;
- std::unordered_set<storageType> m_effectSet;
- bool m_enabled = true;
+ std::expected<WindowRuleEffectValue, std::string> parseEffect(storageType e, const std::string& result) override;
};
};