[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
This commit is contained in:
Vlad Zagorodniy 2018-07-03 12:56:21 +03:00
parent 709b7c2c58
commit 30954506d3
2 changed files with 11 additions and 12 deletions

View file

@ -74,14 +74,15 @@ void KscreenEffect::reconfigure(ReconfigureFlags flags)
Q_UNUSED(flags)
KscreenConfig::self()->read();
m_timeLine.setDuration(animationTime<KscreenConfig>(250));
m_timeLine.setDuration(
std::chrono::milliseconds(animationTime<KscreenConfig>(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;
}

View file

@ -21,8 +21,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define KWIN_KSCREEN_H
#include <kwineffects.h>
// Qt
#include <QTimeLine>
namespace KWin
{
@ -58,7 +56,7 @@ private:
StateFadedOut,
StateFadingIn
};
QTimeLine m_timeLine;
TimeLine m_timeLine;
FadeOutState m_state;
xcb_atom_t m_atom;
};