mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-07-25 17:21:54 -07:00
config: add group: selector (#10588)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
});
|
||||
|
@@ -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;
|
||||
};
|
||||
};
|
||||
|
Reference in New Issue
Block a user