diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 3a354f23..c41f552a 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -204,11 +204,14 @@ void CKeybindManager::changeworkspace(std::string args) { g_pCompositor->fixXWaylandWindowsOnWorkspace(PMONITOR->activeWorkspace); // here and only here begin anim. we don't want to anim visible workspaces on other monitors. + // check if anim left or right + const auto ANIMTOLEFT = workspaceToChangeTo > OLDWORKSPACEID; + // start anim on old workspace - g_pCompositor->getWorkspaceByID(OLDWORKSPACEID)->m_vRenderOffset = Vector2D(-PMONITOR->vecSize.x, 0); + g_pCompositor->getWorkspaceByID(OLDWORKSPACEID)->m_vRenderOffset = Vector2D(ANIMTOLEFT ? -PMONITOR->vecSize.x : PMONITOR->vecSize.x, 0); // start anim on new workspace - g_pCompositor->getWorkspaceByID(workspaceToChangeTo)->m_vRenderOffset.setValueAndWarp(Vector2D(PMONITOR->vecSize.x, 0)); + g_pCompositor->getWorkspaceByID(workspaceToChangeTo)->m_vRenderOffset.setValueAndWarp(Vector2D(ANIMTOLEFT ? PMONITOR->vecSize.x : -PMONITOR->vecSize.x, 0)); g_pCompositor->getWorkspaceByID(workspaceToChangeTo)->m_vRenderOffset = Vector2D(0, 0); } @@ -242,14 +245,17 @@ void CKeybindManager::changeworkspace(std::string args) { const auto OLDWORKSPACE = PMONITOR->activeWorkspace; + // get anim direction + const auto ANIMTOLEFT = workspaceToChangeTo > OLDWORKSPACE; + // start anim on old workspace - g_pCompositor->getWorkspaceByID(OLDWORKSPACE)->m_vRenderOffset = Vector2D(-PMONITOR->vecSize.x, 0); + g_pCompositor->getWorkspaceByID(OLDWORKSPACE)->m_vRenderOffset = Vector2D(ANIMTOLEFT ? -PMONITOR->vecSize.x : PMONITOR->vecSize.x, 0); g_pCompositor->m_lWorkspaces.emplace_back(PMONITOR->ID); const auto PWORKSPACE = &g_pCompositor->m_lWorkspaces.back(); // start anim on new workspace - PWORKSPACE->m_vRenderOffset.setValueAndWarp(Vector2D(PMONITOR->vecSize.x, 0)); + PWORKSPACE->m_vRenderOffset.setValueAndWarp(Vector2D(ANIMTOLEFT ? PMONITOR->vecSize.x : -PMONITOR->vecSize.x, 0)); PWORKSPACE->m_vRenderOffset = Vector2D(0, 0); // We are required to set the name here immediately