From 900f242a39d670d0c55622d9a015fdcc1e27c930 Mon Sep 17 00:00:00 2001 From: Vlad Zagorodniy Date: Wed, 24 Oct 2018 23:25:00 +0300 Subject: [PATCH] [effects/squash] Try to reverse previous active animations Summary: If a window is unminimized and the minimize animation is still active, don't cancel the latter and start a new animation. Instead, try to reverse already active animation and if that attempt failed, start a new animation. This results in more smoother animations. Reviewers: #kwin, davidedmundson Reviewed By: #kwin, davidedmundson Subscribers: kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D16451 --- effects/squash/package/contents/code/main.js | 22 ++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/effects/squash/package/contents/code/main.js b/effects/squash/package/contents/code/main.js index c2b822d148..a7ced7bb88 100644 --- a/effects/squash/package/contents/code/main.js +++ b/effects/squash/package/contents/code/main.js @@ -37,11 +37,20 @@ var squashEffect = { } if (window.unminimizeAnimation) { - // TODO: Try to reverse it instead. + if (redirect(window.unminimizeAnimation, Effect.Backward)) { + return; + } cancel(window.unminimizeAnimation); delete window.unminimizeAnimation; } + if (window.minimizeAnimation) { + if (redirect(window.minimizeAnimation, Effect.Forward)) { + return; + } + cancel(window.minimizeAnimation); + } + var windowRect = window.geometry; window.minimizeAnimation = animate({ @@ -94,11 +103,20 @@ var squashEffect = { } if (window.minimizeAnimation) { - // TODO: Try to reverse it instead. + if (redirect(window.minimizeAnimation, Effect.Backward)) { + return; + } cancel(window.minimizeAnimation); delete window.minimizeAnimation; } + if (window.unminimizeAnimation) { + if (redirect(window.unminimizeAnimation, Effect.Forward)) { + return; + } + cancel(window.unminimizeAnimation); + } + var windowRect = window.geometry; window.unminimizeAnimation = animate({