From c2ffcfdc218c94fc93e1960a8760883eef4e4495 Mon Sep 17 00:00:00 2001 From: Vlad Zagorodniy Date: Fri, 5 Oct 2018 10:19:57 +0300 Subject: [PATCH] [effects/wobblywindows] Fix visual artifacts caused by maximize effect Summary: If one wants to drag a maximized window while he or she has enabled both the Wobbly Windows and the Maximize effect, visual artifacts can be shown. When the Maximize effect animates transition from maximize to restore, some parts of the window can overshoot repaint regions(because of wobbliness), leaving us with the visual artifacts. To fix that, we have to take into account current scale and translation when calculating dirty region in the Wobbly Windows effect. BUG: 370612 FIXED-IN: 5.14.1 Test Plan: When dragging maximized windows, there are no visual artifacts anymore. Reviewers: #kwin, davidedmundson Reviewed By: #kwin, davidedmundson Subscribers: abetts, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D15961 --- effects/wobblywindows/wobblywindows.cpp | 10 ++++++++-- effects/wobblywindows/wobblywindows.h | 5 ++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/effects/wobblywindows/wobblywindows.cpp b/effects/wobblywindows/wobblywindows.cpp index 63ba33c1e5..68ce56772b 100644 --- a/effects/wobblywindows/wobblywindows.cpp +++ b/effects/wobblywindows/wobblywindows.cpp @@ -326,8 +326,14 @@ void WobblyWindowsEffect::paintWindow(EffectWindow* w, int mask, QRegion region, right = qMax(right, data.quads[i].right()); bottom = qMax(bottom, data.quads[i].bottom()); } - m_updateRegion = m_updateRegion.united(QRect(w->x() + left, w->y() + top, - right - left + 2, bottom - top + 2)); + QRectF dirtyRect( + left * data.xScale() + w->x() + data.xTranslation(), + top * data.yScale() + w->y() + data.yTranslation(), + (right - left + 1.0) * data.xScale(), + (bottom - top + 1.0) * data.yScale()); + // Expand the dirty region by 1px to fix potential round/floor issues. + dirtyRect.adjust(-1.0, -1.0, 1.0, 1.0); + m_updateRegion = m_updateRegion.united(dirtyRect.toRect()); } // Call the next effect. diff --git a/effects/wobblywindows/wobblywindows.h b/effects/wobblywindows/wobblywindows.h index 33cc410080..284bd52aa4 100644 --- a/effects/wobblywindows/wobblywindows.h +++ b/effects/wobblywindows/wobblywindows.h @@ -54,7 +54,10 @@ public: virtual bool isActive() const; int requestedEffectChainPosition() const override { - return 45; + // Please notice that the Wobbly Windows effect has to be placed + // after the Maximize effect in the effect chain, otherwise there + // can be visual artifacts when dragging maximized windows.:wq + return 70; } // Wobbly model parameters