File indexing completed on 2025-12-07 12:25:07

0001 /*
0002     KWin - the KDE window manager
0003     This file is part of the KDE project.
0004 
0005     SPDX-FileCopyrightText: 2022 David Edmundson <davidedmundson@kde.org>
0006 
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 #pragma once
0010 #include <chrono>
0011 #include <kwinoffscreeneffect.h>
0012 #include <kwineffects.h>
0013 
0014 namespace KWin
0015 {
0016 
0017 class BlendChanges : public CrossFadeEffect
0018 {
0019     Q_OBJECT
0020 
0021 public:
0022     BlendChanges();
0023     ~BlendChanges() override;
0024 
0025     static bool supported();
0026 
0027     // Effect interface
0028     void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override;
0029     void postPaintScreen() override;
0030     void paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data) override;
0031 
0032     bool isActive() const override;
0033 
0034     int requestedEffectChainPosition() const override
0035     {
0036         return 80;
0037     }
0038 
0039 public Q_SLOTS:
0040     /**
0041      * Called from DBus, this should be called before triggering any changes
0042      * delay (ms) refers to how long to keep the current frame before starting a crossfade
0043      * We should expect all clients to have repainted by the time this expires
0044      */
0045     void start(int delay = 300);
0046 
0047 private:
0048     TimeLine m_timeline;
0049     enum State {
0050         Off,
0051         ShowingCache,
0052         Blending
0053     };
0054     State m_state = Off;
0055 };
0056 
0057 } // namespace KWin