From 5d39223239d86479ffd9639661c92006f8ba6489 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 17 Nov 2022 21:58:22 +0000 Subject: [PATCH] fix events in changeworkspace with bound ws-es --- src/managers/KeybindManager.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index b27087ba..1b8a010f 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -755,7 +755,7 @@ void CKeybindManager::changeworkspace(std::string args) { } // If the monitor is not the one our cursor's at, warp to it. - const bool anotherMonitor = PMONITOR != g_pCompositor->getMonitorFromCursor(); + const bool anotherMonitor = PMONITOR != g_pCompositor->m_pLastMonitor; if (anotherMonitor) { Vector2D middle = PMONITOR->vecPosition + PMONITOR->vecSize / 2.f; g_pCompositor->warpCursorTo(middle); @@ -812,6 +812,8 @@ void CKeybindManager::changeworkspace(std::string args) { const auto PWORKSPACE = g_pCompositor->createNewWorkspace(workspaceToChangeTo, PMONITOR->ID, workspaceName); + const bool ANOTHERMONITOR = PMONITOR == g_pCompositor->m_pLastMonitor; + if (!isSwitchingToPrevious) // Remember previous workspace. PWORKSPACE->m_iPrevWorkspaceID = OLDWORKSPACE; @@ -849,8 +851,16 @@ void CKeybindManager::changeworkspace(std::string args) { // focus (clears the last) g_pInputManager->refocus(); - // Event + // Events g_pEventManager->postEvent(SHyprIPCEvent{"workspace", PWORKSPACE->m_szName}); + if (ANOTHERMONITOR) { + Vector2D middle = PMONITOR->vecPosition + PMONITOR->vecSize / 2.f; + g_pCompositor->warpCursorTo(middle); + + // event for focusedmon, as we changed. + g_pEventManager->postEvent(SHyprIPCEvent{"focusedmon", PMONITOR->szName + "," + PWORKSPACE->m_szName}); + g_pCompositor->m_pLastMonitor = PMONITOR; + } Debug::log(LOG, "Changed to workspace %i", workspaceToChangeTo); }