From a3d3a921e49de241a8891b5908b4911d50ac2ce9 Mon Sep 17 00:00:00 2001 From: Filipe Abreu <134308239+fliplus@users.noreply.github.com> Date: Sat, 30 Nov 2024 22:21:16 +0000 Subject: [PATCH] Add pseudo field for windowrulev2 --- src/config/ConfigManager.cpp | 21 +++++++++++++++++++-- src/desktop/Window.hpp | 1 + src/managers/KeybindManager.cpp | 2 ++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index c0f212cf706..25204727253 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -1236,6 +1236,7 @@ std::vector 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 @@ -1306,6 +1307,11 @@ std::vector CConfigManager::getMatchingRules(PHLWINDOW pWindow, boo continue; } + if (rule.bPseudo != -1) { + if (hasPseudo != rule.bPseudo) + continue; + } + if (rule.bFullscreen != -1) { if (hasFullscreen != rule.bFullscreen) continue; @@ -1396,6 +1402,8 @@ std::vector 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; } @@ -2394,6 +2402,7 @@ std::optional 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:"); @@ -2411,8 +2420,8 @@ std::optional 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; @@ -2437,6 +2446,8 @@ std::optional 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) @@ -2481,6 +2492,9 @@ std::optional 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; @@ -2525,6 +2539,9 @@ std::optional 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; diff --git a/src/desktop/Window.hpp b/src/desktop/Window.hpp index 5dd5943782e..b87d94d6f59 100644 --- a/src/desktop/Window.hpp +++ b/src/desktop/Window.hpp @@ -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; diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 7f10249abe2..86ea220a941 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -1094,6 +1094,8 @@ SDispatchResult CKeybindManager::toggleActivePseudo(std::string args) { if (!PWINDOW->isFullscreen()) g_pLayoutManager->getCurrentLayout()->recalculateWindow(PWINDOW); + PWINDOW->updateDynamicRules(); + return {}; }