From ec4bea7901bdb1f36d33354c02e36d7e03b1ac1e Mon Sep 17 00:00:00 2001 From: Vaxry <vaxry@vaxry.net> Date: Tue, 18 Mar 2025 01:36:55 +0000 Subject: [PATCH] config: nuke windowrule v1 syntax --- src/config/ConfigManager.cpp | 97 ++++++++++++------------------------ src/config/ConfigManager.hpp | 1 - 2 files changed, 33 insertions(+), 65 deletions(-) diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 20f959de4..1c36876d0 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -293,7 +293,7 @@ static Hyprlang::CParseResult handleWindowRuleV2(const char* c, const char* v) { const std::string VALUE = v; const std::string COMMAND = c; - const auto RESULT = g_pConfigManager->handleWindowRuleV2(COMMAND, VALUE); + const auto RESULT = g_pConfigManager->handleWindowRule(COMMAND, VALUE); Hyprlang::CParseResult result; if (RESULT.has_value()) @@ -2347,69 +2347,6 @@ std::optional<std::string> CConfigManager::handleUnbind(const std::string& comma } std::optional<std::string> CConfigManager::handleWindowRule(const std::string& command, const std::string& value) { - const auto RULE = trim(value.substr(0, value.find_first_of(','))); - const auto VALUE = trim(value.substr(value.find_first_of(',') + 1)); - - // check rule and value - if (RULE.empty() || VALUE.empty()) - return "empty rule?"; - - if (RULE == "unset") { - std::erase_if(m_vWindowRules, [&](const auto& other) { return other->szValue == VALUE; }); - return {}; - } - - auto newRule = makeShared<CWindowRule>(RULE, VALUE, false); - - // verify we support a rule - if (newRule->ruleType == CWindowRule::RULE_INVALID) { - Debug::log(ERR, "Invalid rule found: {}", RULE); - return "Invalid rule: " + RULE; - } - - newRule->rV1Regex = {VALUE.starts_with("title:") ? VALUE.substr(6) : VALUE}; - - if (RULE.starts_with("size") || RULE.starts_with("maxsize") || RULE.starts_with("minsize")) - m_vWindowRules.insert(m_vWindowRules.begin(), newRule); - else - m_vWindowRules.emplace_back(newRule); - - return {}; -} - -std::optional<std::string> CConfigManager::handleLayerRule(const std::string& command, const std::string& value) { - const auto RULE = trim(value.substr(0, value.find_first_of(','))); - const auto VALUE = trim(value.substr(value.find_first_of(',') + 1)); - - // check rule and value - if (RULE.empty() || VALUE.empty()) - return "empty rule?"; - - if (RULE == "unset") { - std::erase_if(m_vLayerRules, [&](const auto& other) { return other->targetNamespace == VALUE; }); - return {}; - } - - auto rule = makeShared<CLayerRule>(RULE, VALUE); - - if (rule->ruleType == CLayerRule::RULE_INVALID) { - Debug::log(ERR, "Invalid rule found: {}", RULE); - return "Invalid rule found: " + RULE; - } - - rule->targetNamespaceRegex = {VALUE}; - - m_vLayerRules.emplace_back(rule); - - for (auto const& m : g_pCompositor->m_vMonitors) - for (auto const& lsl : m->m_aLayerSurfaceLayers) - for (auto const& ls : lsl) - ls->applyRules(); - - return {}; -} - -std::optional<std::string> CConfigManager::handleWindowRuleV2(const std::string& command, const std::string& value) { const auto RULE = trim(value.substr(0, value.find_first_of(','))); const auto VALUE = value.substr(value.find_first_of(',') + 1); @@ -2608,6 +2545,38 @@ std::optional<std::string> CConfigManager::handleWindowRuleV2(const std::string& return {}; } +std::optional<std::string> CConfigManager::handleLayerRule(const std::string& command, const std::string& value) { + const auto RULE = trim(value.substr(0, value.find_first_of(','))); + const auto VALUE = trim(value.substr(value.find_first_of(',') + 1)); + + // check rule and value + if (RULE.empty() || VALUE.empty()) + return "empty rule?"; + + if (RULE == "unset") { + std::erase_if(m_vLayerRules, [&](const auto& other) { return other->targetNamespace == VALUE; }); + return {}; + } + + auto rule = makeShared<CLayerRule>(RULE, VALUE); + + if (rule->ruleType == CLayerRule::RULE_INVALID) { + Debug::log(ERR, "Invalid rule found: {}", RULE); + return "Invalid rule found: " + RULE; + } + + rule->targetNamespaceRegex = {VALUE}; + + m_vLayerRules.emplace_back(rule); + + for (auto const& m : g_pCompositor->m_vMonitors) + for (auto const& lsl : m->m_aLayerSurfaceLayers) + for (auto const& ls : lsl) + ls->applyRules(); + + return {}; +} + void CConfigManager::updateBlurredLS(const std::string& name, const bool forceBlur) { const bool BYADDRESS = name.starts_with("address:"); std::string matchName = name; diff --git a/src/config/ConfigManager.hpp b/src/config/ConfigManager.hpp index 7ce378b1d..4da123c9e 100644 --- a/src/config/ConfigManager.hpp +++ b/src/config/ConfigManager.hpp @@ -235,7 +235,6 @@ class CConfigManager { std::optional<std::string> handleUnbind(const std::string&, const std::string&); std::optional<std::string> handleWindowRule(const std::string&, const std::string&); std::optional<std::string> handleLayerRule(const std::string&, const std::string&); - std::optional<std::string> handleWindowRuleV2(const std::string&, const std::string&); std::optional<std::string> handleWorkspaceRules(const std::string&, const std::string&); std::optional<std::string> handleBezier(const std::string&, const std::string&); std::optional<std::string> handleAnimation(const std::string&, const std::string&);