From 117d8d52625cb88592dcfdd4cfc07709a627b745 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Fri, 7 Feb 2014 15:18:45 +0100 Subject: [PATCH] tweak sliding popup slide only a fixed amount of pixel and fade at the same time TODO: dpi independent --- effects/slidingpopups/slidingpopups.cpp | 19 +++++++++++-------- effects/slidingpopups/slidingpopups.h | 1 + 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/effects/slidingpopups/slidingpopups.cpp b/effects/slidingpopups/slidingpopups.cpp index 479a93a861..3a866c34b2 100644 --- a/effects/slidingpopups/slidingpopups.cpp +++ b/effects/slidingpopups/slidingpopups.cpp @@ -28,6 +28,7 @@ namespace KWin SlidingPopupsEffect::SlidingPopupsEffect() { + mSlideLength = 100; mAtom = effects->announceSupportProperty("_KDE_SLIDE", this); connect(effects, SIGNAL(windowAdded(KWin::EffectWindow*)), this, SLOT(slotWindowAdded(KWin::EffectWindow*))); connect(effects, SIGNAL(windowClosed(KWin::EffectWindow*)), this, SLOT(slotWindowClosed(KWin::EffectWindow*))); @@ -105,7 +106,7 @@ void SlidingPopupsEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& da // filter out window quads, but only if the window does not start from the edge switch(mWindowsData[ w ].from) { case West: { - const double splitPoint = geo.width() - (geo.x() + geo.width() - screenRect.x() - start) + geo.width() * (appearing ? 1.0 - progress : progress); + const double splitPoint = geo.width() - (geo.x() + geo.width() - screenRect.x() - start) + mSlideLength * (appearing ? 1.0 - progress : progress); data.quads = data.quads.splitAtX(splitPoint); WindowQuadList filtered; foreach (const WindowQuad &quad, data.quads) { @@ -117,7 +118,7 @@ void SlidingPopupsEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& da break; } case North: { - const double splitPoint = geo.height() - (geo.y() + geo.height() - screenRect.y() - start) + geo.height() * (appearing ? 1.0 - progress : progress); + const double splitPoint = geo.height() - (geo.y() + geo.height() - screenRect.y() - start) + mSlideLength * (appearing ? 1.0 - progress : progress); data.quads = data.quads.splitAtY(splitPoint); WindowQuadList filtered; foreach (const WindowQuad &quad, data.quads) { @@ -129,7 +130,7 @@ void SlidingPopupsEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& da break; } case East: { - const double splitPoint = screenRect.x() + screenRect.width() - geo.x() - start - geo.width() * (appearing ? 1.0 - progress : progress); + const double splitPoint = screenRect.x() + screenRect.width() - geo.x() - start - mSlideLength * (appearing ? 1.0 - progress : progress); data.quads = data.quads.splitAtX(splitPoint); WindowQuadList filtered; foreach (const WindowQuad &quad, data.quads) { @@ -142,7 +143,7 @@ void SlidingPopupsEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& da } case South: default: { - const double splitPoint = screenRect.y() + screenRect.height() - geo.y() - start - geo.height() * (appearing ? 1.0 - progress : progress); + const double splitPoint = screenRect.y() + screenRect.height() - geo.y() - start - mSlideLength * (appearing ? 1.0 - progress : progress); data.quads = data.quads.splitAtY(splitPoint); WindowQuadList filtered; foreach (const WindowQuad &quad, data.quads) { @@ -184,28 +185,30 @@ void SlidingPopupsEffect::paintWindow(EffectWindow* w, int mask, QRegion region, } const int start = mWindowsData[ w ].start; + data.setOpacity(1 - progress); + const QRect screenRect = effects->clientArea(FullScreenArea, w->screen(), w->desktop()); int splitPoint = 0; const QRect geo = w->expandedGeometry(); switch(mWindowsData[ w ].from) { case West: - data.translate(- geo.width() * progress); + data.translate(- mSlideLength * progress); splitPoint = geo.width() - (geo.x() + geo.width() - screenRect.x() - start); region = QRegion(geo.x() + splitPoint, geo.y(), geo.width() - splitPoint, geo.height()); break; case North: - data.translate(0.0, - geo.height() * progress); + data.translate(0.0, - mSlideLength * progress); splitPoint = geo.height() - (geo.y() + geo.height() - screenRect.y() - start); region = QRegion(geo.x(), geo.y() + splitPoint, geo.width(), geo.height() - splitPoint); break; case East: - data.translate(geo.width() * progress); + data.translate(mSlideLength * progress); splitPoint = screenRect.x() + screenRect.width() - geo.x() - start; region = QRegion(geo.x(), geo.y(), splitPoint, geo.height()); break; case South: default: - data.translate(0.0, geo.height() * progress); + data.translate(0.0, mSlideLength * progress); splitPoint = screenRect.y() + screenRect.height() - geo.y() - start; region = QRegion(geo.x(), geo.y(), geo.width(), splitPoint); } diff --git a/effects/slidingpopups/slidingpopups.h b/effects/slidingpopups/slidingpopups.h index ff21eebad4..bddd026451 100644 --- a/effects/slidingpopups/slidingpopups.h +++ b/effects/slidingpopups/slidingpopups.h @@ -76,6 +76,7 @@ private: QHash< const EffectWindow*, QTimeLine* > mAppearingWindows; QHash< const EffectWindow*, QTimeLine* > mDisappearingWindows; QHash< const EffectWindow*, Data > mWindowsData; + int mSlideLength; int mFadeInTime; int mFadeOutTime; };