animation: fix slide/slidevert to accept params (#11574)

This commit is contained in:
0xFMD 2025-09-06 20:24:17 +03:00 committed by GitHub
parent 4e785d12a9
commit 56dd1124ab
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 20 deletions

View file

@ -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) {