mirror of
https://github.com/hyprwm/Hyprland.git
synced 2026-02-05 10:25:44 +00:00
animation: fix slide/slidefade to accept forced direction (#11725)
This commit is contained in:
@ -241,6 +241,8 @@ void CDesktopAnimationManager::startAnimation(PHLWORKSPACE ws, eAnimationType ty
|
||||
const auto PMONITOR = ws->m_monitor.lock();
|
||||
const auto ANIMSTYLE = ws->m_alpha->getStyle();
|
||||
float movePerc = 100.f;
|
||||
// inverted for some reason. TODO: fix the cause
|
||||
bool vert = ANIMSTYLE.starts_with("slidevert") || ANIMSTYLE.starts_with("slidefadevert");
|
||||
|
||||
// set floating windows offset callbacks
|
||||
ws->m_renderOffset->setUpdateCallback([weak = PHLWORKSPACEREF{ws}](auto) {
|
||||
@ -255,10 +257,28 @@ void CDesktopAnimationManager::startAnimation(PHLWORKSPACE ws, eAnimationType ty
|
||||
};
|
||||
});
|
||||
|
||||
if (ANIMSTYLE.find('%') != std::string::npos) {
|
||||
CVarList args(ANIMSTYLE, 0, 's');
|
||||
if (args.size() > 1) {
|
||||
const auto ARG2 = args[1];
|
||||
if (ARG2 == "top") {
|
||||
left = false;
|
||||
vert = true;
|
||||
} else if (ARG2 == "bottom") {
|
||||
left = true;
|
||||
vert = true;
|
||||
} else if (ARG2 == "left") {
|
||||
left = false;
|
||||
vert = false;
|
||||
} else if (ARG2 == "right") {
|
||||
left = true;
|
||||
vert = false;
|
||||
}
|
||||
}
|
||||
|
||||
const auto percstr = args[args.size() - 1];
|
||||
if (percstr.ends_with('%')) {
|
||||
try {
|
||||
auto percstr = ANIMSTYLE.substr(ANIMSTYLE.find_last_of(' ') + 1);
|
||||
movePerc = std::stoi(percstr.substr(0, percstr.length() - 1));
|
||||
movePerc = std::stoi(percstr.substr(0, percstr.length() - 1));
|
||||
} catch (std::exception& e) { Debug::log(ERR, "Error in startAnim: invalid percentage"); }
|
||||
}
|
||||
|
||||
@ -267,7 +287,7 @@ void CDesktopAnimationManager::startAnimation(PHLWORKSPACE ws, eAnimationType ty
|
||||
ws->m_alpha->setValueAndWarp(1.f);
|
||||
ws->m_renderOffset->setValueAndWarp(Vector2D(0, 0));
|
||||
|
||||
if (ANIMSTYLE.starts_with("slidefadevert")) {
|
||||
if (vert) {
|
||||
if (IN) {
|
||||
ws->m_alpha->setValueAndWarp(0.f);
|
||||
ws->m_renderOffset->setValueAndWarp(Vector2D(0.0, (left ? PMONITOR->m_size.y : -PMONITOR->m_size.y) * (movePerc / 100.f)));
|
||||
@ -300,7 +320,7 @@ void CDesktopAnimationManager::startAnimation(PHLWORKSPACE ws, eAnimationType ty
|
||||
ws->m_alpha->setValueAndWarp(1.f);
|
||||
*ws->m_alpha = 0.f;
|
||||
}
|
||||
} else if (ANIMSTYLE.starts_with("slidevert")) {
|
||||
} else if (vert) {
|
||||
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.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user