mirror of
https://github.com/hyprwm/Hyprland
synced 2024-12-23 13:09:50 +01:00
windowrules: add initialTitle and initialClass (#4259)
This commit is contained in:
parent
9fb50252d3
commit
191fa587f4
2 changed files with 45 additions and 10 deletions
|
@ -151,6 +151,8 @@ struct SWindowRule {
|
||||||
bool v2 = false;
|
bool v2 = false;
|
||||||
std::string szTitle;
|
std::string szTitle;
|
||||||
std::string szClass;
|
std::string szClass;
|
||||||
|
std::string szInitialTitle;
|
||||||
|
std::string szInitialClass;
|
||||||
int bX11 = -1; // -1 means "ANY"
|
int bX11 = -1; // -1 means "ANY"
|
||||||
int bFloating = -1;
|
int bFloating = -1;
|
||||||
int bFullscreen = -1;
|
int bFullscreen = -1;
|
||||||
|
|
|
@ -1030,6 +1030,8 @@ void CConfigManager::handleWindowRuleV2(const std::string& command, const std::s
|
||||||
|
|
||||||
const auto TITLEPOS = VALUE.find("title:");
|
const auto TITLEPOS = VALUE.find("title:");
|
||||||
const auto CLASSPOS = VALUE.find("class:");
|
const auto CLASSPOS = VALUE.find("class:");
|
||||||
|
const auto INITIALTITLEPOS = VALUE.find("initialTitle:");
|
||||||
|
const auto INITIALCLASSPOS = VALUE.find("initialClass:");
|
||||||
const auto X11POS = VALUE.find("xwayland:");
|
const auto X11POS = VALUE.find("xwayland:");
|
||||||
const auto FLOATPOS = VALUE.find("floating:");
|
const auto FLOATPOS = VALUE.find("floating:");
|
||||||
const auto FULLSCREENPOS = VALUE.find("fullscreen:");
|
const auto FULLSCREENPOS = VALUE.find("fullscreen:");
|
||||||
|
@ -1048,8 +1050,9 @@ void CConfigManager::handleWindowRuleV2(const std::string& command, const std::s
|
||||||
currentPos = VALUE.find("workspace:", currentPos + 1);
|
currentPos = VALUE.find("workspace:", currentPos + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TITLEPOS == std::string::npos && CLASSPOS == std::string::npos && X11POS == std::string::npos && FLOATPOS == std::string::npos && FULLSCREENPOS == std::string::npos &&
|
if (TITLEPOS == std::string::npos && CLASSPOS == std::string::npos && INITIALTITLEPOS == std::string::npos && INITIALCLASSPOS == std::string::npos &&
|
||||||
PINNEDPOS == std::string::npos && WORKSPACEPOS == std::string::npos && FOCUSPOS == std::string::npos && ONWORKSPACEPOS == std::string::npos) {
|
X11POS == std::string::npos && FLOATPOS == std::string::npos && FULLSCREENPOS == std::string::npos && PINNEDPOS == std::string::npos && WORKSPACEPOS == std::string::npos &&
|
||||||
|
FOCUSPOS == std::string::npos && ONWORKSPACEPOS == std::string::npos) {
|
||||||
Debug::log(ERR, "Invalid rulev2 syntax: {}", VALUE);
|
Debug::log(ERR, "Invalid rulev2 syntax: {}", VALUE);
|
||||||
parseError = "Invalid rulev2 syntax: " + VALUE;
|
parseError = "Invalid rulev2 syntax: " + VALUE;
|
||||||
return;
|
return;
|
||||||
|
@ -1064,6 +1067,10 @@ void CConfigManager::handleWindowRuleV2(const std::string& command, const std::s
|
||||||
min = TITLEPOS;
|
min = TITLEPOS;
|
||||||
if (CLASSPOS > pos && CLASSPOS < min)
|
if (CLASSPOS > pos && CLASSPOS < min)
|
||||||
min = CLASSPOS;
|
min = CLASSPOS;
|
||||||
|
if (INITIALTITLEPOS > pos && INITIALTITLEPOS < min)
|
||||||
|
min = INITIALTITLEPOS;
|
||||||
|
if (INITIALCLASSPOS > pos && INITIALCLASSPOS < min)
|
||||||
|
min = INITIALCLASSPOS;
|
||||||
if (X11POS > pos && X11POS < min)
|
if (X11POS > pos && X11POS < min)
|
||||||
min = X11POS;
|
min = X11POS;
|
||||||
if (FLOATPOS > pos && FLOATPOS < min)
|
if (FLOATPOS > pos && FLOATPOS < min)
|
||||||
|
@ -1095,6 +1102,12 @@ void CConfigManager::handleWindowRuleV2(const std::string& command, const std::s
|
||||||
if (TITLEPOS != std::string::npos)
|
if (TITLEPOS != std::string::npos)
|
||||||
rule.szTitle = extract(TITLEPOS + 6);
|
rule.szTitle = extract(TITLEPOS + 6);
|
||||||
|
|
||||||
|
if (INITIALCLASSPOS != std::string::npos)
|
||||||
|
rule.szInitialClass = extract(INITIALCLASSPOS + 13);
|
||||||
|
|
||||||
|
if (INITIALTITLEPOS != std::string::npos)
|
||||||
|
rule.szInitialTitle = extract(INITIALTITLEPOS + 13);
|
||||||
|
|
||||||
if (X11POS != std::string::npos)
|
if (X11POS != std::string::npos)
|
||||||
rule.bX11 = extract(X11POS + 9) == "1" ? 1 : 0;
|
rule.bX11 = extract(X11POS + 9) == "1" ? 1 : 0;
|
||||||
|
|
||||||
|
@ -1127,6 +1140,12 @@ void CConfigManager::handleWindowRuleV2(const std::string& command, const std::s
|
||||||
if (!rule.szTitle.empty() && rule.szTitle != other.szTitle)
|
if (!rule.szTitle.empty() && rule.szTitle != other.szTitle)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (!rule.szInitialClass.empty() && rule.szInitialClass != other.szInitialClass)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!rule.szInitialTitle.empty() && rule.szInitialTitle != other.szInitialTitle)
|
||||||
|
return false;
|
||||||
|
|
||||||
if (rule.bX11 != -1 && rule.bX11 != other.bX11)
|
if (rule.bX11 != -1 && rule.bX11 != other.bX11)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -2008,6 +2027,20 @@ std::vector<SWindowRule> CConfigManager::getMatchingRules(CWindow* pWindow) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (rule.szInitialTitle != "") {
|
||||||
|
std::regex RULECHECK(rule.szInitialTitle);
|
||||||
|
|
||||||
|
if (!std::regex_search(pWindow->m_szInitialTitle, RULECHECK))
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rule.szInitialClass != "") {
|
||||||
|
std::regex RULECHECK(rule.szInitialClass);
|
||||||
|
|
||||||
|
if (!std::regex_search(pWindow->m_szInitialClass, RULECHECK))
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (rule.bX11 != -1) {
|
if (rule.bX11 != -1) {
|
||||||
if (pWindow->m_bIsX11 != rule.bX11)
|
if (pWindow->m_bIsX11 != rule.bX11)
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in a new issue