From 30954506d3bd27753e88ca9dc4b236c765172b5f Mon Sep 17 00:00:00 2001 From: Vlad Zagorodniy Date: Tue, 3 Jul 2018 12:56:21 +0300 Subject: [PATCH] [effects/kscreen] Port to TimeLine Test Plan: Ran ```lang=sh xprop -root -f _KDE_KWIN_KSCREEN_SUPPORT 32c -set _KDE_KWIN_KSCREEN_SUPPORT 1 sleep 5 xprop -root -f _KDE_KWIN_KSCREEN_SUPPORT 32c -set _KDE_KWIN_KSCREEN_SUPPORT 3 ``` Reviewers: #kwin, davidedmundson Reviewed By: #kwin, davidedmundson Subscribers: kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D13865 --- effects/kscreen/kscreen.cpp | 19 ++++++++++--------- effects/kscreen/kscreen.h | 4 +--- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/effects/kscreen/kscreen.cpp b/effects/kscreen/kscreen.cpp index ee21ac5c20..d377fabcfd 100644 --- a/effects/kscreen/kscreen.cpp +++ b/effects/kscreen/kscreen.cpp @@ -74,14 +74,15 @@ void KscreenEffect::reconfigure(ReconfigureFlags flags) Q_UNUSED(flags) KscreenConfig::self()->read(); - m_timeLine.setDuration(animationTime(250)); + m_timeLine.setDuration( + std::chrono::milliseconds(animationTime(250))); } void KscreenEffect::prePaintScreen(ScreenPrePaintData &data, int time) { if (m_state == StateFadingIn || m_state == StateFadingOut) { - m_timeLine.setCurrentTime(m_timeLine.currentTime() + time); - if (m_timeLine.currentValue() >= 1.0) { + m_timeLine.update(std::chrono::milliseconds(time)); + if (m_timeLine.done()) { switchState(); } } @@ -108,16 +109,16 @@ void KscreenEffect::paintWindow(EffectWindow *w, int mask, QRegion region, Windo //fade to black and fully opaque switch (m_state) { case StateFadingOut: - data.setOpacity(data.opacity() + (1.0 - data.opacity()) * m_timeLine.currentValue()); - data.multiplyBrightness(1.0 - m_timeLine.currentValue()); + data.setOpacity(data.opacity() + (1.0 - data.opacity()) * m_timeLine.value()); + data.multiplyBrightness(1.0 - m_timeLine.value()); break; case StateFadedOut: data.multiplyOpacity(0.0); data.multiplyBrightness(0.0); break; case StateFadingIn: - data.setOpacity(data.opacity() + (1.0 - data.opacity()) * (1.0 - m_timeLine.currentValue())); - data.multiplyBrightness(m_timeLine.currentValue()); + data.setOpacity(data.opacity() + (1.0 - data.opacity()) * (1.0 - m_timeLine.value())); + data.multiplyBrightness(m_timeLine.value()); break; default: // no adjustment @@ -152,14 +153,14 @@ void KscreenEffect::propertyNotify(EffectWindow *window, long int atom) if (data[0] == 1) { // kscreen wants KWin to fade out all windows m_state = StateFadingOut; - m_timeLine.setCurrentTime(0); + m_timeLine.reset(); effects->addRepaintFull(); return; } if (data[0] == 3) { // kscreen wants KWin to fade in again m_state = StateFadingIn; - m_timeLine.setCurrentTime(0); + m_timeLine.reset(); effects->addRepaintFull(); return; } diff --git a/effects/kscreen/kscreen.h b/effects/kscreen/kscreen.h index b6b5c7a029..2f9dad1df3 100644 --- a/effects/kscreen/kscreen.h +++ b/effects/kscreen/kscreen.h @@ -21,8 +21,6 @@ along with this program. If not, see . #define KWIN_KSCREEN_H #include -// Qt -#include namespace KWin { @@ -58,7 +56,7 @@ private: StateFadedOut, StateFadingIn }; - QTimeLine m_timeLine; + TimeLine m_timeLine; FadeOutState m_state; xcb_atom_t m_atom; };