File indexing completed on 2024-11-10 04:56:58

0001 /*
0002     KWin - the KDE window manager
0003     This file is part of the KDE project.
0004 
0005     SPDX-FileCopyrightText: 2007 Lubos Lunak <l.lunak@kde.org>
0006 
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 
0010 #pragma once
0011 
0012 #include "effect/effectwindow.h"
0013 #include "effect/offscreeneffect.h"
0014 
0015 namespace KWin
0016 {
0017 
0018 struct FallApartAnimation
0019 {
0020     EffectWindowDeletedRef deletedRef;
0021     std::chrono::milliseconds lastPresentTime = std::chrono::milliseconds::zero();
0022     qreal progress = 0;
0023 };
0024 
0025 class FallApartEffect : public OffscreenEffect
0026 {
0027     Q_OBJECT
0028     Q_PROPERTY(int blockSize READ configuredBlockSize)
0029 public:
0030     FallApartEffect();
0031     void reconfigure(ReconfigureFlags) override;
0032     void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override;
0033     void prePaintWindow(EffectWindow *w, WindowPrePaintData &data, std::chrono::milliseconds presentTime) override;
0034     void postPaintScreen() override;
0035     bool isActive() const override;
0036 
0037     int requestedEffectChainPosition() const override
0038     {
0039         return 70;
0040     }
0041 
0042     // for properties
0043     int configuredBlockSize() const
0044     {
0045         return blockSize;
0046     }
0047 
0048     static bool supported();
0049 
0050 protected:
0051     void apply(EffectWindow *w, int mask, WindowPaintData &data, WindowQuadList &quads) override;
0052 
0053 public Q_SLOTS:
0054     void slotWindowClosed(KWin::EffectWindow *c);
0055     void slotWindowDataChanged(KWin::EffectWindow *w, int role);
0056 
0057 private:
0058     QHash<EffectWindow *, FallApartAnimation> windows;
0059     bool isRealWindow(EffectWindow *w);
0060     int blockSize;
0061 };
0062 
0063 } // namespace