Support silent for maxClients

```
workspace=special:file_manager,maxclients:1 silent
workspace=1,maxclients:1 silent
```
This commit is contained in:
Lampros Pitsillos 2023-09-07 01:19:33 +03:00
parent 038c0c693b
commit b41da550e9
3 changed files with 19 additions and 8 deletions

View file

@ -1158,8 +1158,16 @@ void CConfigManager::handleWorkspaceRules(const std::string& command, const std:
wsRule.monitor = rule.substr(delim + 8); wsRule.monitor = rule.substr(delim + 8);
else if ((delim = rule.find("default:")) != std::string::npos) else if ((delim = rule.find("default:")) != std::string::npos)
wsRule.isDefault = configStringToInt(rule.substr(delim + 8)); 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)); wsRule.maxClients = configStringToInt(rule.substr(delim + 11));
}
}
}; };
size_t pos = 0; size_t pos = 0;

View file

@ -43,6 +43,7 @@ struct SWorkspaceRule {
int workspaceId = -1; int workspaceId = -1;
bool isDefault = false; bool isDefault = false;
int maxClients = 0; int maxClients = 0;
bool maxClientsSilent = false;
std::optional<int64_t> gapsIn; std::optional<int64_t> gapsIn;
std::optional<int64_t> gapsOut; std::optional<int64_t> gapsOut;
std::optional<int64_t> borderSize; std::optional<int64_t> borderSize;

View file

@ -581,6 +581,7 @@ void Events::listener_mapWindow(void* owner, void* data) {
if (maxClients != 0 && maxClients < g_pCompositor->getVisibleWindowsOnWorkspace(pWorkspace->m_iID)) { if (maxClients != 0 && maxClients < g_pCompositor->getVisibleWindowsOnWorkspace(pWorkspace->m_iID)) {
if (pWorkspace->m_bIsSpecialWorkspace) { if (pWorkspace->m_bIsSpecialWorkspace) {
g_pCompositor->moveWindowToWorkspaceSafe(PWINDOW, g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace)); g_pCompositor->moveWindowToWorkspaceSafe(PWINDOW, g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace));
if (!workspaceRule.maxClientsSilent)
PMONITOR->setSpecialWorkspace(nullptr); PMONITOR->setSpecialWorkspace(nullptr);
} }
@ -593,6 +594,7 @@ void Events::listener_mapWindow(void* owner, void* data) {
// doesn't exist since it's empty // doesn't exist since it's empty
pWorkspace = g_pCompositor->createNewWorkspace(REQUESTEDWORKSPACEID, PWINDOW->m_iMonitorID, requestedWorkspaceName); pWorkspace = g_pCompositor->createNewWorkspace(REQUESTEDWORKSPACEID, PWINDOW->m_iMonitorID, requestedWorkspaceName);
g_pCompositor->moveWindowToWorkspaceSafe(PWINDOW, pWorkspace); g_pCompositor->moveWindowToWorkspaceSafe(PWINDOW, pWorkspace);
if (!workspaceRule.maxClientsSilent)
g_pKeybindManager->m_mDispatchers["workspace"](pWorkspace->m_szName); g_pKeybindManager->m_mDispatchers["workspace"](pWorkspace->m_szName);
} }
} }