From 727160f0a4ef08dbcd543f1ffca64c6de30c9c44 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Fri, 14 Apr 2023 15:28:22 +0100 Subject: [PATCH] workspaces: fixup workspaces not activating on workspace switch --- src/helpers/Monitor.cpp | 12 ++++++++++-- src/managers/KeybindManager.cpp | 6 +++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp index 3fa2ebb8..47bb9317 100644 --- a/src/helpers/Monitor.cpp +++ b/src/helpers/Monitor.cpp @@ -477,9 +477,17 @@ float CMonitor::getDefaultScale() { } void CMonitor::changeWorkspace(CWorkspace* const pWorkspace, bool internal) { - if (!pWorkspace || pWorkspace->m_iID == activeWorkspace) + if (!pWorkspace) return; + if (pWorkspace->m_iID == activeWorkspace) { + // in some cases (e.g. workspace from one monitor to another) + // we need to send this + g_pCompositor->deactivateAllWLRWorkspaces(pWorkspace->m_pWlrHandle); + pWorkspace->setActive(true); + return; + } + if (pWorkspace->m_bIsSpecialWorkspace) { Debug::log(ERR, "BUG THIS: Attempted to changeWorkspace to special!"); return; @@ -509,7 +517,7 @@ void CMonitor::changeWorkspace(CWorkspace* const pWorkspace, bool internal) { } // set some flags and fire event - g_pCompositor->deactivateAllWLRWorkspaces(); + g_pCompositor->deactivateAllWLRWorkspaces(pWorkspace->m_pWlrHandle); pWorkspace->setActive(true); g_pEventManager->postEvent(SHyprIPCEvent{"workspace", pWorkspace->m_szName}); EMIT_HOOK_EVENT("workspace", pWorkspace); diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 9c3a5bec..df48fefe 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -777,6 +777,8 @@ void CKeybindManager::changeworkspace(std::string args) { if (!PMONITORWORKSPACEOWNER) return; + g_pCompositor->setActiveMonitor(PMONITORWORKSPACEOWNER); + const auto PREVWSDATA = pWorkspaceToChangeTo->m_sPrevWorkspace; PMONITORWORKSPACEOWNER->changeWorkspace(pWorkspaceToChangeTo); @@ -810,11 +812,12 @@ void CKeybindManager::changeworkspace(std::string args) { const auto PMONITORWORKSPACEOWNER = PMONITOR->ID == pWorkspaceToChangeTo->m_iMonitorID ? PMONITOR : g_pCompositor->getMonitorFromID(pWorkspaceToChangeTo->m_iMonitorID); + g_pCompositor->setActiveMonitor(PMONITORWORKSPACEOWNER); + PMONITORWORKSPACEOWNER->changeWorkspace(pWorkspaceToChangeTo); g_pCompositor->warpCursorTo(PMONITORWORKSPACEOWNER->vecPosition + PMONITORWORKSPACEOWNER->vecSize / 2.f); if (PMONITOR != PMONITORWORKSPACEOWNER) { - g_pCompositor->setActiveMonitor(PMONITORWORKSPACEOWNER); if (const auto PLASTWINDOW = pWorkspaceToChangeTo->getLastFocusedWindow(); PLASTWINDOW) g_pCompositor->focusWindow(PLASTWINDOW); else @@ -869,6 +872,7 @@ void CKeybindManager::moveActiveToWorkspace(std::string args) { if (pWorkspace) { g_pCompositor->moveWindowToWorkspaceSafe(PWINDOW, pWorkspace); const auto PMONITOR = g_pCompositor->getMonitorFromID(pWorkspace->m_iMonitorID); + g_pCompositor->setActiveMonitor(PMONITOR); PMONITOR->changeWorkspace(pWorkspace); } else { const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);