From 117d8d52625cb88592dcfdd4cfc07709a627b745 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Fri, 7 Feb 2014 15:18:45 +0100 Subject: [PATCH 1/4] 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; }; From 36f45fda87c971b7586a038678aa813b458fcde1 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Mon, 10 Feb 2014 17:59:16 +0100 Subject: [PATCH 2/4] base size in fonts --- effects/slidingpopups/slidingpopups.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/effects/slidingpopups/slidingpopups.cpp b/effects/slidingpopups/slidingpopups.cpp index 3a866c34b2..79e6091694 100644 --- a/effects/slidingpopups/slidingpopups.cpp +++ b/effects/slidingpopups/slidingpopups.cpp @@ -22,13 +22,15 @@ along with this program. If not, see . #include #include +#include namespace KWin { SlidingPopupsEffect::SlidingPopupsEffect() { - mSlideLength = 100; + mSlideLength = QFontMetrics(qApp->font()).height() * 8; + 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*))); @@ -45,7 +47,7 @@ void SlidingPopupsEffect::reconfigure(ReconfigureFlags flags) { Q_UNUSED(flags) KConfigGroup conf = effects->effectConfig(QStringLiteral("SlidingPopups")); - mFadeInTime = animationTime(conf, QStringLiteral("SlideInTime"), 250); + mFadeInTime = animationTime(conf, QStringLiteral("SlideInTime"), 150); mFadeOutTime = animationTime(conf, QStringLiteral("SlideOutTime"), 250); QHash< const EffectWindow*, QTimeLine* >::iterator it = mAppearingWindows.begin(); while (it != mAppearingWindows.end()) { @@ -106,7 +108,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) + mSlideLength * (appearing ? 1.0 - progress : progress); + const double splitPoint = geo.width() - (geo.x() + geo.width() - screenRect.x() - start) + qMin(geo.width(), mSlideLength) * (appearing ? 1.0 - progress : progress); data.quads = data.quads.splitAtX(splitPoint); WindowQuadList filtered; foreach (const WindowQuad &quad, data.quads) { @@ -118,7 +120,7 @@ void SlidingPopupsEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& da break; } case North: { - const double splitPoint = geo.height() - (geo.y() + geo.height() - screenRect.y() - start) + mSlideLength * (appearing ? 1.0 - progress : progress); + const double splitPoint = geo.height() - (geo.y() + geo.height() - screenRect.y() - start) + qMin(geo.height(), mSlideLength) * (appearing ? 1.0 - progress : progress); data.quads = data.quads.splitAtY(splitPoint); WindowQuadList filtered; foreach (const WindowQuad &quad, data.quads) { @@ -130,7 +132,7 @@ void SlidingPopupsEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& da break; } case East: { - const double splitPoint = screenRect.x() + screenRect.width() - geo.x() - start - mSlideLength * (appearing ? 1.0 - progress : progress); + const double splitPoint = screenRect.x() + screenRect.width() - geo.x() - start - qMin(geo.width(), mSlideLength) * (appearing ? 1.0 - progress : progress); data.quads = data.quads.splitAtX(splitPoint); WindowQuadList filtered; foreach (const WindowQuad &quad, data.quads) { @@ -143,7 +145,7 @@ void SlidingPopupsEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& da } case South: default: { - const double splitPoint = screenRect.y() + screenRect.height() - geo.y() - start - mSlideLength * (appearing ? 1.0 - progress : progress); + const double splitPoint = screenRect.y() + screenRect.height() - geo.y() - start - qMin(geo.height(), mSlideLength) * (appearing ? 1.0 - progress : progress); data.quads = data.quads.splitAtY(splitPoint); WindowQuadList filtered; foreach (const WindowQuad &quad, data.quads) { @@ -192,23 +194,23 @@ void SlidingPopupsEffect::paintWindow(EffectWindow* w, int mask, QRegion region, const QRect geo = w->expandedGeometry(); switch(mWindowsData[ w ].from) { case West: - data.translate(- mSlideLength * progress); + data.translate(- qMin(geo.width(), 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, - mSlideLength * progress); + data.translate(0.0, - qMin(geo.height(), 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(mSlideLength * progress); + data.translate(qMin(geo.width(), 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, mSlideLength * progress); + data.translate(0.0, qMin(geo.height(), mSlideLength) * progress); splitPoint = screenRect.y() + screenRect.height() - geo.y() - start; region = QRegion(geo.x(), geo.y(), geo.width(), splitPoint); } From 73b1bde2a379759983701da7192dd17100c8e040 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Thu, 13 Feb 2014 19:45:42 +0100 Subject: [PATCH 3/4] optional property for sliding distance if a sliding distance is given, it will be used instead of the default. if that distance is the whole popup size, don't fade --- effects/slidingpopups/slidingpopups.cpp | 51 ++++++++++++++++++++----- effects/slidingpopups/slidingpopups.h | 1 + 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/effects/slidingpopups/slidingpopups.cpp b/effects/slidingpopups/slidingpopups.cpp index 79e6091694..8dce46f59a 100644 --- a/effects/slidingpopups/slidingpopups.cpp +++ b/effects/slidingpopups/slidingpopups.cpp @@ -106,9 +106,16 @@ void SlidingPopupsEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& da const QRect screenRect = effects->clientArea(FullScreenArea, w->screen(), effects->currentDesktop()); const QRect geo = w->expandedGeometry(); // filter out window quads, but only if the window does not start from the edge + int slideLength; + if (mWindowsData[ w ].slideLength > 0) { + slideLength = mWindowsData[ w ].slideLength; + } else { + slideLength = mSlideLength; + } + switch(mWindowsData[ w ].from) { case West: { - const double splitPoint = geo.width() - (geo.x() + geo.width() - screenRect.x() - start) + qMin(geo.width(), mSlideLength) * (appearing ? 1.0 - progress : progress); + const double splitPoint = geo.width() - (geo.x() + geo.width() - screenRect.x() - start) + qMin(geo.width(), slideLength) * (appearing ? 1.0 - progress : progress); data.quads = data.quads.splitAtX(splitPoint); WindowQuadList filtered; foreach (const WindowQuad &quad, data.quads) { @@ -120,7 +127,7 @@ void SlidingPopupsEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& da break; } case North: { - const double splitPoint = geo.height() - (geo.y() + geo.height() - screenRect.y() - start) + qMin(geo.height(), mSlideLength) * (appearing ? 1.0 - progress : progress); + const double splitPoint = geo.height() - (geo.y() + geo.height() - screenRect.y() - start) + qMin(geo.height(), slideLength) * (appearing ? 1.0 - progress : progress); data.quads = data.quads.splitAtY(splitPoint); WindowQuadList filtered; foreach (const WindowQuad &quad, data.quads) { @@ -132,7 +139,7 @@ void SlidingPopupsEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& da break; } case East: { - const double splitPoint = screenRect.x() + screenRect.width() - geo.x() - start - qMin(geo.width(), mSlideLength) * (appearing ? 1.0 - progress : progress); + const double splitPoint = screenRect.x() + screenRect.width() - geo.x() - start - qMin(geo.width(), slideLength) * (appearing ? 1.0 - progress : progress); data.quads = data.quads.splitAtX(splitPoint); WindowQuadList filtered; foreach (const WindowQuad &quad, data.quads) { @@ -145,7 +152,7 @@ void SlidingPopupsEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& da } case South: default: { - const double splitPoint = screenRect.y() + screenRect.height() - geo.y() - start - qMin(geo.height(), mSlideLength) * (appearing ? 1.0 - progress : progress); + const double splitPoint = screenRect.y() + screenRect.height() - geo.y() - start - qMin(geo.height(), slideLength) * (appearing ? 1.0 - progress : progress); data.quads = data.quads.splitAtY(splitPoint); WindowQuadList filtered; foreach (const WindowQuad &quad, data.quads) { @@ -187,30 +194,47 @@ void SlidingPopupsEffect::paintWindow(EffectWindow* w, int mask, QRegion region, } const int start = mWindowsData[ w ].start; - data.setOpacity(1 - progress); + int slideLength; + if (mWindowsData[ w ].slideLength > 0) { + slideLength = mWindowsData[ w ].slideLength; + } else { + slideLength = mSlideLength; + } 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(- qMin(geo.width(), mSlideLength) * progress); + if (slideLength < geo.width()) { + data.setOpacity(1 - progress); + } + data.translate(- qMin(geo.width(), slideLength) * 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, - qMin(geo.height(), mSlideLength) * progress); + if (slideLength < geo.height()) { + data.setOpacity(1 - progress); + } + data.translate(0.0, - qMin(geo.height(), slideLength) * 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(qMin(geo.width(), mSlideLength) * progress); + if (slideLength < geo.width()) { + data.setOpacity(1 - progress); + } + data.translate(qMin(geo.width(), slideLength) * 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, qMin(geo.height(), mSlideLength) * progress); + if (slideLength < geo.width()) { + data.setOpacity(1 - progress); + } + data.translate(0.0, qMin(geo.height(), slideLength) * progress); splitPoint = screenRect.y() + screenRect.height() - geo.y() - start; region = QRegion(geo.x(), geo.y(), geo.width(), splitPoint); } @@ -286,12 +310,21 @@ void SlidingPopupsEffect::slotPropertyNotify(EffectWindow* w, long a) Data animData; animData.start = d[ 0 ]; animData.from = (Position)d[ 1 ]; + //custom duration if (data.length() >= (int)(sizeof(uint32_t) * 3)) { animData.fadeInDuration = d[2]; if (data.length() >= (int)(sizeof(uint32_t) * 4)) + //custom fadein animData.fadeOutDuration = d[3]; else + //custom fadeout animData.fadeOutDuration = d[2]; + + //do we want an actual slide? + if (data.length() >= (int)(sizeof(uint32_t) * 5)) + animData.slideLength = d[5]; + else + animData.slideLength = -1; } else { animData.fadeInDuration = animationTime(mFadeInTime); animData.fadeOutDuration = animationTime(mFadeOutTime); diff --git a/effects/slidingpopups/slidingpopups.h b/effects/slidingpopups/slidingpopups.h index bddd026451..f66e42ec42 100644 --- a/effects/slidingpopups/slidingpopups.h +++ b/effects/slidingpopups/slidingpopups.h @@ -71,6 +71,7 @@ private: Position from; int fadeInDuration; int fadeOutDuration; + int slideLength; }; long mAtom; QHash< const EffectWindow*, QTimeLine* > mAppearingWindows; From d7a2a3d31f1b647e0b7c90360c597d611ee280b3 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Fri, 14 Feb 2014 10:36:51 +0100 Subject: [PATCH 4/4] use multiplyOpacity() --- effects/slidingpopups/slidingpopups.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/effects/slidingpopups/slidingpopups.cpp b/effects/slidingpopups/slidingpopups.cpp index 8dce46f59a..fd697f0c62 100644 --- a/effects/slidingpopups/slidingpopups.cpp +++ b/effects/slidingpopups/slidingpopups.cpp @@ -207,7 +207,7 @@ void SlidingPopupsEffect::paintWindow(EffectWindow* w, int mask, QRegion region, switch(mWindowsData[ w ].from) { case West: if (slideLength < geo.width()) { - data.setOpacity(1 - progress); + data.multiplyOpacity(1 - progress); } data.translate(- qMin(geo.width(), slideLength) * progress); splitPoint = geo.width() - (geo.x() + geo.width() - screenRect.x() - start); @@ -215,7 +215,7 @@ void SlidingPopupsEffect::paintWindow(EffectWindow* w, int mask, QRegion region, break; case North: if (slideLength < geo.height()) { - data.setOpacity(1 - progress); + data.multiplyOpacity(1 - progress); } data.translate(0.0, - qMin(geo.height(), slideLength) * progress); splitPoint = geo.height() - (geo.y() + geo.height() - screenRect.y() - start); @@ -223,7 +223,7 @@ void SlidingPopupsEffect::paintWindow(EffectWindow* w, int mask, QRegion region, break; case East: if (slideLength < geo.width()) { - data.setOpacity(1 - progress); + data.multiplyOpacity(1 - progress); } data.translate(qMin(geo.width(), slideLength) * progress); splitPoint = screenRect.x() + screenRect.width() - geo.x() - start; @@ -232,7 +232,7 @@ void SlidingPopupsEffect::paintWindow(EffectWindow* w, int mask, QRegion region, case South: default: if (slideLength < geo.width()) { - data.setOpacity(1 - progress); + data.multiplyOpacity(1 - progress); } data.translate(0.0, qMin(geo.height(), slideLength) * progress); splitPoint = screenRect.y() + screenRect.height() - geo.y() - start; @@ -324,7 +324,7 @@ void SlidingPopupsEffect::slotPropertyNotify(EffectWindow* w, long a) if (data.length() >= (int)(sizeof(uint32_t) * 5)) animData.slideLength = d[5]; else - animData.slideLength = -1; + animData.slideLength = 0; } else { animData.fadeInDuration = animationTime(mFadeInTime); animData.fadeOutDuration = animationTime(mFadeOutTime);