From 004bf94a23223265c96e348a84d1d044a009c566 Mon Sep 17 00:00:00 2001 From: dranull <150595692+dranull@users.noreply.github.com> Date: Thu, 7 Dec 2023 22:12:08 +0000 Subject: [PATCH] keybinds: Keep focus on special when switching workspaces (#4084) --- src/helpers/Monitor.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp index c1ae3503..c112d07d 100644 --- a/src/helpers/Monitor.cpp +++ b/src/helpers/Monitor.cpp @@ -533,24 +533,24 @@ void CMonitor::changeWorkspace(CWorkspace* const pWorkspace, bool internal, bool } } - static auto* const PFOLLOWMOUSE = &g_pConfigManager->getConfigValuePtr("input:follow_mouse")->intValue; + if (!g_pCompositor->m_pLastMonitor->specialWorkspaceID) { + static auto* const PFOLLOWMOUSE = &g_pConfigManager->getConfigValuePtr("input:follow_mouse")->intValue; + CWindow* pWindow = pWorkspace->getLastFocusedWindow(); - if (const auto PLASTWINDOW = pWorkspace->getLastFocusedWindow(); PLASTWINDOW) - g_pCompositor->focusWindow(PLASTWINDOW); - else { - CWindow* pWindow = nullptr; + if (!pWindow) { + if (*PFOLLOWMOUSE == 1) + pWindow = g_pCompositor->vectorToWindowIdeal(g_pInputManager->getMouseCoordsInternal()); - if (*PFOLLOWMOUSE == 1) - pWindow = g_pCompositor->vectorToWindowIdeal(g_pInputManager->getMouseCoordsInternal()); + if (!pWindow) + pWindow = g_pCompositor->getTopLeftWindowOnWorkspace(pWorkspace->m_iID); - if (!pWindow) - pWindow = g_pCompositor->getTopLeftWindowOnWorkspace(pWorkspace->m_iID); - - if (!pWindow) - pWindow = g_pCompositor->getFirstWindowOnWorkspace(pWorkspace->m_iID); + if (!pWindow) + pWindow = g_pCompositor->getFirstWindowOnWorkspace(pWorkspace->m_iID); + } g_pCompositor->focusWindow(pWindow); } + if (!noMouseMove) g_pInputManager->simulateMouseMovement();