summaryrefslogtreecommitdiff
path: root/src/managers/animation/DesktopAnimationManager.cpp
diff options
context:
space:
mode:
author0xFMD <30713087+0xFMD@users.noreply.github.com>2025-09-06 20:24:17 +0300
committerGitHub <noreply@github.com>2025-09-06 19:24:17 +0200
commit56dd1124ab30dbc949b1f76e9dc6bbc9c74ef853 (patch)
treec368d20b9b04fa57e4a0fb6562f96e3166375b89 /src/managers/animation/DesktopAnimationManager.cpp
parent4e785d12a91117cd5b255052799d1a051d9976c0 (diff)
animation: fix slide/slidevert to accept params (#11574)
Diffstat (limited to 'src/managers/animation/DesktopAnimationManager.cpp')
-rw-r--r--src/managers/animation/DesktopAnimationManager.cpp33
1 files changed, 14 insertions, 19 deletions
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<Hyprlang::INT>("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) {