From 44a2d755c68f8e6990ea885a45ea370be8b3a392 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Wed, 7 Sep 2022 11:24:40 +0200 Subject: [PATCH] Added Xwayland and floating props to windowrulev2 --- src/config/ConfigManager.cpp | 25 ++++++++++++++++++++++++- src/config/ConfigManager.hpp | 2 ++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 5e03e275..1f6b3829 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -777,11 +777,14 @@ void CConfigManager::handleWindowRuleV2(const std::string& command, const std::s SWindowRule rule; rule.v2 = true; rule.szRule = RULE; + rule.szValue = VALUE; const auto TITLEPOS = VALUE.find("title:"); const auto CLASSPOS = VALUE.find("class:"); + const auto X11POS = VALUE.find("xwayland:"); + const auto FLOATPOS = VALUE.find("floating:"); - if (TITLEPOS == std::string::npos && CLASSPOS == std::string::npos) { + if (TITLEPOS == std::string::npos && CLASSPOS == std::string::npos && X11POS == std::string::npos && FLOATPOS == std::string::npos) { Debug::log(ERR, "Invalid rulev2 syntax: %s", VALUE.c_str()); parseError = "Invalid rulev2 syntax: " + VALUE; return; @@ -794,6 +797,8 @@ void CConfigManager::handleWindowRuleV2(const std::string& command, const std::s size_t min = 999999; if (TITLEPOS > pos && TITLEPOS < min) min = TITLEPOS; if (CLASSPOS > pos && CLASSPOS < min) min = CLASSPOS; + if (X11POS > pos && X11POS < min) min = X11POS; + if (FLOATPOS > pos && FLOATPOS < min) min = FLOATPOS; result = result.substr(0, min - pos); @@ -811,6 +816,14 @@ void CConfigManager::handleWindowRuleV2(const std::string& command, const std::s rule.szTitle = extract(TITLEPOS + 6); } + if (X11POS != std::string::npos) { + rule.bX11 = extract(X11POS + 9) == "1" ? 1 : 0; + } + + if (FLOATPOS != std::string::npos) { + rule.bFloating = extract(FLOATPOS + 9) == "1" ? 1 : 0; + } + m_dWindowRules.push_back(rule); } @@ -1370,6 +1383,16 @@ std::vector CConfigManager::getMatchingRules(CWindow* pWindow) { if (!std::regex_search(title, RULECHECK)) continue; } + + if (rule.bX11 != -1) { + if (pWindow->m_bIsX11 != rule.bX11) + continue; + } + + if (rule.bFloating != -1) { + if (pWindow->m_bIsFloating != rule.bFloating) + continue; + } } catch (...) { Debug::log(ERR, "Regex error at %s", rule.szValue.c_str()); continue; diff --git a/src/config/ConfigManager.hpp b/src/config/ConfigManager.hpp index 0077548c..c719c317 100644 --- a/src/config/ConfigManager.hpp +++ b/src/config/ConfigManager.hpp @@ -52,6 +52,8 @@ struct SWindowRule { bool v2 = false; std::string szTitle; std::string szClass; + int bX11 = -1; // -1 means "ANY" + int bFloating = -1; }; struct SAnimationPropertyConfig {