diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 735d9703..025be9f7 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -1434,6 +1434,7 @@ std::vector> CConfigManager::getMatchingRules(PHLWINDOW pWindow, // since some rules will be applied later, we need to store some flags bool hasFloating = pWindow->m_isFloating; bool hasFullscreen = pWindow->isFullscreen(); + bool isGrouped = pWindow->m_groupData.pNextWindow; // local tags for dynamic tag rule match auto tags = pWindow->m_tags; @@ -1482,6 +1483,11 @@ std::vector> CConfigManager::getMatchingRules(PHLWINDOW pWindow, continue; } + if (rule->m_group != -1) { + if (rule->m_group != isGrouped) + continue; + } + if (!rule->m_fullscreenState.empty()) { const auto ARGS = CVarList(rule->m_fullscreenState, 2, ' '); // @@ -2576,6 +2582,7 @@ std::optional CConfigManager::handleWindowRule(const std::string& c const auto ONWORKSPACEPOS = VALUE.find("onworkspace:"); const auto CONTENTTYPEPOS = VALUE.find("content:"); const auto XDGTAGPOS = VALUE.find("xdgTag:"); + const auto GROUPPOS = VALUE.find("group:"); // find workspacepos that isn't onworkspacepos size_t WORKSPACEPOS = std::string::npos; @@ -2588,8 +2595,8 @@ std::optional CConfigManager::handleWindowRule(const std::string& c currentPos = VALUE.find("workspace:", currentPos + 1); } - const auto checkPos = std::unordered_set{TAGPOS, TITLEPOS, CLASSPOS, INITIALTITLEPOS, INITIALCLASSPOS, X11POS, FLOATPOS, FULLSCREENPOS, - PINNEDPOS, FULLSCREENSTATEPOS, WORKSPACEPOS, FOCUSPOS, ONWORKSPACEPOS, CONTENTTYPEPOS, XDGTAGPOS}; + const auto checkPos = std::unordered_set{TAGPOS, TITLEPOS, CLASSPOS, INITIALTITLEPOS, INITIALCLASSPOS, X11POS, FLOATPOS, FULLSCREENPOS, + PINNEDPOS, FULLSCREENSTATEPOS, WORKSPACEPOS, FOCUSPOS, ONWORKSPACEPOS, CONTENTTYPEPOS, XDGTAGPOS, GROUPPOS}; if (checkPos.size() == 1 && checkPos.contains(std::string::npos)) { Debug::log(ERR, "Invalid rulev2 syntax: {}", VALUE); return "Invalid rulev2 syntax: " + VALUE; @@ -2630,6 +2637,8 @@ std::optional CConfigManager::handleWindowRule(const std::string& c min = CONTENTTYPEPOS; if (XDGTAGPOS > pos && XDGTAGPOS < min) min = XDGTAGPOS; + if (GROUPPOS > pos && GROUPPOS < min) + min = GROUPPOS; result = result.substr(0, min - pos); @@ -2694,6 +2703,9 @@ std::optional CConfigManager::handleWindowRule(const std::string& c if (XDGTAGPOS != std::string::npos) rule->m_xdgTag = extract(XDGTAGPOS + 8); + if (GROUPPOS != std::string::npos) + rule->m_group = extract(GROUPPOS + 6) == "1" ? 1 : 0; + if (RULE == "unset") { std::erase_if(m_windowRules, [&](const auto& other) { if (!other->m_v2) @@ -2741,6 +2753,9 @@ std::optional CConfigManager::handleWindowRule(const std::string& c if (!rule->m_contentType.empty() && rule->m_contentType != other->m_contentType) return false; + if (rule->m_group != -1 && rule->m_group != other->m_group) + return false; + return true; } }); diff --git a/src/desktop/WindowRule.hpp b/src/desktop/WindowRule.hpp index 9af3909a..b828c8ee 100644 --- a/src/desktop/WindowRule.hpp +++ b/src/desktop/WindowRule.hpp @@ -58,6 +58,7 @@ class CWindowRule { int m_fullscreen = -1; int m_pinned = -1; int m_focus = -1; + int m_group = -1; std::string m_fullscreenState = ""; // empty means any std::string m_onWorkspace = ""; // empty means any std::string m_workspace = ""; // empty means any @@ -70,4 +71,4 @@ class CWindowRule { CRuleRegexContainer m_initialTitleRegex; CRuleRegexContainer m_initialClassRegex; CRuleRegexContainer m_v1Regex; -}; \ No newline at end of file +};