mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-08-10 17:51:53 -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
|
// since some rules will be applied later, we need to store some flags
|
||||||
bool hasFloating = pWindow->m_isFloating;
|
bool hasFloating = pWindow->m_isFloating;
|
||||||
bool hasFullscreen = pWindow->isFullscreen();
|
bool hasFullscreen = pWindow->isFullscreen();
|
||||||
|
bool isGrouped = pWindow->m_groupData.pNextWindow;
|
||||||
|
|
||||||
// local tags for dynamic tag rule match
|
// local tags for dynamic tag rule match
|
||||||
auto tags = pWindow->m_tags;
|
auto tags = pWindow->m_tags;
|
||||||
@@ -1482,6 +1483,11 @@ std::vector<SP<CWindowRule>> CConfigManager::getMatchingRules(PHLWINDOW pWindow,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (rule->m_group != -1) {
|
||||||
|
if (rule->m_group != isGrouped)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!rule->m_fullscreenState.empty()) {
|
if (!rule->m_fullscreenState.empty()) {
|
||||||
const auto ARGS = CVarList(rule->m_fullscreenState, 2, ' ');
|
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 ONWORKSPACEPOS = VALUE.find("onworkspace:");
|
||||||
const auto CONTENTTYPEPOS = VALUE.find("content:");
|
const auto CONTENTTYPEPOS = VALUE.find("content:");
|
||||||
const auto XDGTAGPOS = VALUE.find("xdgTag:");
|
const auto XDGTAGPOS = VALUE.find("xdgTag:");
|
||||||
|
const auto GROUPPOS = VALUE.find("group:");
|
||||||
|
|
||||||
// find workspacepos that isn't onworkspacepos
|
// find workspacepos that isn't onworkspacepos
|
||||||
size_t WORKSPACEPOS = std::string::npos;
|
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);
|
currentPos = VALUE.find("workspace:", currentPos + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto checkPos = std::unordered_set{TAGPOS, TITLEPOS, CLASSPOS, INITIALTITLEPOS, INITIALCLASSPOS, X11POS, FLOATPOS, FULLSCREENPOS,
|
const auto checkPos = std::unordered_set{TAGPOS, TITLEPOS, CLASSPOS, INITIALTITLEPOS, INITIALCLASSPOS, X11POS, FLOATPOS, FULLSCREENPOS,
|
||||||
PINNEDPOS, FULLSCREENSTATEPOS, WORKSPACEPOS, FOCUSPOS, ONWORKSPACEPOS, CONTENTTYPEPOS, XDGTAGPOS};
|
PINNEDPOS, FULLSCREENSTATEPOS, WORKSPACEPOS, FOCUSPOS, ONWORKSPACEPOS, CONTENTTYPEPOS, XDGTAGPOS, GROUPPOS};
|
||||||
if (checkPos.size() == 1 && checkPos.contains(std::string::npos)) {
|
if (checkPos.size() == 1 && checkPos.contains(std::string::npos)) {
|
||||||
Debug::log(ERR, "Invalid rulev2 syntax: {}", VALUE);
|
Debug::log(ERR, "Invalid rulev2 syntax: {}", VALUE);
|
||||||
return "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;
|
min = CONTENTTYPEPOS;
|
||||||
if (XDGTAGPOS > pos && XDGTAGPOS < min)
|
if (XDGTAGPOS > pos && XDGTAGPOS < min)
|
||||||
min = XDGTAGPOS;
|
min = XDGTAGPOS;
|
||||||
|
if (GROUPPOS > pos && GROUPPOS < min)
|
||||||
|
min = GROUPPOS;
|
||||||
|
|
||||||
result = result.substr(0, min - pos);
|
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)
|
if (XDGTAGPOS != std::string::npos)
|
||||||
rule->m_xdgTag = extract(XDGTAGPOS + 8);
|
rule->m_xdgTag = extract(XDGTAGPOS + 8);
|
||||||
|
|
||||||
|
if (GROUPPOS != std::string::npos)
|
||||||
|
rule->m_group = extract(GROUPPOS + 6) == "1" ? 1 : 0;
|
||||||
|
|
||||||
if (RULE == "unset") {
|
if (RULE == "unset") {
|
||||||
std::erase_if(m_windowRules, [&](const auto& other) {
|
std::erase_if(m_windowRules, [&](const auto& other) {
|
||||||
if (!other->m_v2)
|
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)
|
if (!rule->m_contentType.empty() && rule->m_contentType != other->m_contentType)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (rule->m_group != -1 && rule->m_group != other->m_group)
|
||||||
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@@ -58,6 +58,7 @@ class CWindowRule {
|
|||||||
int m_fullscreen = -1;
|
int m_fullscreen = -1;
|
||||||
int m_pinned = -1;
|
int m_pinned = -1;
|
||||||
int m_focus = -1;
|
int m_focus = -1;
|
||||||
|
int m_group = -1;
|
||||||
std::string m_fullscreenState = ""; // empty means any
|
std::string m_fullscreenState = ""; // empty means any
|
||||||
std::string m_onWorkspace = ""; // empty means any
|
std::string m_onWorkspace = ""; // empty means any
|
||||||
std::string m_workspace = ""; // empty means any
|
std::string m_workspace = ""; // empty means any
|
||||||
|
Reference in New Issue
Block a user