Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 4e1e22c7 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii

[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
parent 2d1afb80
......@@ -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<int>(mWindowsData[w].start, difference);
// Grab the window, so other windowClosed effects will ignore it
w->setData(WindowClosedGrabRole, QVariant::fromValue(static_cast<void*>(this)));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment