From 606cb2832aff2c7305da1f880ce732f7eb464d04 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 16 Mar 2023 16:39:40 +0000 Subject: [PATCH] keybinds: remember last workspace on focusmonitor --- src/managers/KeybindManager.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 3b0a66783..d6cffd415 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -1394,7 +1394,18 @@ void CKeybindManager::focusMonitor(std::string arg) { if (!PMONITOR || PMONITOR == g_pCompositor->m_pLastMonitor) return; + const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(g_pCompositor->m_pLastMonitor->activeWorkspace); + changeworkspace("[internal]" + std::to_string(PMONITOR->activeWorkspace)); + + // remember last workspace (internal calls don't preserve it) + + const auto PNEWWORKSPACE = g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace); + if (PNEWWORKSPACE == PWORKSPACE) + return; + + PNEWWORKSPACE->m_sPrevWorkspace.iID = PWORKSPACE->m_iID; + PNEWWORKSPACE->m_sPrevWorkspace.name = PWORKSPACE->m_szName; } void CKeybindManager::moveCursorToCorner(std::string arg) {