From 56dd1124ab30dbc949b1f76e9dc6bbc9c74ef853 Mon Sep 17 00:00:00 2001 From: 0xFMD <30713087+0xFMD@users.noreply.github.com> Date: Sat, 6 Sep 2025 20:24:17 +0300 Subject: [PATCH] animation: fix slide/slidevert to accept params (#11574) --- src/managers/animation/AnimationManager.cpp | 2 +- .../animation/DesktopAnimationManager.cpp | 33 ++++++++----------- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/src/managers/animation/AnimationManager.cpp b/src/managers/animation/AnimationManager.cpp index 6675216a..f38f4ccf 100644 --- a/src/managers/animation/AnimationManager.cpp +++ b/src/managers/animation/AnimationManager.cpp @@ -300,7 +300,7 @@ std::string CHyprAnimationManager::styleValidInConfigVar(const std::string& conf } else if (config.starts_with("workspaces") || config.starts_with("specialWorkspace")) { if (style == "slide" || style == "slidevert" || style == "fade") return ""; - else if (style.starts_with("slidefade")) { + else if (style.starts_with("slide")) { // try parsing float movePerc = 0.f; if (style.find('%') != std::string::npos) { diff --git a/src/managers/animation/DesktopAnimationManager.cpp b/src/managers/animation/DesktopAnimationManager.cpp index e55a0439..d1ddd8f5 100644 --- a/src/managers/animation/DesktopAnimationManager.cpp +++ b/src/managers/animation/DesktopAnimationManager.cpp @@ -237,9 +237,10 @@ void CDesktopAnimationManager::startAnimation(PHLWORKSPACE ws, eAnimationType ty ws->m_alpha->setConfig(g_pConfigManager->getAnimationPropertyConfig(ANIMNAME)); ws->m_renderOffset->setConfig(g_pConfigManager->getAnimationPropertyConfig(ANIMNAME)); } - - const auto ANIMSTYLE = ws->m_alpha->getStyle(); static auto PWORKSPACEGAP = CConfigValue("general:gaps_workspaces"); + const auto PMONITOR = ws->m_monitor.lock(); + const auto ANIMSTYLE = ws->m_alpha->getStyle(); + float movePerc = 100.f; // set floating windows offset callbacks ws->m_renderOffset->setUpdateCallback([weak = PHLWORKSPACEREF{ws}](auto) { @@ -254,16 +255,14 @@ void CDesktopAnimationManager::startAnimation(PHLWORKSPACE ws, eAnimationType ty }; }); - if (ANIMSTYLE.starts_with("slidefade")) { - const auto PMONITOR = ws->m_monitor.lock(); - 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"); } + } - 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"); } - } + if (ANIMSTYLE.starts_with("slidefade")) { ws->m_alpha->setValueAndWarp(1.f); ws->m_renderOffset->setValueAndWarp(Vector2D(0, 0)); @@ -301,11 +300,8 @@ void CDesktopAnimationManager::startAnimation(PHLWORKSPACE ws, eAnimationType ty ws->m_alpha->setValueAndWarp(1.f); *ws->m_alpha = 0.f; } - } else if (ANIMSTYLE == "slidevert") { - // fallback is slide - const auto PMONITOR = ws->m_monitor.lock(); - const auto YDISTANCE = PMONITOR->m_size.y + *PWORKSPACEGAP; - + } else if (ANIMSTYLE.starts_with("slidevert")) { + const auto YDISTANCE = (PMONITOR->m_size.y + *PWORKSPACEGAP) * (movePerc / 100.f); ws->m_alpha->setValueAndWarp(1.f); // fix a bug, if switching from fade -> slide. if (IN) { @@ -314,11 +310,10 @@ void CDesktopAnimationManager::startAnimation(PHLWORKSPACE ws, eAnimationType ty } else { *ws->m_renderOffset = Vector2D(0.0, left ? -YDISTANCE : YDISTANCE); } + } else { // fallback is slide - const auto PMONITOR = ws->m_monitor.lock(); - const auto XDISTANCE = PMONITOR->m_size.x + *PWORKSPACEGAP; - + const auto XDISTANCE = (PMONITOR->m_size.x + *PWORKSPACEGAP) * (movePerc / 100.f); ws->m_alpha->setValueAndWarp(1.f); // fix a bug, if switching from fade -> slide. if (IN) {