Commit 30954506 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii

[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
parent 709b7c2c
......@@ -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;
}
......
......@@ -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;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment