From 088b4a68e6288e7bbeb7fb9a31798d47e4d13a78 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Mon, 22 May 2023 19:44:10 +0200 Subject: [PATCH] moveActiveToWorkspace: update last window of old ws --- src/managers/KeybindManager.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 7b5a102c..8dad6700 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -879,22 +879,26 @@ void CKeybindManager::moveActiveToWorkspace(std::string args) { return; } - auto pWorkspace = g_pCompositor->getWorkspaceByID(WORKSPACEID); + auto pWorkspace = g_pCompositor->getWorkspaceByID(WORKSPACEID); + CMonitor* pMonitor = nullptr; + const auto POLDWS = g_pCompositor->getWorkspaceByID(PWINDOW->m_iWorkspaceID); g_pHyprRenderer->damageWindow(PWINDOW); if (pWorkspace) { g_pCompositor->moveWindowToWorkspaceSafe(PWINDOW, pWorkspace); - const auto PMONITOR = g_pCompositor->getMonitorFromID(pWorkspace->m_iMonitorID); - g_pCompositor->setActiveMonitor(PMONITOR); - PMONITOR->changeWorkspace(pWorkspace); + pMonitor = g_pCompositor->getMonitorFromID(pWorkspace->m_iMonitorID); + g_pCompositor->setActiveMonitor(pMonitor); } else { - pWorkspace = g_pCompositor->createNewWorkspace(WORKSPACEID, PWINDOW->m_iMonitorID, workspaceName); - const auto PMONITOR = g_pCompositor->getMonitorFromID(pWorkspace->m_iMonitorID); + pWorkspace = g_pCompositor->createNewWorkspace(WORKSPACEID, PWINDOW->m_iMonitorID, workspaceName); + pMonitor = g_pCompositor->getMonitorFromID(pWorkspace->m_iMonitorID); g_pCompositor->moveWindowToWorkspaceSafe(PWINDOW, pWorkspace); - PMONITOR->changeWorkspace(pWorkspace); } + POLDWS->m_pLastFocusedWindow = g_pCompositor->getFirstWindowOnWorkspace(POLDWS->m_iID); + + pMonitor->changeWorkspace(pWorkspace); + g_pCompositor->focusWindow(PWINDOW); g_pCompositor->warpCursorTo(PWINDOW->middle()); }