From 4e1e22c76d5bc98ff3350dfb64e04496c2a6ed99 Mon Sep 17 00:00:00 2001 From: Vlad Zagorodniy Date: Fri, 13 Jul 2018 10:08:29 +0300 Subject: [PATCH] [effects/slidingpopups] Simplify math in setupAnimData Summary: Also, this change fixes "possible bug" when sanitizing offset for East/South(Right/Bottom) location. QHash abuse will be fixed in the follow-up patches. Reviewers: #kwin, mart, davidedmundson Reviewed By: #kwin, davidedmundson Subscribers: davidedmundson, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D14088 --- effects/slidingpopups/slidingpopups.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/effects/slidingpopups/slidingpopups.cpp b/effects/slidingpopups/slidingpopups.cpp index 2229fcb06f..e0112fa5be 100644 --- a/effects/slidingpopups/slidingpopups.cpp +++ b/effects/slidingpopups/slidingpopups.cpp @@ -405,20 +405,21 @@ void SlidingPopupsEffect::slotPropertyNotify(EffectWindow* w, long a) void SlidingPopupsEffect::setupAnimData(EffectWindow *w) { const QRect screenRect = effects->clientArea(FullScreenArea, w->screen(), effects->currentDesktop()); + const QRect windowGeo = w->geometry(); if (mWindowsData[w].start == -1) { switch (mWindowsData[w].from) { case West: - mWindowsData[w].start = qMax(w->x() - screenRect.x(), 0); + mWindowsData[w].start = qMax(windowGeo.left() - screenRect.left(), 0); break; case North: - mWindowsData[w].start = qMax(w->y() - screenRect.y(), 0); + mWindowsData[w].start = qMax(windowGeo.top() - screenRect.top(), 0); break; case East: - mWindowsData[w].start = qMax(screenRect.x() + screenRect.width() - (w->x() + w->width()), 0); + mWindowsData[w].start = qMax(screenRect.right() - windowGeo.right(), 0); break; case South: default: - mWindowsData[w].start = qMax(screenRect.y() + screenRect.height() - (w->y() + w->height()), 0); + mWindowsData[w].start = qMax(screenRect.bottom() - windowGeo.bottom(), 0); break; } } @@ -426,20 +427,20 @@ void SlidingPopupsEffect::setupAnimData(EffectWindow *w) int difference = 0; switch (mWindowsData[w].from) { case West: - difference = w->x() - screenRect.x(); + mWindowsData[w].start = qMax(windowGeo.left() - screenRect.left(), mWindowsData[w].start); break; case North: - difference = w->y() - screenRect.y(); + mWindowsData[w].start = qMax(windowGeo.top() - screenRect.top(), mWindowsData[w].start); break; case East: - difference = w->x() + w->width() - (screenRect.x() + screenRect.width()); + mWindowsData[w].start = qMax(screenRect.right() - windowGeo.right(), mWindowsData[w].start); break; case South: default: - difference = w->y() + w->height() - (screenRect.y() + screenRect.height()); + mWindowsData[w].start = qMax(screenRect.bottom() - windowGeo.bottom(), mWindowsData[w].start); break; } - mWindowsData[w].start = qMax(mWindowsData[w].start, difference); + // Grab the window, so other windowClosed effects will ignore it w->setData(WindowClosedGrabRole, QVariant::fromValue(static_cast(this))); }