From 20780c6f2144577bc2683c97568c50ed982a5109 Mon Sep 17 00:00:00 2001 From: Vlad Zagorodniy Date: Mon, 1 Jan 2018 17:07:41 +0200 Subject: [PATCH] [effects/slide] Handle moving clients Summary: Currently, slide effect doesn't handle a case when there is a moving client. This results in having window jumps. This commit fixes it by fixing position of the moving client during switching to another desktop. Test Plan: * send window one desktop to the left/right using shortcuts Reviewers: #kwin, #plasma, graesslin Reviewed By: #kwin, #plasma, graesslin Subscribers: graesslin, plasma-devel, kwin Tags: #plasma Differential Revision: https://phabricator.kde.org/D9487 --- effects/slide/slide.cpp | 26 ++++++++++++++++++-------- effects/slide/slide.h | 4 +++- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/effects/slide/slide.cpp b/effects/slide/slide.cpp index 37e2d7d34a..375721ed29 100644 --- a/effects/slide/slide.cpp +++ b/effects/slide/slide.cpp @@ -32,11 +32,10 @@ SlideEffect::SlideEffect() : slide(false) { initConfig(); - connect(effects, SIGNAL(desktopChanged(int,int)), this, SLOT(slotDesktopChanged(int,int))); + connect(effects, SIGNAL(desktopChanged(int,int,KWin::EffectWindow*)), + this, SLOT(slotDesktopChanged(int,int,KWin::EffectWindow*))); connect(effects, &EffectsHandler::windowAdded, this, &SlideEffect::windowAdded); - connect(effects, &EffectsHandler::windowDeleted, this, [this](EffectWindow *w) { - m_backgroundContrastForcedBefore.removeAll(w); - }); + connect(effects, &EffectsHandler::windowDeleted, this, &SlideEffect::windowDeleted); mTimeLine.setCurveShape(QTimeLine::EaseInOutCurve); reconfigure(ReconfigureAll); } @@ -72,6 +71,7 @@ void SlideEffect::prePaintScreen(ScreenPrePaintData& data, int time) } } m_backgroundContrastForcedBefore.clear(); + m_movingWindow = nullptr; slide = false; mTimeLine.setCurrentTime(0); effects->setActiveFullScreenEffect(NULL); @@ -82,7 +82,7 @@ void SlideEffect::prePaintScreen(ScreenPrePaintData& data, int time) void SlideEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time) { - if (slide) { + if (slide && w != m_movingWindow) { if (w->isOnAllDesktops()) { bool keep_above = w->keepAbove() || w->isDock(); if ((!slide_painting_sticky || keep_above) && @@ -182,8 +182,8 @@ void SlideEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data) void SlideEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) { if (slide) { - // don't move windows on all desktops (compensate screen transformation) - if (!w->isOnAllDesktops()) { // TODO also fix 'Workspace::movingClient' + // Do not move a window if it is on all desktops or being moved to another desktop. + if (!w->isOnAllDesktops() && w != m_movingWindow) { data += slide_painting_diff; } } @@ -205,7 +205,7 @@ QRect SlideEffect::desktopRect(int desktop) const return rect; } -void SlideEffect::slotDesktopChanged(int old, int current) +void SlideEffect::slotDesktopChanged(int old, int current, EffectWindow* with) { if (effects->activeFullScreenEffect() && effects->activeFullScreenEffect() != this) return; @@ -275,6 +275,9 @@ void SlideEffect::slotDesktopChanged(int old, int current) } effects->setActiveFullScreenEffect(this); } + + m_movingWindow = with; + effects->addRepaintFull(); } @@ -286,6 +289,13 @@ void SlideEffect::windowAdded(EffectWindow *w) } } +void SlideEffect::windowDeleted(EffectWindow *w) +{ + m_backgroundContrastForcedBefore.removeAll(w); + if (w == m_movingWindow) + m_movingWindow = nullptr; +} + bool SlideEffect::shouldForceBackgroundContrast(const EffectWindow *w) const { // Windows that are docks, kept above (such as panel popups), and do not diff --git a/effects/slide/slide.h b/effects/slide/slide.h index eb6b0147d1..7e972b99e5 100644 --- a/effects/slide/slide.h +++ b/effects/slide/slide.h @@ -50,10 +50,11 @@ public: static bool supported(); private Q_SLOTS: - void slotDesktopChanged(int old, int current); + void slotDesktopChanged(int old, int current, KWin::EffectWindow* with); private: void windowAdded(EffectWindow* w); + void windowDeleted(EffectWindow* w); bool shouldForceBackgroundContrast(const EffectWindow* w) const; QList< EffectWindow* > m_backgroundContrastForcedBefore; QRect desktopRect(int desktop) const; @@ -64,6 +65,7 @@ private: bool slide_painting_sticky; bool slide_painting_keep_above; QPoint slide_painting_diff; + EffectWindow* m_movingWindow = nullptr; };