From e8b45cce1168859e58fe98b45f8060052ed861a7 Mon Sep 17 00:00:00 2001 From: Vlad Zagorodniy Date: Tue, 7 May 2019 12:07:02 +0300 Subject: [PATCH] [effects/cubeslide] Cancel active animation when number of desktops has changed Summary: If a virtual desktop is removed, then desktopChanged will be followed by numberDesktopsChanged signal. In which case, we have to cancel the active animation because front_desktop might be no longer valid when it's time to perform compositing. BUG: 406452 Reviewers: #kwin, davidedmundson Reviewed By: #kwin, davidedmundson Subscribers: kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D21064 --- effects/cubeslide/cubeslide.cpp | 24 ++++++++++++++++++++++++ effects/cubeslide/cubeslide.h | 1 + 2 files changed, 25 insertions(+) diff --git a/effects/cubeslide/cubeslide.cpp b/effects/cubeslide/cubeslide.cpp index 01dd122250..f4725e2915 100644 --- a/effects/cubeslide/cubeslide.cpp +++ b/effects/cubeslide/cubeslide.cpp @@ -49,6 +49,8 @@ CubeSlideEffect::CubeSlideEffect() this, &CubeSlideEffect::slotWindowStepUserMovedResized); connect(effects, &EffectsHandler::windowFinishUserMovedResized, this, &CubeSlideEffect::slotWindowFinishUserMovedResized); + connect(effects, &EffectsHandler::numberDesktopsChanged, + this, &CubeSlideEffect::slotNumberDesktopsChanged); reconfigure(ReconfigureAll); } @@ -644,4 +646,26 @@ bool CubeSlideEffect::isActive() const return !slideRotations.isEmpty(); } +void CubeSlideEffect::slotNumberDesktopsChanged() +{ + // This effect animates only aftermaths of desktop switching. There is no any + // way to reference removed desktops for animation purposes. So our the best + // shot is just to do nothing. It doesn't look nice and we probaby have to + // find more proper way to handle this case. + + if (!isActive()) { + return; + } + + for (EffectWindow *w : staticWindows) { + w->setData(WindowForceBlurRole, QVariant()); + w->setData(WindowForceBackgroundContrastRole, QVariant()); + } + + slideRotations.clear(); + staticWindows.clear(); + + effects->setActiveFullScreenEffect(nullptr); +} + } // namespace diff --git a/effects/cubeslide/cubeslide.h b/effects/cubeslide/cubeslide.h index 9fac0dad7d..f05da0aaf4 100644 --- a/effects/cubeslide/cubeslide.h +++ b/effects/cubeslide/cubeslide.h @@ -78,6 +78,7 @@ private Q_SLOTS: void slotDesktopChanged(int old, int current, EffectWindow* w); void slotWindowStepUserMovedResized(KWin::EffectWindow *w); void slotWindowFinishUserMovedResized(KWin::EffectWindow *w); + void slotNumberDesktopsChanged(); private: enum RotationDirection {