KWin
Loading...
Searching...
No Matches
slidingpopups.h
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: 2009 Marco Martin notmart @gmail.com
6 SPDX-FileCopyrightText: 2018 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
7
8 SPDX-License-Identifier: GPL-2.0-or-later
9*/
10
11#pragma once
12
13// Include with base class for effects.
14#include "effect/effect.h"
15#include "effect/effectwindow.h"
16#include "effect/timeline.h"
17
18namespace KWin
19{
20
21class SlideManagerInterface;
22
24{
25 Q_OBJECT
26 Q_PROPERTY(int slideInDuration READ slideInDuration)
28
29public:
31 ~SlidingPopupsEffect() override;
32
33 void prePaintWindow(EffectWindow *w, WindowPrePaintData &data, std::chrono::milliseconds presentTime) override;
34 void paintWindow(const RenderTarget &renderTarget, const RenderViewport &viewport, EffectWindow *w, int mask, QRegion region, WindowPaintData &data) override;
35 void postPaintWindow(EffectWindow *w) override;
36 void reconfigure(ReconfigureFlags flags) override;
37 bool isActive() const override;
38
39 int requestedEffectChainPosition() const override
40 {
41 return 40;
42 }
43
44 static bool supported();
45
46 int slideInDuration() const;
47 int slideOutDuration() const;
48
49 bool eventFilter(QObject *watched, QEvent *event) override;
50
51private Q_SLOTS:
52 void slotWindowAdded(EffectWindow *w);
53 void slotWindowClosed(EffectWindow *w);
54 void slotWindowDeleted(EffectWindow *w);
55 void slotPropertyNotify(EffectWindow *w, long atom);
56 void slotWaylandSlideOnShowChanged(EffectWindow *w);
57 void slotWindowFrameGeometryChanged(EffectWindow *w, const QRectF &);
58
59 void slideIn(EffectWindow *w);
60 void slideOut(EffectWindow *w);
61 void stopAnimations();
62
63private:
64 void setupAnimData(EffectWindow *w);
65 void setupInternalWindowSlide(EffectWindow *w);
66 void setupSlideData(EffectWindow *w);
67 void setupInputPanelSlide();
68
69 static SlideManagerInterface *s_slideManager;
70 static QTimer *s_slideManagerRemoveTimer;
71 long m_atom = 0;
72
73 int m_slideLength;
74 std::chrono::milliseconds m_slideInDuration;
75 std::chrono::milliseconds m_slideOutDuration;
76
77 enum class AnimationKind {
78 In,
79 Out
80 };
81
82 struct Animation
83 {
84 EffectWindowDeletedRef deletedRef;
85 EffectWindowVisibleRef visibleRef;
86 AnimationKind kind;
87 TimeLine timeLine;
88 };
89 QHash<EffectWindow *, Animation> m_animations;
90
91 enum class Location {
92 Left,
93 Top,
94 Right,
95 Bottom
96 };
97
98 struct AnimationData
99 {
100 int offset;
101 Location location;
102 std::chrono::milliseconds slideInDuration;
103 std::chrono::milliseconds slideOutDuration;
104 int slideLength;
105 };
106 QHash<const EffectWindow *, AnimationData> m_animationsData;
107};
108
110{
111 return m_slideInDuration.count();
112}
113
115{
116 return m_slideOutDuration.count();
117}
118
119} // namespace
Base class for all KWin effects.
Definition effect.h:535
Representation of a window used by/for Effect classes.
void reconfigure(ReconfigureFlags flags) override
bool isActive() const override
void paintWindow(const RenderTarget &renderTarget, const RenderViewport &viewport, EffectWindow *w, int mask, QRegion region, WindowPaintData &data) override
void postPaintWindow(EffectWindow *w) override
bool eventFilter(QObject *watched, QEvent *event) override
void prePaintWindow(EffectWindow *w, WindowPrePaintData &data, std::chrono::milliseconds presentTime) override
int requestedEffectChainPosition() const override