Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pseudo field for windowrulev2 #8623

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions src/config/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1236,6 +1236,7 @@ std::vector<SWindowRule> CConfigManager::getMatchingRules(PHLWINDOW pWindow, boo

// since some rules will be applied later, we need to store some flags
bool hasFloating = pWindow->m_bIsFloating;
bool hasPseudo = pWindow->m_bIsPseudotiled;
bool hasFullscreen = pWindow->isFullscreen();

// local tags for dynamic tag rule match
Expand Down Expand Up @@ -1306,6 +1307,11 @@ std::vector<SWindowRule> CConfigManager::getMatchingRules(PHLWINDOW pWindow, boo
continue;
}

if (rule.bPseudo != -1) {
if (hasPseudo != rule.bPseudo)
continue;
}

if (rule.bFullscreen != -1) {
if (hasFullscreen != rule.bFullscreen)
continue;
Expand Down Expand Up @@ -1396,6 +1402,8 @@ std::vector<SWindowRule> CConfigManager::getMatchingRules(PHLWINDOW pWindow, boo

if (rule.szRule == "float")
hasFloating = true;
else if (rule.szRule == "pseudo")
hasPseudo = true;
else if (rule.szRule == "fullscreen")
hasFullscreen = true;
}
Expand Down Expand Up @@ -2394,6 +2402,7 @@ std::optional<std::string> CConfigManager::handleWindowRuleV2(const std::string&
const auto INITIALCLASSPOS = VALUE.find("initialClass:");
const auto X11POS = VALUE.find("xwayland:");
const auto FLOATPOS = VALUE.find("floating:");
const auto PSEUDOPOS = VALUE.find("pseudo:");
const auto FULLSCREENPOS = VALUE.find("fullscreen:");
const auto PINNEDPOS = VALUE.find("pinned:");
const auto FOCUSPOS = VALUE.find("focus:");
Expand All @@ -2411,8 +2420,8 @@ std::optional<std::string> CConfigManager::handleWindowRuleV2(const std::string&
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};
const auto checkPos = std::unordered_set{TAGPOS, TITLEPOS, CLASSPOS, INITIALTITLEPOS, INITIALCLASSPOS, X11POS, FLOATPOS,
PSEUDOPOS, FULLSCREENPOS, PINNEDPOS, FULLSCREENSTATEPOS, WORKSPACEPOS, FOCUSPOS, ONWORKSPACEPOS};
if (checkPos.size() == 1 && checkPos.contains(std::string::npos)) {
Debug::log(ERR, "Invalid rulev2 syntax: {}", VALUE);
return "Invalid rulev2 syntax: " + VALUE;
Expand All @@ -2437,6 +2446,8 @@ std::optional<std::string> CConfigManager::handleWindowRuleV2(const std::string&
min = X11POS;
if (FLOATPOS > pos && FLOATPOS < min)
min = FLOATPOS;
if (PSEUDOPOS > pos && PSEUDOPOS < min)
min = PSEUDOPOS;
if (FULLSCREENPOS > pos && FULLSCREENPOS < min)
min = FULLSCREENPOS;
if (PINNEDPOS > pos && PINNEDPOS < min)
Expand Down Expand Up @@ -2481,6 +2492,9 @@ std::optional<std::string> CConfigManager::handleWindowRuleV2(const std::string&
if (FLOATPOS != std::string::npos)
rule.bFloating = extract(FLOATPOS + 9) == "1" ? 1 : 0;

if (PSEUDOPOS != std::string::npos)
rule.bPseudo = extract(PSEUDOPOS + 7) == "1" ? 1 : 0;

if (FULLSCREENPOS != std::string::npos)
rule.bFullscreen = extract(FULLSCREENPOS + 11) == "1" ? 1 : 0;

Expand Down Expand Up @@ -2525,6 +2539,9 @@ std::optional<std::string> CConfigManager::handleWindowRuleV2(const std::string&
if (rule.bFloating != -1 && rule.bFloating != other.bFloating)
return false;

if (rule.bPseudo != -1 && rule.bPseudo != other.bPseudo)
return false;

if (rule.bFullscreen != -1 && rule.bFullscreen != other.bFullscreen)
return false;

Expand Down
1 change: 1 addition & 0 deletions src/desktop/Window.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ struct SWindowRule {
std::string szTag;
int bX11 = -1; // -1 means "ANY"
int bFloating = -1;
int bPseudo = -1;
int bFullscreen = -1;
int bPinned = -1;
int bFocus = -1;
Expand Down
2 changes: 2 additions & 0 deletions src/managers/KeybindManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1094,6 +1094,8 @@ SDispatchResult CKeybindManager::toggleActivePseudo(std::string args) {
if (!PWINDOW->isFullscreen())
g_pLayoutManager->getCurrentLayout()->recalculateWindow(PWINDOW);

PWINDOW->updateDynamicRules();

return {};
}

Expand Down