diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 868f15e0..76b0460e 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -743,7 +743,7 @@ CWindow* CCompositor::getWindowInDirection(CWindow* pWindow, char dir) { void CCompositor::deactivateAllWLRWorkspaces(wlr_ext_workspace_handle_v1* exclude) { for (auto& w : m_lWorkspaces) { if (w.m_pWlrHandle && w.m_pWlrHandle != exclude) - wlr_ext_workspace_handle_v1_set_active(w.m_pWlrHandle, false); + w.setActive(false); } } diff --git a/src/events/Monitors.cpp b/src/events/Monitors.cpp index aee360b2..ed25a4b2 100644 --- a/src/events/Monitors.cpp +++ b/src/events/Monitors.cpp @@ -115,7 +115,7 @@ void Events::listener_newOutput(wl_listener* listener, void* data) { PNEWMONITOR->scale = monitorRule.scale; g_pCompositor->deactivateAllWLRWorkspaces(PNEWWORKSPACE->m_pWlrHandle); - wlr_ext_workspace_handle_v1_set_active(PNEWWORKSPACE->m_pWlrHandle, true); + PNEWWORKSPACE->setActive(true); if (!pMostHzMonitor || monitorRule.refreshRate > pMostHzMonitor->refreshRate) pMostHzMonitor = PNEWMONITOR; diff --git a/src/helpers/Workspace.cpp b/src/helpers/Workspace.cpp index 5341fdf7..00ac6132 100644 --- a/src/helpers/Workspace.cpp +++ b/src/helpers/Workspace.cpp @@ -64,4 +64,10 @@ void CWorkspace::startAnim(bool in, bool left) { m_vRenderOffset = Vector2D(left ? -PMONITOR->vecSize.x : PMONITOR->vecSize.x, 0); } } +} + +void CWorkspace::setActive(bool on) { + if (m_pWlrHandle) { + wlr_ext_workspace_handle_v1_set_active(m_pWlrHandle, on); + } } \ No newline at end of file diff --git a/src/helpers/Workspace.hpp b/src/helpers/Workspace.hpp index fbf32f6f..6347a63b 100644 --- a/src/helpers/Workspace.hpp +++ b/src/helpers/Workspace.hpp @@ -24,4 +24,5 @@ public: CAnimatedVariable m_fAlpha; void startAnim(bool in, bool left); + void setActive(bool on); }; \ No newline at end of file diff --git a/src/managers/InputManager.cpp b/src/managers/InputManager.cpp index e3e4bd36..446ce369 100644 --- a/src/managers/InputManager.cpp +++ b/src/managers/InputManager.cpp @@ -87,11 +87,12 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { g_pCompositor->m_pLastMonitor = PMONITOR; // set active workspace and deactivate all other in wlr - g_pCompositor->deactivateAllWLRWorkspaces(g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace)->m_pWlrHandle); - wlr_ext_workspace_handle_v1_set_active(g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace)->m_pWlrHandle, true); + const auto ACTIVEWORKSPACE = g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace); + g_pCompositor->deactivateAllWLRWorkspaces(ACTIVEWORKSPACE->m_pWlrHandle); + ACTIVEWORKSPACE->setActive(true); // event - g_pEventManager->postEvent(SHyprIPCEvent("activemon", PMONITOR->szName + "," + g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace)->m_szName)); + g_pEventManager->postEvent(SHyprIPCEvent("activemon", PMONITOR->szName + "," + ACTIVEWORKSPACE->m_szName)); } Vector2D surfaceCoords; diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index ed2be2c5..f6e4f037 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -226,7 +226,7 @@ void CKeybindManager::changeworkspace(std::string args) { // set active and deactivate all other in wlr g_pCompositor->deactivateAllWLRWorkspaces(PWORKSPACETOCHANGETO->m_pWlrHandle); - wlr_ext_workspace_handle_v1_set_active(PWORKSPACETOCHANGETO->m_pWlrHandle, true); + PWORKSPACETOCHANGETO->setActive(true); Debug::log(LOG, "Changed to workspace %i", workspaceToChangeTo); @@ -271,7 +271,7 @@ void CKeybindManager::changeworkspace(std::string args) { // set active and deactivate all other g_pCompositor->deactivateAllWLRWorkspaces(PWORKSPACE->m_pWlrHandle); - wlr_ext_workspace_handle_v1_set_active(PWORKSPACE->m_pWlrHandle, true); + PWORKSPACE->setActive(true); // mark the monitor dirty g_pHyprRenderer->damageMonitor(PMONITOR);