diff options
| author | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2022-05-12 11:27:31 +0200 |
|---|---|---|
| committer | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2022-05-12 11:27:31 +0200 |
| commit | ff0f535c28018eeb5164f3576904748b73136202 (patch) | |
| tree | 0180a5d51034754efe36c6bc352eb198aca4827c /src/managers | |
| parent | 07e208aa73a69505264e8a2922699e09ad708d58 (diff) | |
Added workspace animations
Diffstat (limited to 'src/managers')
| -rw-r--r-- | src/managers/AnimationManager.cpp | 28 | ||||
| -rw-r--r-- | src/managers/KeybindManager.cpp | 15 |
2 files changed, 36 insertions, 7 deletions
diff --git a/src/managers/AnimationManager.cpp b/src/managers/AnimationManager.cpp index 4052c7e2..639be55e 100644 --- a/src/managers/AnimationManager.cpp +++ b/src/managers/AnimationManager.cpp @@ -40,17 +40,27 @@ void CAnimationManager::tick() { // window stuff const auto PWINDOW = (CWindow*)av->m_pWindow; - wlr_box WLRBOXPREV = {PWINDOW->m_vRealPosition.vec().x - BORDERSIZE - 1, PWINDOW->m_vRealPosition.vec().y - BORDERSIZE - 1, PWINDOW->m_vRealSize.vec().x + 2 * BORDERSIZE + 2, PWINDOW->m_vRealSize.vec().y + 2 * BORDERSIZE + 2}; - + const auto PWORKSPACE = (CWorkspace*)av->m_pWorkspace; + wlr_box WLRBOXPREV = {0,0,0,0}; + if (PWINDOW) { + WLRBOXPREV = {(int)PWINDOW->m_vRealPosition.vec().x - BORDERSIZE - 1, (int)PWINDOW->m_vRealPosition.vec().y - BORDERSIZE - 1, (int)PWINDOW->m_vRealSize.vec().x + 2 * BORDERSIZE + 2, (int)PWINDOW->m_vRealSize.vec().y + 2 * BORDERSIZE + 2}; + } else if (PWORKSPACE) { + const auto PMONITOR = g_pCompositor->getMonitorFromID(PWORKSPACE->m_iMonitorID); + WLRBOXPREV = {(int)PMONITOR->vecPosition.x, (int)PMONITOR->vecPosition.y, (int)PMONITOR->vecSize.x, (int)PMONITOR->vecSize.y}; + } + // check if it's disabled, if so, warp if (av->m_pEnabled == 0 || animationsDisabled) { av->warp(); g_pHyprRenderer->damageBox(&WLRBOXPREV); - g_pHyprRenderer->damageWindow(PWINDOW); - // set size and pos if valid - if (g_pCompositor->windowValidMapped(PWINDOW)) - g_pXWaylandManager->setWindowSize(PWINDOW, PWINDOW->m_vRealSize.goalv()); + if (PWINDOW) { + g_pHyprRenderer->damageWindow(PWINDOW); + // set size and pos if valid + if (g_pCompositor->windowValidMapped(PWINDOW)) + g_pXWaylandManager->setWindowSize(PWINDOW, PWINDOW->m_vRealSize.goalv()); + } + continue; } @@ -125,10 +135,14 @@ void CAnimationManager::tick() { switch (av->m_eDamagePolicy) { case AVARDAMAGE_ENTIRE: { g_pHyprRenderer->damageBox(&WLRBOXPREV); - g_pHyprRenderer->damageWindow(PWINDOW); + + if (PWINDOW) + g_pHyprRenderer->damageWindow(PWINDOW); break; } case AVARDAMAGE_BORDER: { + RASSERT(PWINDOW, "Tried to AVARDAMAGE_BORDER a non-window AVAR!"); + // damage only the border. const auto BORDERSIZE = g_pConfigManager->getInt("general:border_size") + 1; // +1 for padding and shit const auto ROUNDINGSIZE = g_pConfigManager->getInt("decoration:rounding") + 1; diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 900e1e00..3a354f23 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -202,6 +202,14 @@ void CKeybindManager::changeworkspace(std::string args) { // and fix on the new workspace g_pCompositor->fixXWaylandWindowsOnWorkspace(PMONITOR->activeWorkspace); + + // here and only here begin anim. we don't want to anim visible workspaces on other monitors. + // start anim on old workspace + g_pCompositor->getWorkspaceByID(OLDWORKSPACEID)->m_vRenderOffset = Vector2D(-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 = Vector2D(0, 0); } @@ -234,9 +242,16 @@ void CKeybindManager::changeworkspace(std::string args) { const auto OLDWORKSPACE = PMONITOR->activeWorkspace; + // start anim on old workspace + g_pCompositor->getWorkspaceByID(OLDWORKSPACE)->m_vRenderOffset = Vector2D(-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 = Vector2D(0, 0); + // We are required to set the name here immediately wlr_ext_workspace_handle_v1_set_name(PWORKSPACE->m_pWlrHandle, workspaceName.c_str()); |
