From ca172e2082c26851d5526dbbe235aea892e2a2b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20K=C3=BCgler?= Date: Thu, 20 Feb 2014 14:10:18 +0100 Subject: [PATCH] Force backgroundcontrast during slidingpopup animations This fixes the sliding popups losing their contrast effect when animating, less flicker. In this patch, we temporarily force the contrast effect on, but only if it hasn't been explicitely disabled. As soon as the animation stops, the force flag is disabled again. For disappearing windows, we just set the flag in the same way, but skip over the bookkeeping, since the window is going to be deleted, anyway. REVIEW:115902 --- effects/slidingpopups/slidingpopups.cpp | 13 +++++++++++++ effects/slidingpopups/slidingpopups.h | 5 +++++ 2 files changed, 18 insertions(+) diff --git a/effects/slidingpopups/slidingpopups.cpp b/effects/slidingpopups/slidingpopups.cpp index 4f0a9ea11d..99c3bfe732 100644 --- a/effects/slidingpopups/slidingpopups.cpp +++ b/effects/slidingpopups/slidingpopups.cpp @@ -85,6 +85,11 @@ void SlidingPopupsEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& da } else { delete mAppearingWindows.take(w); w->setData(WindowForceBlurRole, false); + if (m_backgroundContrastForced.contains(w) && w->hasAlpha() && + w->data(WindowForceBackgroundContrastRole).toBool()) { + w->setData(WindowForceBackgroundContrastRole, QVariant()); + m_backgroundContrastForced.removeAll(w); + } } } else if (mDisappearingWindows.contains(w)) { @@ -255,6 +260,10 @@ void SlidingPopupsEffect::slotWindowAdded(EffectWindow *w) { slotPropertyNotify(w, mAtom); if (w->isOnCurrentDesktop() && mWindowsData.contains(w)) { + if (!w->data(WindowForceBackgroundContrastRole).isValid() && w->hasAlpha()) { + w->setData(WindowForceBackgroundContrastRole, QVariant(true)); + m_backgroundContrastForced.append(w); + } mAppearingWindows.insert(w, new QTimeLine(mWindowsData[ w ].fadeInDuration, this)); mAppearingWindows[ w ]->setCurveShape(QTimeLine::EaseInOutCurve); @@ -278,9 +287,13 @@ void SlidingPopupsEffect::slotWindowClosed(EffectWindow* w) // Tell other windowClosed() effects to ignore this window w->setData(WindowClosedGrabRole, QVariant::fromValue(static_cast(this))); w->setData(WindowForceBlurRole, true); + if (!w->data(WindowForceBackgroundContrastRole).isValid() && w->hasAlpha()) { + w->setData(WindowForceBackgroundContrastRole, QVariant(true)); + } w->addRepaintFull(); } + m_backgroundContrastForced.removeAll(w); } void SlidingPopupsEffect::slotWindowDeleted(EffectWindow* w) diff --git a/effects/slidingpopups/slidingpopups.h b/effects/slidingpopups/slidingpopups.h index f66e42ec42..77f0103b49 100644 --- a/effects/slidingpopups/slidingpopups.h +++ b/effects/slidingpopups/slidingpopups.h @@ -74,6 +74,11 @@ private: int slideLength; }; long mAtom; + + // This list is only for appearing windows: we remember that we've enabled the + // WindowBackgroundContrastForcedRole flag, so we can remove it later. + // It doesn't matter for disappearing windows, they'll be deleted anyway. + QList< const EffectWindow* > m_backgroundContrastForced; QHash< const EffectWindow*, QTimeLine* > mAppearingWindows; QHash< const EffectWindow*, QTimeLine* > mDisappearingWindows; QHash< const EffectWindow*, Data > mWindowsData;