diff options
-rw-r--r-- | src/helpers/Workspace.cpp | 26 | ||||
-rw-r--r-- | src/helpers/Workspace.hpp | 3 | ||||
-rw-r--r-- | src/managers/KeybindManager.cpp | 10 | ||||
-rw-r--r-- | src/render/OpenGL.cpp | 5 | ||||
-rw-r--r-- | src/render/Renderer.cpp | 6 |
5 files changed, 37 insertions, 13 deletions
diff --git a/src/helpers/Workspace.cpp b/src/helpers/Workspace.cpp index e4065907..80bf139c 100644 --- a/src/helpers/Workspace.cpp +++ b/src/helpers/Workspace.cpp @@ -23,6 +23,8 @@ CWorkspace::CWorkspace(int monitorID) { m_vRenderOffset.m_pWorkspace = this; m_vRenderOffset.create(AVARTYPE_VECTOR, &g_pConfigManager->getConfigValuePtr("animations:workspaces_speed")->floatValue, &g_pConfigManager->getConfigValuePtr("animations:workspaces")->intValue, &g_pConfigManager->getConfigValuePtr("animations:workspaces_curve")->strValue, nullptr, AVARDAMAGE_ENTIRE); + m_fAlpha.create(AVARTYPE_FLOAT, &g_pConfigManager->getConfigValuePtr("animations:workspaces_speed")->floatValue, &g_pConfigManager->getConfigValuePtr("animations:workspaces")->intValue, &g_pConfigManager->getConfigValuePtr("animations:workspaces_curve")->strValue, nullptr, AVARDAMAGE_ENTIRE); + m_fAlpha.setValueAndWarp(255.f); } CWorkspace::~CWorkspace() { @@ -33,4 +35,28 @@ CWorkspace::~CWorkspace() { wlr_ext_workspace_handle_v1_destroy(m_pWlrHandle); m_pWlrHandle = nullptr; } +} + +void CWorkspace::startAnim(bool in, bool left) { + const auto ANIMSTYLE = g_pConfigManager->getString("animations:workspaces_style"); + + if (ANIMSTYLE == "fade") { + if (in) { + m_fAlpha.setValueAndWarp(0.f); + m_fAlpha = 255.f; + } else { + m_fAlpha.setValueAndWarp(255.f); + m_fAlpha = 0.f; + } + } else { + // fallback is slide + const auto PMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID); + + if (in) { + m_vRenderOffset.setValueAndWarp(Vector2D(left ? PMONITOR->vecSize.x : -PMONITOR->vecSize.x, 0)); + m_vRenderOffset = Vector2D(0, 0); + } else { + m_vRenderOffset = Vector2D(left ? -PMONITOR->vecSize.x : PMONITOR->vecSize.x, 0); + } + } }
\ No newline at end of file diff --git a/src/helpers/Workspace.hpp b/src/helpers/Workspace.hpp index 3a9abf72..fbf32f6f 100644 --- a/src/helpers/Workspace.hpp +++ b/src/helpers/Workspace.hpp @@ -21,4 +21,7 @@ public: // for animations CAnimatedVariable m_vRenderOffset; + CAnimatedVariable m_fAlpha; + + void startAnim(bool in, bool left); };
\ No newline at end of file diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index e58819d8..87f0b94d 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -209,11 +209,10 @@ void CKeybindManager::changeworkspace(std::string args) { const auto ANIMTOLEFT = workspaceToChangeTo > OLDWORKSPACEID; // start anim on old workspace - g_pCompositor->getWorkspaceByID(OLDWORKSPACEID)->m_vRenderOffset = Vector2D(ANIMTOLEFT ? -PMONITOR->vecSize.x : PMONITOR->vecSize.x, 0); + g_pCompositor->getWorkspaceByID(OLDWORKSPACEID)->startAnim(false, ANIMTOLEFT); // start anim on new workspace - 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); + g_pCompositor->getWorkspaceByID(workspaceToChangeTo)->startAnim(true, ANIMTOLEFT); } @@ -250,14 +249,13 @@ void CKeybindManager::changeworkspace(std::string args) { const auto ANIMTOLEFT = workspaceToChangeTo > OLDWORKSPACE; // start anim on old workspace - g_pCompositor->getWorkspaceByID(OLDWORKSPACE)->m_vRenderOffset = Vector2D(ANIMTOLEFT ? -PMONITOR->vecSize.x : PMONITOR->vecSize.x, 0); + g_pCompositor->getWorkspaceByID(OLDWORKSPACE)->startAnim(false, ANIMTOLEFT); 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(ANIMTOLEFT ? PMONITOR->vecSize.x : -PMONITOR->vecSize.x, 0)); - PWORKSPACE->m_vRenderOffset = Vector2D(0, 0); + PWORKSPACE->startAnim(true, ANIMTOLEFT); // We are required to set the name here immediately wlr_ext_workspace_handle_v1_set_name(PWORKSPACE->m_pWlrHandle, workspaceName.c_str()); diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp index 59bea30d..f82721b6 100644 --- a/src/render/OpenGL.cpp +++ b/src/render/OpenGL.cpp @@ -565,10 +565,7 @@ void CHyprOpenGLImpl::renderBorder(wlr_box* box, const CColor& col, int thick, i wlr_matrix_transpose(glMatrix, glMatrix); - if (col.a == 255.f) - glDisable(GL_BLEND); - else - glEnable(GL_BLEND); + glEnable(GL_BLEND); glUseProgram(m_shQUAD.program); diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 22060e83..0d646317 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -41,7 +41,7 @@ bool shouldRenderWindow(CWindow* pWindow, SMonitor* pMonitor) { const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID); // if not, check if it maybe is active on a different monitor. vvv might be animation in progress - if (g_pCompositor->isWorkspaceVisible(pWindow->m_iWorkspaceID) || (PWORKSPACE && PWORKSPACE->m_iMonitorID == pMonitor->ID && PWORKSPACE->m_vRenderOffset.isBeingAnimated())) + if (g_pCompositor->isWorkspaceVisible(pWindow->m_iWorkspaceID) || (PWORKSPACE && PWORKSPACE->m_iMonitorID == pMonitor->ID && (PWORKSPACE->m_vRenderOffset.isBeingAnimated() || PWORKSPACE->m_fAlpha.isBeingAnimated()))) return true; return false; @@ -96,7 +96,7 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, SMonitor* pMonitor, timespec* renderdata.w = pWindow->m_vRealSize.vec().x; renderdata.h = pWindow->m_vRealSize.vec().y; renderdata.dontRound = pWindow->m_bIsFullscreen; - renderdata.fadeAlpha = pWindow->m_fAlpha.fl(); + renderdata.fadeAlpha = pWindow->m_fAlpha.fl() * (PWORKSPACE->m_fAlpha.fl() / 255.f); renderdata.alpha = pWindow == g_pCompositor->m_pLastWindow ? g_pConfigManager->getFloat("decoration:active_opacity") : g_pConfigManager->getFloat("decoration:inactive_opacity"); // apply window special data @@ -106,7 +106,7 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, SMonitor* pMonitor, timespec* // border if (decorate && !pWindow->m_bX11DoesntWantBorders) - drawBorderForWindow(pWindow, pMonitor, pWindow->m_fAlpha.fl() * renderdata.alpha, PWORKSPACE->m_vRenderOffset.vec()); + drawBorderForWindow(pWindow, pMonitor, renderdata.alpha * renderdata.fadeAlpha, PWORKSPACE->m_vRenderOffset.vec()); if (pWindow->m_bIsX11) { if (pWindow->m_uSurface.xwayland->surface) { |