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.cpp | 35 ++++-------------------------- 1 file changed, 4 insertions(+), 31 deletions(-) (limited to 'src/desktop/rule/windowRule/WindowRule.cpp') diff --git a/src/desktop/rule/windowRule/WindowRule.cpp b/src/desktop/rule/windowRule/WindowRule.cpp index 481e471c..c2b520c0 100644 --- a/src/desktop/rule/windowRule/WindowRule.cpp +++ b/src/desktop/rule/windowRule/WindowRule.cpp @@ -330,31 +330,16 @@ static std::expected parseWindowRuleEffect(C } } -CWindowRule::CWindowRule(const std::string& name) : IRule(name) { +CWindowRule::CWindowRule(const std::string& name) : CRuleWithEffects(name) { ; } -eRuleType CWindowRule::type() { - return RULE_TYPE_WINDOW; -} - -std::expected CWindowRule::addEffect(CWindowRule::storageType e, const std::string& result) { - auto parsed = parseWindowRuleEffect(e, result); - if (!parsed) - return std::unexpected(parsed.error()); - - m_effects.emplace_back(SWindowRuleEffect{.key = e, .raw = result, .value = std::move(*parsed)}); - m_effectSet.emplace(e); - - return {}; -} - -const std::vector& CWindowRule::effects() { - return m_effects; +std::expected CWindowRule::parseEffect(CWindowRule::storageType e, const std::string& result) { + return parseWindowRuleEffect(e, result); } bool CWindowRule::matches(PHLWINDOW w, bool allowEnvLookup) { - if (m_matchEngines.empty() || !m_enabled) + if (!canMatch()) return false; for (const auto& [prop, engine] : m_matchEngines) { @@ -491,15 +476,3 @@ std::expected, std::string> CWindowRule::buildFromExecString(std return wr; } - -const std::unordered_set& CWindowRule::effectsSet() { - return m_effectSet; -} - -void CWindowRule::setEnabled(bool enable) { - m_enabled = enable; -} - -bool CWindowRule::isEnabled() const { - return m_enabled; -} -- cgit v1.2.3