File indexing completed on 2024-05-26 05:33:26

0001 /*
0002     KWin - the KDE window manager
0003     This file is part of the KDE project.
0004 
0005     SPDX-FileCopyrightText: 2007 Philip Falkner <philip.falkner@gmail.com>
0006     SPDX-FileCopyrightText: 2009 Martin Gräßlin <mgraesslin@kde.org>
0007     SPDX-FileCopyrightText: 2018 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
0008 
0009     SPDX-License-Identifier: GPL-2.0-or-later
0010 */
0011 
0012 #pragma once
0013 
0014 // kwineffects
0015 #include "effect/effect.h"
0016 #include "effect/effectwindow.h"
0017 #include "effect/timeline.h"
0018 
0019 namespace KWin
0020 {
0021 
0022 class SheetEffect : public Effect
0023 {
0024     Q_OBJECT
0025     Q_PROPERTY(int duration READ duration)
0026 
0027 public:
0028     SheetEffect();
0029 
0030     void reconfigure(ReconfigureFlags flags) override;
0031 
0032     void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override;
0033     void prePaintWindow(EffectWindow *w, WindowPrePaintData &data, std::chrono::milliseconds presentTime) override;
0034     void paintWindow(const RenderTarget &renderTarget, const RenderViewport &viewport, EffectWindow *w, int mask, QRegion region, WindowPaintData &data) override;
0035     void postPaintWindow(EffectWindow *w) override;
0036 
0037     bool isActive() const override;
0038     int requestedEffectChainPosition() const override;
0039 
0040     static bool supported();
0041 
0042     int duration() const;
0043 
0044 private Q_SLOTS:
0045     void slotWindowAdded(EffectWindow *w);
0046     void slotWindowClosed(EffectWindow *w);
0047 
0048 private:
0049     bool isSheetWindow(EffectWindow *w) const;
0050 
0051 private:
0052     std::chrono::milliseconds m_duration;
0053 
0054     struct Animation
0055     {
0056         EffectWindowDeletedRef deletedRef;
0057         TimeLine timeLine;
0058         int parentY;
0059     };
0060 
0061     QHash<EffectWindow *, Animation> m_animations;
0062 };
0063 
0064 inline int SheetEffect::requestedEffectChainPosition() const
0065 {
0066     return 60;
0067 }
0068 
0069 inline int SheetEffect::duration() const
0070 {
0071     return m_duration.count();
0072 }
0073 
0074 } // namespace KWin