diff options
| author | Vaxry <vaxry@vaxry.net> | 2026-04-28 15:55:41 +0100 |
|---|---|---|
| committer | Vaxry <43317083+vaxerski@users.noreply.github.com> | 2026-04-28 16:52:41 +0100 |
| commit | 97886cf0dab39ce4b7887e549b93ccec30156ddc (patch) | |
| tree | 14b9c3b575b0a2f38b009d8267ef929109b0d33b /src/desktop/rule/windowRule/WindowRule.cpp | |
| parent | 89e2380da8d432a84ab93345d82389010172adcf (diff) | |
desktop/rule: cleanup inheritance, use templates to avoid dup
Diffstat (limited to 'src/desktop/rule/windowRule/WindowRule.cpp')
| -rw-r--r-- | src/desktop/rule/windowRule/WindowRule.cpp | 35 |
1 files changed, 4 insertions, 31 deletions
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<WindowRuleEffectValue, std::string> parseWindowRuleEffect(C } } -CWindowRule::CWindowRule(const std::string& name) : IRule(name) { +CWindowRule::CWindowRule(const std::string& name) : CRuleWithEffects<SWindowRuleEffect, RULE_TYPE_WINDOW>(name) { ; } -eRuleType CWindowRule::type() { - return RULE_TYPE_WINDOW; -} - -std::expected<void, std::string> 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<SWindowRuleEffect>& CWindowRule::effects() { - return m_effects; +std::expected<WindowRuleEffectValue, std::string> 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<SP<CWindowRule>, std::string> CWindowRule::buildFromExecString(std return wr; } - -const std::unordered_set<CWindowRule::storageType>& CWindowRule::effectsSet() { - return m_effectSet; -} - -void CWindowRule::setEnabled(bool enable) { - m_enabled = enable; -} - -bool CWindowRule::isEnabled() const { - return m_enabled; -} |
