[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/D14088icc-effect-5.14.5
parent
2d1afb809c
commit
4e1e22c76d
|
@ -405,20 +405,21 @@ void SlidingPopupsEffect::slotPropertyNotify(EffectWindow* w, long a)
|
||||||
void SlidingPopupsEffect::setupAnimData(EffectWindow *w)
|
void SlidingPopupsEffect::setupAnimData(EffectWindow *w)
|
||||||
{
|
{
|
||||||
const QRect screenRect = effects->clientArea(FullScreenArea, w->screen(), effects->currentDesktop());
|
const QRect screenRect = effects->clientArea(FullScreenArea, w->screen(), effects->currentDesktop());
|
||||||
|
const QRect windowGeo = w->geometry();
|
||||||
if (mWindowsData[w].start == -1) {
|
if (mWindowsData[w].start == -1) {
|
||||||
switch (mWindowsData[w].from) {
|
switch (mWindowsData[w].from) {
|
||||||
case West:
|
case West:
|
||||||
mWindowsData[w].start = qMax(w->x() - screenRect.x(), 0);
|
mWindowsData[w].start = qMax(windowGeo.left() - screenRect.left(), 0);
|
||||||
break;
|
break;
|
||||||
case North:
|
case North:
|
||||||
mWindowsData[w].start = qMax(w->y() - screenRect.y(), 0);
|
mWindowsData[w].start = qMax(windowGeo.top() - screenRect.top(), 0);
|
||||||
break;
|
break;
|
||||||
case East:
|
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;
|
break;
|
||||||
case South:
|
case South:
|
||||||
default:
|
default:
|
||||||
mWindowsData[w].start = qMax(screenRect.y() + screenRect.height() - (w->y() + w->height()), 0);
|
mWindowsData[w].start = qMax(screenRect.bottom() - windowGeo.bottom(), 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -426,20 +427,20 @@ void SlidingPopupsEffect::setupAnimData(EffectWindow *w)
|
||||||
int difference = 0;
|
int difference = 0;
|
||||||
switch (mWindowsData[w].from) {
|
switch (mWindowsData[w].from) {
|
||||||
case West:
|
case West:
|
||||||
difference = w->x() - screenRect.x();
|
mWindowsData[w].start = qMax(windowGeo.left() - screenRect.left(), mWindowsData[w].start);
|
||||||
break;
|
break;
|
||||||
case North:
|
case North:
|
||||||
difference = w->y() - screenRect.y();
|
mWindowsData[w].start = qMax(windowGeo.top() - screenRect.top(), mWindowsData[w].start);
|
||||||
break;
|
break;
|
||||||
case East:
|
case East:
|
||||||
difference = w->x() + w->width() - (screenRect.x() + screenRect.width());
|
mWindowsData[w].start = qMax(screenRect.right() - windowGeo.right(), mWindowsData[w].start);
|
||||||
break;
|
break;
|
||||||
case South:
|
case South:
|
||||||
default:
|
default:
|
||||||
difference = w->y() + w->height() - (screenRect.y() + screenRect.height());
|
mWindowsData[w].start = qMax(screenRect.bottom() - windowGeo.bottom(), mWindowsData[w].start);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
mWindowsData[w].start = qMax<int>(mWindowsData[w].start, difference);
|
|
||||||
// Grab the window, so other windowClosed effects will ignore it
|
// Grab the window, so other windowClosed effects will ignore it
|
||||||
w->setData(WindowClosedGrabRole, QVariant::fromValue(static_cast<void*>(this)));
|
w->setData(WindowClosedGrabRole, QVariant::fromValue(static_cast<void*>(this)));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue