From b50927375919a16c51192c4c2e8c5cf3f86c05b2 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sat, 24 Aug 2024 20:29:31 +0200 Subject: [PATCH 1/6] implement ws scaling --- src/config/ConfigManager.cpp | 8 ++- src/desktop/Workspace.cpp | 98 +++++++++++++------------------ src/desktop/Workspace.hpp | 1 + src/managers/AnimationManager.cpp | 4 +- src/render/Renderer.cpp | 94 +++++++++++++++++++++++------ 5 files changed, 125 insertions(+), 80 deletions(-) diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 0390b9d9a9a..58b186774d4 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -741,8 +741,6 @@ void CConfigManager::setDefaultAnimationVars() { INITANIMCFG("fadeShadow"); INITANIMCFG("fadeDim"); - // border - // workspaces INITANIMCFG("workspaces"); INITANIMCFG("workspacesIn"); @@ -777,6 +775,12 @@ void CConfigManager::setDefaultAnimationVars() { CREATEANIMCFG("fadeLayers", "fade"); CREATEANIMCFG("fadeLayersIn", "fadeLayers"); CREATEANIMCFG("fadeLayersOut", "fadeLayers"); + CREATEANIMCFG("fadeWorkspaces", "fade"); + CREATEANIMCFG("fadeWorkspacesIn", "fadeWorkspaces"); + CREATEANIMCFG("fadeWorkspacesOut", "fadeWorkspaces"); + CREATEANIMCFG("fadeSpecialWorkspace", "fadeWorkspaces"); + CREATEANIMCFG("fadeSpecialWorkspaceIn", "fadeSpecialWorkspace"); + CREATEANIMCFG("fadeSpecialWorkspaceOut", "fadeSpecialWorkspace"); CREATEANIMCFG("workspacesIn", "workspaces"); CREATEANIMCFG("workspacesOut", "workspaces"); diff --git a/src/desktop/Workspace.cpp b/src/desktop/Workspace.cpp index a9412e6d243..36bd08d4d6e 100644 --- a/src/desktop/Workspace.cpp +++ b/src/desktop/Workspace.cpp @@ -26,12 +26,18 @@ void CWorkspace::init(PHLWORKSPACE self) { g_pConfigManager->getAnimationPropertyConfig("workspacesIn"), self, AVARDAMAGE_ENTIRE); m_fAlpha.create(AVARTYPE_FLOAT, - m_bIsSpecialWorkspace ? g_pConfigManager->getAnimationPropertyConfig("specialWorkspaceIn") : g_pConfigManager->getAnimationPropertyConfig("workspacesIn"), self, - AVARDAMAGE_ENTIRE); + m_bIsSpecialWorkspace ? g_pConfigManager->getAnimationPropertyConfig("fadeSpecialWorkspaceIn") : + g_pConfigManager->getAnimationPropertyConfig("fadeWorkspacesIn"), + self, AVARDAMAGE_ENTIRE); m_fAlpha.setValueAndWarp(1.f); + m_fScaleClients.create( + AVARTYPE_FLOAT, m_bIsSpecialWorkspace ? g_pConfigManager->getAnimationPropertyConfig("specialWorkspaceIn") : g_pConfigManager->getAnimationPropertyConfig("workspacesIn"), + self, AVARDAMAGE_ENTIRE); + m_fScaleClients.setValueAndWarp(1.f); m_vRenderOffset.registerVar(); m_fAlpha.registerVar(); + m_fScaleClients.registerVar(); const auto RULEFORTHIS = g_pConfigManager->getWorkspaceRuleFor(self); if (RULEFORTHIS.defaultName.has_value()) @@ -83,13 +89,15 @@ CWorkspace::~CWorkspace() { void CWorkspace::startAnim(bool in, bool left, bool instant) { if (!instant) { - const std::string ANIMNAME = std::format("{}{}", m_bIsSpecialWorkspace ? "specialWorkspace" : "workspaces", in ? "In" : "Out"); + const std::string ANIMNAME = std::format("{}{}", m_bIsSpecialWorkspace ? "specialWorkspace" : "workspaces", in ? "In" : "Out"); + const std::string ANIMNAME2 = std::format("fade{}{}", m_bIsSpecialWorkspace ? "SpecialWorkspace" : "Workspaces", in ? "In" : "Out"); - m_fAlpha.m_pConfig = g_pConfigManager->getAnimationPropertyConfig(ANIMNAME); + m_fAlpha.m_pConfig = g_pConfigManager->getAnimationPropertyConfig(ANIMNAME2); m_vRenderOffset.m_pConfig = g_pConfigManager->getAnimationPropertyConfig(ANIMNAME); + m_fScaleClients.m_pConfig = g_pConfigManager->getAnimationPropertyConfig(ANIMNAME); } - const auto ANIMSTYLE = m_fAlpha.m_pConfig->pValues->internalStyle; + const auto ANIMSTYLE = m_vRenderOffset.m_pConfig->pValues->internalStyle; static auto PWORKSPACEGAP = CConfigValue("general:gaps_workspaces"); // set floating windows offset callbacks @@ -102,95 +110,71 @@ void CWorkspace::startAnim(bool in, bool left, bool instant) { }; }); - if (ANIMSTYLE.starts_with("slidefade")) { + m_fAlpha.setValueAndWarp(in ? 0.F : 1.F); + m_fAlpha = in ? 1.F : 0.F; + + // handle animation styles for the movement one + if (ANIMSTYLE.starts_with("slide") && ANIMSTYLE.contains("%")) { const auto PMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID); float movePerc = 100.f; - if (ANIMSTYLE.find("%") != std::string::npos) { - try { - auto percstr = ANIMSTYLE.substr(ANIMSTYLE.find_last_of(' ') + 1); - movePerc = std::stoi(percstr.substr(0, percstr.length() - 1)); - } catch (std::exception& e) { Debug::log(ERR, "Error in startAnim: invalid percentage"); } - } + try { + auto percstr = ANIMSTYLE.substr(ANIMSTYLE.find_last_of(' ') + 1); + movePerc = std::stoi(percstr.substr(0, percstr.length() - 1)); + } catch (std::exception& e) { Debug::log(ERR, "Error in startAnim: invalid percentage"); } - m_fAlpha.setValueAndWarp(1.f); m_vRenderOffset.setValueAndWarp(Vector2D(0, 0)); + m_fScaleClients.setValueAndWarp(1.F); - if (ANIMSTYLE.starts_with("slidefadevert")) { + if (ANIMSTYLE.starts_with("slidevert")) { if (in) { - m_fAlpha.setValueAndWarp(0.f); m_vRenderOffset.setValueAndWarp(Vector2D(0.0, (left ? PMONITOR->vecSize.y : -PMONITOR->vecSize.y) * (movePerc / 100.f))); - m_fAlpha = 1.f; m_vRenderOffset = Vector2D(0, 0); - } else { - m_fAlpha.setValueAndWarp(1.f); - m_fAlpha = 0.f; + } else m_vRenderOffset = Vector2D(0.0, (left ? -PMONITOR->vecSize.y : PMONITOR->vecSize.y) * (movePerc / 100.f)); - } + } else { if (in) { - m_fAlpha.setValueAndWarp(0.f); m_vRenderOffset.setValueAndWarp(Vector2D((left ? PMONITOR->vecSize.x : -PMONITOR->vecSize.x) * (movePerc / 100.f), 0.0)); - m_fAlpha = 1.f; m_vRenderOffset = Vector2D(0, 0); - } else { - m_fAlpha.setValueAndWarp(1.f); - m_fAlpha = 0.f; + } else m_vRenderOffset = Vector2D((left ? -PMONITOR->vecSize.x : PMONITOR->vecSize.x) * (movePerc / 100.f), 0.0); - } } - } else if (ANIMSTYLE == "fade") { - m_vRenderOffset.setValueAndWarp(Vector2D(0, 0)); // fix a bug, if switching from slide -> fade. + } else if (ANIMSTYLE.starts_with("popin")) { + m_vRenderOffset.setValueAndWarp(Vector2D(0, 0)); - if (in) { - m_fAlpha.setValueAndWarp(0.f); - m_fAlpha = 1.f; - } else { - m_fAlpha.setValueAndWarp(1.f); - m_fAlpha = 0.f; - } - } else if (ANIMSTYLE == "slidevert") { - // fallback is slide - const auto PMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID); - const auto YDISTANCE = PMONITOR->vecSize.y + *PWORKSPACEGAP; + float startPerc = 100.f; - m_fAlpha.setValueAndWarp(1.f); // fix a bug, if switching from fade -> slide. + try { + auto percstr = ANIMSTYLE.substr(ANIMSTYLE.find_last_of(' ') + 1); + startPerc = std::stoi(percstr.substr(0, percstr.length() - 1)); + } catch (std::exception& e) { Debug::log(ERR, "Error in startAnim: invalid percentage"); } if (in) { - m_vRenderOffset.setValueAndWarp(Vector2D(0.0, left ? YDISTANCE : -YDISTANCE)); - m_vRenderOffset = Vector2D(0, 0); + m_fScaleClients.setValueAndWarp(startPerc / 100.F); + m_fScaleClients = 1.F; } else { - m_vRenderOffset = Vector2D(0.0, left ? -YDISTANCE : YDISTANCE); + m_fScaleClients.setValueAndWarp(1.F); + m_fScaleClients = startPerc / 100.F; } } else { // fallback is slide const auto PMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID); const auto XDISTANCE = PMONITOR->vecSize.x + *PWORKSPACEGAP; - m_fAlpha.setValueAndWarp(1.f); // fix a bug, if switching from fade -> slide. + m_fScaleClients.setValueAndWarp(1.F); if (in) { m_vRenderOffset.setValueAndWarp(Vector2D(left ? XDISTANCE : -XDISTANCE, 0.0)); m_vRenderOffset = Vector2D(0, 0); - } else { + } else m_vRenderOffset = Vector2D(left ? -XDISTANCE : XDISTANCE, 0.0); - } - } - - if (m_bIsSpecialWorkspace) { - // required for open/close animations - if (in) { - m_fAlpha.setValueAndWarp(0.f); - m_fAlpha = 1.f; - } else { - m_fAlpha.setValueAndWarp(1.f); - m_fAlpha = 0.f; - } } if (instant) { m_vRenderOffset.warp(); m_fAlpha.warp(); + m_fScaleClients.warp(); } } diff --git a/src/desktop/Workspace.hpp b/src/desktop/Workspace.hpp index 9cacb0ccae8..3024c64cdc8 100644 --- a/src/desktop/Workspace.hpp +++ b/src/desktop/Workspace.hpp @@ -39,6 +39,7 @@ class CWorkspace { // for animations CAnimatedVariable m_vRenderOffset; CAnimatedVariable m_fAlpha; + CAnimatedVariable m_fScaleClients; bool m_bForceRendering = false; // allows damage to propagate. diff --git a/src/managers/AnimationManager.cpp b/src/managers/AnimationManager.cpp index beb880be32c..f8e60de41ce 100644 --- a/src/managers/AnimationManager.cpp +++ b/src/managers/AnimationManager.cpp @@ -472,9 +472,9 @@ std::string CAnimationManager::styleValidInConfigVar(const std::string& config, return "unknown style"; } else if (config.starts_with("workspaces") || config.starts_with("specialWorkspace")) { - if (style == "slide" || style == "slidevert" || style == "fade") + if (style == "slide" || style == "slidevert") return ""; - else if (style.starts_with("slidefade")) { + else if (style.starts_with("slide") || style.starts_with("popin")) { // try parsing float movePerc = 0.f; if (style.find("%") != std::string::npos) { diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index c2ecbbf3977..828d35cf9f5 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -437,6 +437,17 @@ void CHyprRenderer::renderWorkspaceWindows(CMonitor* pMonitor, PHLWORKSPACE pWor EMIT_HOOK_EVENT("render", RENDER_PRE_WINDOWS); + // TODO: dedup this with renderallclients + auto preWorkspaceScaleAnim = []() { g_pHyprOpenGL->bindOffMain(); }; + + auto postWorkspaceScaleAnim = [pMonitor](PHLWORKSPACE workspace) { + g_pHyprOpenGL->bindBackOnMain(); + CBox box = CBox{{}, pMonitor->vecPixelSize}.scaleFromCenter(workspace->m_fScaleClients.value()); + g_pHyprOpenGL->renderTexture(g_pHyprOpenGL->m_RenderData.pCurrentMonData->offMainFB.m_cTex, &box, 1.F); + }; + + std::unordered_map>> toRender; + // Non-floating main for (auto& w : g_pCompositor->m_vWindows) { if (w->isHidden() || (!w->m_bIsMapped && !w->m_bFadingOut)) @@ -457,12 +468,11 @@ void CHyprRenderer::renderWorkspaceWindows(CMonitor* pMonitor, PHLWORKSPACE pWor continue; } - // render the bad boy - renderWindow(w, pMonitor, time, true, RENDER_PASS_MAIN); + toRender[w->m_pWorkspace].emplace_back(w, RENDER_PASS_MAIN); } if (lastWindow) - renderWindow(lastWindow, pMonitor, time, true, RENDER_PASS_MAIN); + toRender[lastWindow->m_pWorkspace].emplace_back(lastWindow, RENDER_PASS_MAIN); // Non-floating popup for (auto& w : g_pCompositor->m_vWindows) { @@ -478,8 +488,7 @@ void CHyprRenderer::renderWorkspaceWindows(CMonitor* pMonitor, PHLWORKSPACE pWor if (!shouldRenderWindow(w, pMonitor)) continue; - // render the bad boy - renderWindow(w, pMonitor, time, true, RENDER_PASS_POPUP); + toRender[w->m_pWorkspace].emplace_back(w, RENDER_PASS_POPUP); } // floating on top @@ -499,9 +508,39 @@ void CHyprRenderer::renderWorkspaceWindows(CMonitor* pMonitor, PHLWORKSPACE pWor if (pWorkspace->m_bIsSpecialWorkspace && w->m_iMonitorID != pWorkspace->m_iMonitorID) continue; // special on another are rendered as a part of the base pass - // render the bad boy - renderWindow(w, pMonitor, time, true, RENDER_PASS_ALL); + toRender[w->m_pWorkspace].emplace_back(w, RENDER_PASS_ALL); + } + + // firstly, render all workspaces in sync, but leave out main workspace + for (auto& [k, v] : toRender) { + if (k == pWorkspace) + continue; + + const bool SCALE = k->m_fScaleClients.value() != 1.F && g_pCompositor->getWindowsOnWorkspace(k->m_iID) > 0; + + if (SCALE) + preWorkspaceScaleAnim(); + + for (auto& [window, mode] : v) { + renderWindow(window, pMonitor, time, true, mode); + } + + if (SCALE) + postWorkspaceScaleAnim(k); + } + + const bool SCALE = pWorkspace->m_fScaleClients.value() != 1.F && g_pCompositor->getWindowsOnWorkspace(pWorkspace->m_iID) > 0; + + if (SCALE) + preWorkspaceScaleAnim(); + + // lastly, render the current ws + for (auto& [window, mode] : toRender[pWorkspace]) { + renderWindow(window, pMonitor, time, true, mode); } + + if (SCALE) + postWorkspaceScaleAnim(pWorkspace); } void CHyprRenderer::renderWindow(PHLWINDOW pWindow, CMonitor* pMonitor, timespec* time, bool decorate, eRenderPassMode mode, bool ignorePosition, bool ignoreAllGeometry) { @@ -813,11 +852,19 @@ void CHyprRenderer::renderSessionLockSurface(SSessionLockSurface* pSurface, CMon } void CHyprRenderer::renderAllClientsForWorkspace(CMonitor* pMonitor, PHLWORKSPACE pWorkspace, timespec* time, const Vector2D& translate, const float& scale) { - static auto PDIMSPECIAL = CConfigValue("decoration:dim_special"); - static auto PBLURSPECIAL = CConfigValue("decoration:blur:special"); - static auto PBLUR = CConfigValue("decoration:blur:enabled"); - static auto PRENDERTEX = CConfigValue("misc:disable_hyprland_logo"); - static auto PBACKGROUNDCOLOR = CConfigValue("misc:background_color"); + static auto PDIMSPECIAL = CConfigValue("decoration:dim_special"); + static auto PBLURSPECIAL = CConfigValue("decoration:blur:special"); + static auto PBLUR = CConfigValue("decoration:blur:enabled"); + static auto PRENDERTEX = CConfigValue("misc:disable_hyprland_logo"); + static auto PBACKGROUNDCOLOR = CConfigValue("misc:background_color"); + + auto preWorkspaceScaleAnim = []() { g_pHyprOpenGL->bindOffMain(); }; + + auto postWorkspaceScaleAnim = [pMonitor](PHLWORKSPACE workspace) { + g_pHyprOpenGL->bindBackOnMain(); + CBox box = CBox{{}, pMonitor->vecPixelSize}.scaleFromCenter(workspace->m_fScaleClients.value()); + g_pHyprOpenGL->renderTexture(g_pHyprOpenGL->m_RenderData.pCurrentMonData->offMainFB.m_cTex, &box, 1.F); + }; SRenderModifData RENDERMODIFDATA; if (translate != Vector2D{0, 0}) @@ -936,12 +983,21 @@ void CHyprRenderer::renderAllClientsForWorkspace(CMonitor* pMonitor, PHLWORKSPAC // special for (auto& ws : g_pCompositor->m_vWorkspaces) { - if (ws->m_fAlpha.value() > 0.f && ws->m_bIsSpecialWorkspace) { - if (ws->m_bHasFullscreenWindow) - renderWorkspaceWindowsFullscreen(pMonitor, ws, time); - else - renderWorkspaceWindows(pMonitor, ws, time); - } + if (ws->m_fAlpha.value() <= 0.F || !ws->m_bIsSpecialWorkspace) + continue; + + const bool SCALE = ws->m_fScaleClients.value() != 1.F && g_pCompositor->getWindowsOnWorkspace(ws->m_iID) > 0; + + if (SCALE) + preWorkspaceScaleAnim(); + + if (ws->m_bHasFullscreenWindow) + renderWorkspaceWindowsFullscreen(pMonitor, ws, time); + else + renderWorkspaceWindows(pMonitor, ws, time); + + if (SCALE) + postWorkspaceScaleAnim(ws); } // pinned always above @@ -1316,7 +1372,7 @@ void CHyprRenderer::renderMonitor(CMonitor* pMonitor) { EMIT_HOOK_EVENT("render", RENDER_POST_MIRROR); renderCursor = false; } else { - CBox renderBox = {0, 0, (int)pMonitor->vecPixelSize.x, (int)pMonitor->vecPixelSize.y}; + CBox renderBox = CBox{0, 0, (int)pMonitor->vecPixelSize.x, (int)pMonitor->vecPixelSize.y}; renderWorkspace(pMonitor, pMonitor->activeWorkspace, &now, renderBox); renderLockscreen(pMonitor, &now, renderBox); From 00319c01d4a6919f0036e21f1a19e8309ddecb81 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sat, 24 Aug 2024 20:31:14 +0200 Subject: [PATCH 2/6] def 0% --- src/desktop/Workspace.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/desktop/Workspace.cpp b/src/desktop/Workspace.cpp index 36bd08d4d6e..6b1e23b865e 100644 --- a/src/desktop/Workspace.cpp +++ b/src/desktop/Workspace.cpp @@ -116,7 +116,7 @@ void CWorkspace::startAnim(bool in, bool left, bool instant) { // handle animation styles for the movement one if (ANIMSTYLE.starts_with("slide") && ANIMSTYLE.contains("%")) { const auto PMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID); - float movePerc = 100.f; + float movePerc = 0.F; try { auto percstr = ANIMSTYLE.substr(ANIMSTYLE.find_last_of(' ') + 1); @@ -143,7 +143,7 @@ void CWorkspace::startAnim(bool in, bool left, bool instant) { } else if (ANIMSTYLE.starts_with("popin")) { m_vRenderOffset.setValueAndWarp(Vector2D(0, 0)); - float startPerc = 100.f; + float startPerc = 0.F; try { auto percstr = ANIMSTYLE.substr(ANIMSTYLE.find_last_of(' ') + 1); From 746f80456840fbaeb056edbbbd233377b6cf1c9d Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sat, 24 Aug 2024 20:42:16 +0200 Subject: [PATCH 3/6] oops --- src/render/Renderer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 828d35cf9f5..760760938f5 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -516,7 +516,7 @@ void CHyprRenderer::renderWorkspaceWindows(CMonitor* pMonitor, PHLWORKSPACE pWor if (k == pWorkspace) continue; - const bool SCALE = k->m_fScaleClients.value() != 1.F && g_pCompositor->getWindowsOnWorkspace(k->m_iID) > 0; + const bool SCALE = k && k->m_fScaleClients.value() != 1.F && g_pCompositor->getWindowsOnWorkspace(k->m_iID) > 0; if (SCALE) preWorkspaceScaleAnim(); From 276652b44e43a441381f51644f21ed901dab6c8f Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sat, 24 Aug 2024 20:53:27 +0200 Subject: [PATCH 4/6] fix pure fade --- src/desktop/Workspace.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/desktop/Workspace.cpp b/src/desktop/Workspace.cpp index 6b1e23b865e..735da9f7afc 100644 --- a/src/desktop/Workspace.cpp +++ b/src/desktop/Workspace.cpp @@ -164,11 +164,14 @@ void CWorkspace::startAnim(bool in, bool left, bool instant) { m_fScaleClients.setValueAndWarp(1.F); - if (in) { - m_vRenderOffset.setValueAndWarp(Vector2D(left ? XDISTANCE : -XDISTANCE, 0.0)); - m_vRenderOffset = Vector2D(0, 0); - } else - m_vRenderOffset = Vector2D(left ? -XDISTANCE : XDISTANCE, 0.0); + // special case: fade enabled but this anim is disabled, so don't change anything. Only do the anim otherwise. + if (m_vRenderOffset.m_pConfig->pValues->internalEnabled || !m_fAlpha.m_pConfig->pValues->internalEnabled) { + if (in) { + m_vRenderOffset.setValueAndWarp(Vector2D(left ? XDISTANCE : -XDISTANCE, 0.0)); + m_vRenderOffset = Vector2D(0, 0); + } else + m_vRenderOffset = Vector2D(left ? -XDISTANCE : XDISTANCE, 0.0); + } } if (instant) { From d3e26652d627a7bf3e562de415568260d9865a2f Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sat, 24 Aug 2024 20:54:05 +0200 Subject: [PATCH 5/6] better --- src/desktop/Workspace.cpp | 85 +++++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 43 deletions(-) diff --git a/src/desktop/Workspace.cpp b/src/desktop/Workspace.cpp index 735da9f7afc..5c1fedf1686 100644 --- a/src/desktop/Workspace.cpp +++ b/src/desktop/Workspace.cpp @@ -114,58 +114,57 @@ void CWorkspace::startAnim(bool in, bool left, bool instant) { m_fAlpha = in ? 1.F : 0.F; // handle animation styles for the movement one - if (ANIMSTYLE.starts_with("slide") && ANIMSTYLE.contains("%")) { - const auto PMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID); - float movePerc = 0.F; + if (m_vRenderOffset.m_pConfig->pValues->internalEnabled) { + if (ANIMSTYLE.starts_with("slide") && ANIMSTYLE.contains("%")) { + const auto PMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID); + float movePerc = 0.F; - try { - auto percstr = ANIMSTYLE.substr(ANIMSTYLE.find_last_of(' ') + 1); - movePerc = std::stoi(percstr.substr(0, percstr.length() - 1)); - } catch (std::exception& e) { Debug::log(ERR, "Error in startAnim: invalid percentage"); } + try { + auto percstr = ANIMSTYLE.substr(ANIMSTYLE.find_last_of(' ') + 1); + movePerc = std::stoi(percstr.substr(0, percstr.length() - 1)); + } catch (std::exception& e) { Debug::log(ERR, "Error in startAnim: invalid percentage"); } - m_vRenderOffset.setValueAndWarp(Vector2D(0, 0)); - m_fScaleClients.setValueAndWarp(1.F); - - if (ANIMSTYLE.starts_with("slidevert")) { - if (in) { - m_vRenderOffset.setValueAndWarp(Vector2D(0.0, (left ? PMONITOR->vecSize.y : -PMONITOR->vecSize.y) * (movePerc / 100.f))); - m_vRenderOffset = Vector2D(0, 0); - } else - m_vRenderOffset = Vector2D(0.0, (left ? -PMONITOR->vecSize.y : PMONITOR->vecSize.y) * (movePerc / 100.f)); + m_vRenderOffset.setValueAndWarp(Vector2D(0, 0)); + m_fScaleClients.setValueAndWarp(1.F); - } else { - if (in) { - m_vRenderOffset.setValueAndWarp(Vector2D((left ? PMONITOR->vecSize.x : -PMONITOR->vecSize.x) * (movePerc / 100.f), 0.0)); - m_vRenderOffset = Vector2D(0, 0); - } else - m_vRenderOffset = Vector2D((left ? -PMONITOR->vecSize.x : PMONITOR->vecSize.x) * (movePerc / 100.f), 0.0); - } - } else if (ANIMSTYLE.starts_with("popin")) { - m_vRenderOffset.setValueAndWarp(Vector2D(0, 0)); + if (ANIMSTYLE.starts_with("slidevert")) { + if (in) { + m_vRenderOffset.setValueAndWarp(Vector2D(0.0, (left ? PMONITOR->vecSize.y : -PMONITOR->vecSize.y) * (movePerc / 100.f))); + m_vRenderOffset = Vector2D(0, 0); + } else + m_vRenderOffset = Vector2D(0.0, (left ? -PMONITOR->vecSize.y : PMONITOR->vecSize.y) * (movePerc / 100.f)); + + } else { + if (in) { + m_vRenderOffset.setValueAndWarp(Vector2D((left ? PMONITOR->vecSize.x : -PMONITOR->vecSize.x) * (movePerc / 100.f), 0.0)); + m_vRenderOffset = Vector2D(0, 0); + } else + m_vRenderOffset = Vector2D((left ? -PMONITOR->vecSize.x : PMONITOR->vecSize.x) * (movePerc / 100.f), 0.0); + } + } else if (ANIMSTYLE.starts_with("popin")) { + m_vRenderOffset.setValueAndWarp(Vector2D(0, 0)); - float startPerc = 0.F; + float startPerc = 0.F; - try { - auto percstr = ANIMSTYLE.substr(ANIMSTYLE.find_last_of(' ') + 1); - startPerc = std::stoi(percstr.substr(0, percstr.length() - 1)); - } catch (std::exception& e) { Debug::log(ERR, "Error in startAnim: invalid percentage"); } + try { + auto percstr = ANIMSTYLE.substr(ANIMSTYLE.find_last_of(' ') + 1); + startPerc = std::stoi(percstr.substr(0, percstr.length() - 1)); + } catch (std::exception& e) { Debug::log(ERR, "Error in startAnim: invalid percentage"); } - if (in) { - m_fScaleClients.setValueAndWarp(startPerc / 100.F); - m_fScaleClients = 1.F; + if (in) { + m_fScaleClients.setValueAndWarp(startPerc / 100.F); + m_fScaleClients = 1.F; + } else { + m_fScaleClients.setValueAndWarp(1.F); + m_fScaleClients = startPerc / 100.F; + } } else { - m_fScaleClients.setValueAndWarp(1.F); - m_fScaleClients = startPerc / 100.F; - } - } else { - // fallback is slide - const auto PMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID); - const auto XDISTANCE = PMONITOR->vecSize.x + *PWORKSPACEGAP; + // fallback is slide + const auto PMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID); + const auto XDISTANCE = PMONITOR->vecSize.x + *PWORKSPACEGAP; - m_fScaleClients.setValueAndWarp(1.F); + m_fScaleClients.setValueAndWarp(1.F); - // special case: fade enabled but this anim is disabled, so don't change anything. Only do the anim otherwise. - if (m_vRenderOffset.m_pConfig->pValues->internalEnabled || !m_fAlpha.m_pConfig->pValues->internalEnabled) { if (in) { m_vRenderOffset.setValueAndWarp(Vector2D(left ? XDISTANCE : -XDISTANCE, 0.0)); m_vRenderOffset = Vector2D(0, 0); From 85917a40b0001c206610dbbcc7295c5550fad2ec Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sat, 24 Aug 2024 20:58:21 +0200 Subject: [PATCH 6/6] more --- src/render/Renderer.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 760760938f5..2993de1c1f3 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -513,10 +513,10 @@ void CHyprRenderer::renderWorkspaceWindows(CMonitor* pMonitor, PHLWORKSPACE pWor // firstly, render all workspaces in sync, but leave out main workspace for (auto& [k, v] : toRender) { - if (k == pWorkspace) + if (k == pWorkspace || !k) continue; - const bool SCALE = k && k->m_fScaleClients.value() != 1.F && g_pCompositor->getWindowsOnWorkspace(k->m_iID) > 0; + const bool SCALE = k->m_fScaleClients.value() != 1.F && g_pCompositor->getWindowsOnWorkspace(k->m_iID) > 0; if (SCALE) preWorkspaceScaleAnim(); @@ -535,8 +535,16 @@ void CHyprRenderer::renderWorkspaceWindows(CMonitor* pMonitor, PHLWORKSPACE pWor preWorkspaceScaleAnim(); // lastly, render the current ws - for (auto& [window, mode] : toRender[pWorkspace]) { - renderWindow(window, pMonitor, time, true, mode); + if (toRender.contains(pWorkspace)) { + for (auto& [window, mode] : toRender[pWorkspace]) { + renderWindow(window, pMonitor, time, true, mode); + } + } + // and the null ws (windows fading out) + if (toRender.contains(nullptr)) { + for (auto& [window, mode] : toRender[nullptr]) { + renderWindow(window, pMonitor, time, true, mode); + } } if (SCALE)