Focus stays on old window

This commit is contained in:
Lampros Pitsillos 2023-09-07 01:47:09 +03:00
parent b41da550e9
commit bd86768c50

View file

@ -578,10 +578,11 @@ void Events::listener_mapWindow(void* owner, void* data) {
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID); const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
int maxClients = workspaceRule.maxClients; int maxClients = workspaceRule.maxClients;
bool silent = workspaceRule.maxClientsSilent;
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) if (!silent)
PMONITOR->setSpecialWorkspace(nullptr); PMONITOR->setSpecialWorkspace(nullptr);
} }
@ -594,9 +595,17 @@ 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) if (!silent)
g_pKeybindManager->m_mDispatchers["workspace"](pWorkspace->m_szName); g_pKeybindManager->m_mDispatchers["workspace"](pWorkspace->m_szName);
} }
if (silent) {
if (g_pCompositor->windowValidMapped(PFOCUSEDWINDOWPREV)) {
g_pCompositor->focusWindow(PFOCUSEDWINDOWPREV);
PFOCUSEDWINDOWPREV->updateWindowDecos();
} else if (!PFOCUSEDWINDOWPREV)
g_pCompositor->focusWindow(nullptr);
}
} }
} }