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);
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;

View file

@ -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<int64_t> gapsIn;
std::optional<int64_t> gapsOut;
std::optional<int64_t> borderSize;

View file

@ -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);
}
}