From 0c69ce50aca554446004d85ea984164c89e1eb91 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Tue, 3 May 2022 09:31:30 +0300 Subject: [PATCH] effects/slide: Fix panels losing blurred background when gesture is active At the moment, if user switches between virtual desktops using a gesture, panels will loose blurred background because WindowForceBlurRole is not set. This change refactors setup code so the slide effect always forces blur and background contrast when sliding between virtual desktops using a gesture or animation. --- src/effects/slide/slide.cpp | 48 ++++++++++++++++++++----------------- src/effects/slide/slide.h | 1 + 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/src/effects/slide/slide.cpp b/src/effects/slide/slide.cpp index 957121aa8d..c797ff5ea8 100644 --- a/src/effects/slide/slide.cpp +++ b/src/effects/slide/slide.cpp @@ -345,28 +345,17 @@ void SlideEffect::startAnimation(int old, int current, EffectWindow *movingWindo { Q_UNUSED(old) - m_movingWindow = movingWindow; - - const bool wrap = effects->optionRollOverDesktops(); - - // Handle stacking order - const auto windows = effects->stackingOrder(); - for (EffectWindow *w : windows) { - if (shouldElevate(w)) { - effects->setElevatedWindow(w, true); - m_elevatedWindows << w; - } - w->setData(WindowForceBackgroundContrastRole, QVariant(true)); - w->setData(WindowForceBlurRole, QVariant(true)); + if (m_state == State::Inactive) { + prepareSwitching(); } - // Set up animation m_state = State::ActiveAnimation; + m_movingWindow = movingWindow; m_timeLine.reset(); m_startPos = m_currentPosition; m_endPos = effects->desktopGridCoords(current); - if (wrap) { + if (effects->optionRollOverDesktops()) { optimizePath(); } @@ -388,6 +377,19 @@ void SlideEffect::startAnimation(int old, int current, EffectWindow *movingWindo effects->addRepaintFull(); } +void SlideEffect::prepareSwitching() +{ + const auto windows = effects->stackingOrder(); + for (EffectWindow *w : windows) { + if (shouldElevate(w)) { + effects->setElevatedWindow(w, true); + m_elevatedWindows << w; + } + w->setData(WindowForceBackgroundContrastRole, QVariant(true)); + w->setData(WindowForceBlurRole, QVariant(true)); + } +} + void SlideEffect::finishedSwitching() { if (m_state == State::Inactive) { @@ -428,17 +430,19 @@ void SlideEffect::desktopChanging(uint old, QPointF desktopOffset, EffectWindow return; } + if (m_state == State::Inactive) { + prepareSwitching(); + } + m_state = State::ActiveGesture; m_movingWindow = with; - const bool wrap = effects->optionRollOverDesktops(); - // Find desktop position based on animationDelta QPoint gridPos = effects->desktopGridCoords(old); m_currentPosition.setX(gridPos.x() + desktopOffset.x()); m_currentPosition.setY(gridPos.y() + desktopOffset.y()); - if (wrap) { + if (effects->optionRollOverDesktops()) { m_currentPosition = forcePositivePosition(m_currentPosition); } else { m_currentPosition = moveInsideDesktopGrid(m_currentPosition); @@ -450,11 +454,11 @@ void SlideEffect::desktopChanging(uint old, QPointF desktopOffset, EffectWindow void SlideEffect::desktopChangingCancelled() { - if (effects->hasActiveFullScreenEffect() && effects->activeFullScreenEffect() != this) { - return; + // If the fingers have been lifted and the current desktop didn't change, start animation + // to move back to the original virtual desktop. + if (effects->activeFullScreenEffect() == this) { + startAnimation(effects->currentDesktop(), effects->currentDesktop(), nullptr); } - - startAnimation(effects->currentDesktop(), effects->currentDesktop(), nullptr); } QPointF SlideEffect::moveInsideDesktopGrid(QPointF p) diff --git a/src/effects/slide/slide.h b/src/effects/slide/slide.h index 3452beeb00..71831d2a96 100644 --- a/src/effects/slide/slide.h +++ b/src/effects/slide/slide.h @@ -93,6 +93,7 @@ private: void optimizePath(); // Find the best path to target desktop void startAnimation(int old, int current, EffectWindow *movingWindow = nullptr); + void prepareSwitching(); void finishedSwitching(); private: