From b41da550e99e3df5c4defebf05ddf5dfa510bbec Mon Sep 17 00:00:00 2001 From: Lampros Pitsillos Date: Thu, 7 Sep 2023 01:19:33 +0300 Subject: [PATCH] Support silent for maxClients ``` workspace=special:file_manager,maxclients:1 silent workspace=1,maxclients:1 silent ``` --- src/config/ConfigManager.cpp | 10 +++++++++- src/config/ConfigManager.hpp | 13 +++++++------ src/events/Windows.cpp | 4 +++- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 20a70b84..2678da4c 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -1158,8 +1158,16 @@ void CConfigManager::handleWorkspaceRules(const std::string& command, const std: wsRule.monitor = rule.substr(delim + 8); else if ((delim = rule.find("default:")) != std::string::npos) wsRule.isDefault = configStringToInt(rule.substr(delim + 8)); - else if ((delim = rule.find("maxclients:")) != std::string::npos) + else if ((delim = rule.find("maxclients:")) != std::string::npos){ + size_t silent = rule.find("silent"); + if (silent != std::string::npos) { + wsRule.maxClientsSilent = true; + wsRule.maxClients = configStringToInt(rule.substr(delim + 11, silent)); + } else { wsRule.maxClients = configStringToInt(rule.substr(delim + 11)); + } + } + }; size_t pos = 0; diff --git a/src/config/ConfigManager.hpp b/src/config/ConfigManager.hpp index 4c1c860a..a21fe23a 100644 --- a/src/config/ConfigManager.hpp +++ b/src/config/ConfigManager.hpp @@ -37,12 +37,13 @@ struct SConfigValue { }; struct SWorkspaceRule { - std::string monitor = ""; - std::string workspaceString = ""; - std::string workspaceName = ""; - int workspaceId = -1; - bool isDefault = false; - int maxClients = 0; + std::string monitor = ""; + std::string workspaceString = ""; + std::string workspaceName = ""; + int workspaceId = -1; + bool isDefault = false; + int maxClients = 0; + bool maxClientsSilent = false; std::optional gapsIn; std::optional gapsOut; std::optional borderSize; diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index be7d0fbe..df393374 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -581,7 +581,8 @@ void Events::listener_mapWindow(void* owner, void* data) { if (maxClients != 0 && maxClients < g_pCompositor->getVisibleWindowsOnWorkspace(pWorkspace->m_iID)) { if (pWorkspace->m_bIsSpecialWorkspace) { g_pCompositor->moveWindowToWorkspaceSafe(PWINDOW, g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace)); - PMONITOR->setSpecialWorkspace(nullptr); + if (!workspaceRule.maxClientsSilent) + PMONITOR->setSpecialWorkspace(nullptr); } pWorkspace = g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace); @@ -593,6 +594,7 @@ void Events::listener_mapWindow(void* owner, void* data) { // doesn't exist since it's empty pWorkspace = g_pCompositor->createNewWorkspace(REQUESTEDWORKSPACEID, PWINDOW->m_iMonitorID, requestedWorkspaceName); g_pCompositor->moveWindowToWorkspaceSafe(PWINDOW, pWorkspace); + if (!workspaceRule.maxClientsSilent) g_pKeybindManager->m_mDispatchers["workspace"](pWorkspace->m_szName); } }