File indexing completed on 2024-11-10 04:57:10
0001 /* 0002 KWin - the KDE window manager 0003 This file is part of the KDE project. 0004 0005 SPDX-FileCopyrightText: 2009 Marco Martin notmart @gmail.com 0006 SPDX-FileCopyrightText: 2018 Vlad Zahorodnii <vlad.zahorodnii@kde.org> 0007 0008 SPDX-License-Identifier: GPL-2.0-or-later 0009 */ 0010 0011 #pragma once 0012 0013 // Include with base class for effects. 0014 #include "effect/effect.h" 0015 #include "effect/effectwindow.h" 0016 #include "effect/timeline.h" 0017 0018 namespace KWin 0019 { 0020 0021 class SlideManagerInterface; 0022 0023 class SlidingPopupsEffect : public Effect 0024 { 0025 Q_OBJECT 0026 Q_PROPERTY(int slideInDuration READ slideInDuration) 0027 Q_PROPERTY(int slideOutDuration READ slideOutDuration) 0028 0029 public: 0030 SlidingPopupsEffect(); 0031 ~SlidingPopupsEffect() override; 0032 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 void reconfigure(ReconfigureFlags flags) override; 0037 bool isActive() const override; 0038 0039 int requestedEffectChainPosition() const override 0040 { 0041 return 40; 0042 } 0043 0044 static bool supported(); 0045 0046 int slideInDuration() const; 0047 int slideOutDuration() const; 0048 0049 bool eventFilter(QObject *watched, QEvent *event) override; 0050 0051 private Q_SLOTS: 0052 void slotWindowAdded(EffectWindow *w); 0053 void slotWindowClosed(EffectWindow *w); 0054 void slotWindowDeleted(EffectWindow *w); 0055 void slotPropertyNotify(EffectWindow *w, long atom); 0056 void slotWaylandSlideOnShowChanged(EffectWindow *w); 0057 void slotWindowFrameGeometryChanged(EffectWindow *w, const QRectF &); 0058 0059 void slideIn(EffectWindow *w); 0060 void slideOut(EffectWindow *w); 0061 void stopAnimations(); 0062 0063 private: 0064 void setupAnimData(EffectWindow *w); 0065 void setupInternalWindowSlide(EffectWindow *w); 0066 void setupSlideData(EffectWindow *w); 0067 void setupInputPanelSlide(); 0068 0069 static SlideManagerInterface *s_slideManager; 0070 static QTimer *s_slideManagerRemoveTimer; 0071 long m_atom = 0; 0072 0073 int m_slideLength; 0074 std::chrono::milliseconds m_slideInDuration; 0075 std::chrono::milliseconds m_slideOutDuration; 0076 0077 enum class AnimationKind { 0078 In, 0079 Out 0080 }; 0081 0082 struct Animation 0083 { 0084 EffectWindowDeletedRef deletedRef; 0085 EffectWindowVisibleRef visibleRef; 0086 AnimationKind kind; 0087 TimeLine timeLine; 0088 }; 0089 QHash<EffectWindow *, Animation> m_animations; 0090 0091 enum class Location { 0092 Left, 0093 Top, 0094 Right, 0095 Bottom 0096 }; 0097 0098 struct AnimationData 0099 { 0100 int offset; 0101 Location location; 0102 std::chrono::milliseconds slideInDuration; 0103 std::chrono::milliseconds slideOutDuration; 0104 int slideLength; 0105 }; 0106 QHash<const EffectWindow *, AnimationData> m_animationsData; 0107 }; 0108 0109 inline int SlidingPopupsEffect::slideInDuration() const 0110 { 0111 return m_slideInDuration.count(); 0112 } 0113 0114 inline int SlidingPopupsEffect::slideOutDuration() const 0115 { 0116 return m_slideOutDuration.count(); 0117 } 0118 0119 } // namespace