From c6b25627105a21f2338123f08dd4281bed17c320 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Mon, 4 Jul 2016 15:40:38 +0200 Subject: [PATCH] [effects] Adjust SlidingPopups to new windowShown and windowHidden signals Summary: With this change SlidingPopups is able to animate Wayland clients properly, though windowHidden does not yet work for OpenGL based windows (buffer seems to get lost somewhere). Reviewers: #kwin, #plasma_on_wayland Subscribers: plasma-devel, kwin Tags: #plasma_on_wayland, #kwin Differential Revision: https://phabricator.kde.org/D2085 --- effects/slidingpopups/slidingpopups.cpp | 43 ++++++++++++++++++++++--- effects/slidingpopups/slidingpopups.h | 1 + 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/effects/slidingpopups/slidingpopups.cpp b/effects/slidingpopups/slidingpopups.cpp index 3c22214625..44c55853a5 100644 --- a/effects/slidingpopups/slidingpopups.cpp +++ b/effects/slidingpopups/slidingpopups.cpp @@ -45,6 +45,8 @@ SlidingPopupsEffect::SlidingPopupsEffect() connect(effects, SIGNAL(windowClosed(KWin::EffectWindow*)), this, SLOT(slotWindowClosed(KWin::EffectWindow*))); connect(effects, SIGNAL(windowDeleted(KWin::EffectWindow*)), this, SLOT(slotWindowDeleted(KWin::EffectWindow*))); connect(effects, SIGNAL(propertyNotify(KWin::EffectWindow*,long)), this, SLOT(slotPropertyNotify(KWin::EffectWindow*,long))); + connect(effects, &EffectsHandler::windowShown, this, &SlidingPopupsEffect::startForShow); + connect(effects, &EffectsHandler::windowHidden, this, &SlidingPopupsEffect::slotWindowClosed); reconfigure(ReconfigureAll); } @@ -107,11 +109,15 @@ void SlidingPopupsEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& da if (progress != 1.0) { data.setTransformed(); - w->enablePainting(EffectWindow::PAINT_DISABLED_BY_DELETE); + w->enablePainting(EffectWindow::PAINT_DISABLED | EffectWindow::PAINT_DISABLED_BY_DELETE); } else { delete mDisappearingWindows.take(w); w->addRepaintFull(); - w->unrefWindow(); + if (w->isDeleted()) { + w->unrefWindow(); + } else { + w->unreferencePreviousWindowPixmap(); + } } } if (progress != 1.0) { @@ -191,7 +197,7 @@ void SlidingPopupsEffect::paintWindow(EffectWindow* w, int mask, QRegion region, if (mAppearingWindows.contains(w)) { appearing = true; animating = true; - } else if (mDisappearingWindows.contains(w) && w->isDeleted()) { + } else if (mDisappearingWindows.contains(w)) { appearing = false; animating = true; } @@ -278,11 +284,26 @@ void SlidingPopupsEffect::slotWindowAdded(EffectWindow *w) }); } + startForShow(w); +} + +void SlidingPopupsEffect::startForShow(EffectWindow *w) +{ if (w->isOnCurrentDesktop() && mWindowsData.contains(w)) { if (!w->data(WindowForceBackgroundContrastRole).isValid() && w->hasAlpha()) { w->setData(WindowForceBackgroundContrastRole, QVariant(true)); m_backgroundContrastForced.append(w); } + auto it = mDisappearingWindows.find(w); + if (it != mDisappearingWindows.end()) { + delete it.value(); + mDisappearingWindows.erase(it); + } + it = mAppearingWindows.find(w); + if (it != mAppearingWindows.end()) { + delete it.value(); + mAppearingWindows.erase(it); + } mAppearingWindows.insert(w, new QTimeLine(mWindowsData[ w ].fadeInDuration, this)); mAppearingWindows[ w ]->setCurveShape(QTimeLine::EaseInOutCurve); @@ -298,8 +319,20 @@ void SlidingPopupsEffect::slotWindowAdded(EffectWindow *w) void SlidingPopupsEffect::slotWindowClosed(EffectWindow* w) { if (w->isOnCurrentDesktop() && !w->isMinimized() && mWindowsData.contains(w)) { - w->refWindow(); - delete mAppearingWindows.take(w); + if (w->isDeleted()) { + w->refWindow(); + } else { + w->referencePreviousWindowPixmap(); + } + auto it = mAppearingWindows.find(w); + if (it != mAppearingWindows.end()) { + delete it.value(); + mAppearingWindows.erase(it); + } + // could be already running, better check + if (mDisappearingWindows.contains(w)) { + return; + } mDisappearingWindows.insert(w, new QTimeLine(mWindowsData[ w ].fadeOutDuration, this)); mDisappearingWindows[ w ]->setCurveShape(QTimeLine::EaseInOutCurve); diff --git a/effects/slidingpopups/slidingpopups.h b/effects/slidingpopups/slidingpopups.h index 4cde7cd084..ffa3622539 100644 --- a/effects/slidingpopups/slidingpopups.h +++ b/effects/slidingpopups/slidingpopups.h @@ -65,6 +65,7 @@ public Q_SLOTS: void slotWaylandSlideOnShowChanged(EffectWindow* w); private: void setupAnimData(EffectWindow *w); + void startForShow(EffectWindow *w); enum Position { West = 0,