summaryrefslogtreecommitdiff
path: root/src/config/ConfigManager.cpp
diff options
context:
space:
mode:
authorEric Li <eric.r.li@gmail.com>2025-06-05 16:17:04 -0400
committerGitHub <noreply@github.com>2025-06-05 21:17:04 +0100
commit423b69f5d3c76762e05c1511a10942714dea4e8e (patch)
treeab0c76e0e5a0de62409b1e422f8aa3ba48150872 /src/config/ConfigManager.cpp
parentabdfc5ea40c0793117f34bf6c465840500cf7cb0 (diff)
config: add group: selector (#10588)
Diffstat (limited to 'src/config/ConfigManager.cpp')
-rw-r--r--src/config/ConfigManager.cpp19
1 files changed, 17 insertions, 2 deletions
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<SP<CWindowRule>> 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<SP<CWindowRule>> 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<std::string> 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<std::string> 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<std::string> 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<std::string> 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<std::string> 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;
}
});