Added workspace animations

This commit is contained in:
vaxerski 2022-05-12 11:27:31 +02:00
parent 07e208aa73
commit ff0f535c28
11 changed files with 86 additions and 16 deletions

View file

@ -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;

View file

@ -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());