KWin
Loading...
Searching...
No Matches
blendchanges.cpp
Go to the documentation of this file.
1/*
2 KWin - the KDE window manager
3 This file is part of the KDE project.
4
5 SPDX-FileCopyrightText: 2022 David Edmundson <davidedmundson@kde.org>
6
7 SPDX-License-Identifier: GPL-2.0-or-later
8*/
9// own
10#include "blendchanges.h"
12#include "opengl/glutils.h"
13
14#include <QDBusConnection>
15#include <QTimer>
16
17namespace KWin
18{
21{
22 QDBusConnection::sessionBus().registerObject(QStringLiteral("/org/kde/KWin/BlendChanges"),
23 QStringLiteral("org.kde.KWin.BlendChanges"),
24 this,
25 QDBusConnection::ExportAllSlots);
26
27 m_timeline.setEasingCurve(QEasingCurve::InOutCubic);
28}
29
31
36
38{
39 int animationDuration = animationTime(400);
40
41 if (!supported() || m_state != Off) {
42 return;
43 }
45 return;
46 }
47
48 const QList<EffectWindow *> allWindows = effects->stackingOrder();
49 for (auto window : allWindows) {
50 if (!window->isFullScreen()) {
51 redirect(window);
52 }
53 }
54
55 QTimer::singleShot(delay, this, [this, animationDuration]() {
56 m_timeline.setDuration(std::chrono::milliseconds(animationDuration));
58 m_state = Blending;
59 });
60
61 m_state = ShowingCache;
62}
63
65{
66 return m_state != Off;
67}
68
70{
71 if (m_timeline.done()) {
72 m_timeline.reset();
73 m_state = Off;
74
75 const QList<EffectWindow *> allWindows = effects->stackingOrder();
76 for (auto window : allWindows) {
77 unredirect(window);
78 }
79 }
81}
82
83void BlendChanges::paintWindow(const RenderTarget &renderTarget, const RenderViewport &viewport, EffectWindow *w, int mask, QRegion region, WindowPaintData &data)
84{
85 data.setCrossFadeProgress(m_timeline.value());
86 effects->paintWindow(renderTarget, viewport, w, mask, region, data);
87}
88
89void BlendChanges::prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime)
90{
91 if (m_state == Off) {
92 return;
93 }
94 if (m_state == Blending) {
95 m_timeline.advance(presentTime);
96 }
97
98 effects->prePaintScreen(data, presentTime);
99}
100
101} // namespace KWin
102
103#include "moc_blendchanges.cpp"
void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override
bool isActive() const override
void paintWindow(const RenderTarget &renderTarget, const RenderViewport &viewport, EffectWindow *w, int mask, QRegion region, WindowPaintData &data) override
void postPaintScreen() override
~BlendChanges() override
static bool supported()
void start(int delay=300)
void unredirect(EffectWindow *window)
Representation of a window used by/for Effect classes.
bool animationsSupported() const
QList< EffectWindow * > stackingOrder
CompositingType compositingType
void paintWindow(const RenderTarget &renderTarget, const RenderViewport &viewport, EffectWindow *w, int mask, const QRegion &region, WindowPaintData &data)
void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime)
Q_SCRIPTABLE void addRepaintFull()
qreal value() const
Definition timeline.cpp:46
void advance(std::chrono::milliseconds timestamp)
Definition timeline.cpp:53
void setEasingCurve(const QEasingCurve &easingCurve)
Definition timeline.cpp:155
void setCrossFadeProgress(qreal factor)
Sets the cross fading factor to fade over with previously sized window. If 1.0 only the current windo...
Definition effect.cpp:304
@ OpenGLCompositing
Definition globals.h:37
EffectsHandler * effects