KWin
Loading...
Searching...
No Matches
quickeffect.h
Go to the documentation of this file.
1/*
2 SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "core/output.h"
10#include "effect/effect.h"
12
13#include <QQmlComponent>
14
15namespace KWin
16{
17
18class QuickSceneEffect;
19class QuickSceneEffectPrivate;
20
29class KWIN_EXPORT QuickSceneView : public OffscreenQuickView
30{
31 Q_OBJECT
32 Q_PROPERTY(QuickSceneEffect *effect READ effect CONSTANT)
33 Q_PROPERTY(Output *screen READ screen CONSTANT)
34 Q_PROPERTY(QQuickItem *rootItem READ rootItem CONSTANT)
35
36public:
38 ~QuickSceneView() override;
39
40 QuickSceneEffect *effect() const;
41 Output *screen() const;
42
43 QQuickItem *rootItem() const;
44 void setRootItem(QQuickItem *item);
45
46 bool isDirty() const;
47 void markDirty();
48 void resetDirty();
49
50 static QuickSceneView *findView(QQuickItem *item);
51 static QuickSceneView *qmlAttachedProperties(QObject *object);
52
53public Q_SLOTS:
54 void scheduleRepaint();
55
57 QuickSceneEffect *m_effect;
58 Output *m_screen;
59 std::unique_ptr<QQuickItem> m_rootItem;
60 bool m_dirty = false;
61};
62
75class KWIN_EXPORT QuickSceneEffect : public Effect
76{
77 Q_OBJECT
78 Q_PROPERTY(QuickSceneView *activeView READ activeView NOTIFY activeViewChanged)
79 Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
80
81public:
82 explicit QuickSceneEffect(QObject *parent = nullptr);
83 ~QuickSceneEffect() override;
84
88 bool isRunning() const;
89
93 void setRunning(bool running);
94
95 QuickSceneView *activeView() const;
96
100 Q_INVOKABLE QuickSceneView *viewForScreen(Output *screen) const;
101
105 Q_INVOKABLE QuickSceneView *viewAt(const QPoint &pos) const;
106
111 Q_INVOKABLE KWin::QuickSceneView *getView(Qt::Edge edge);
112
116 Q_INVOKABLE void activateView(QuickSceneView *view);
117
121 QQmlComponent *delegate() const;
122 void setDelegate(QQmlComponent *delegate);
123
127 QUrl source() const;
128
138 void setSource(const QUrl &url);
139
140 bool eventFilter(QObject *watched, QEvent *event) override;
141
142 void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override;
143 void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion &region, Output *screen) override;
144 bool isActive() const override;
145
146 void windowInputMouseEvent(QEvent *event) override;
147 void grabbedKeyboardEvent(QKeyEvent *keyEvent) override;
148
149 bool touchDown(qint32 id, const QPointF &pos, std::chrono::microseconds time) override;
150 bool touchMotion(qint32 id, const QPointF &pos, std::chrono::microseconds time) override;
151 bool touchUp(qint32 id, std::chrono::microseconds time) override;
152
153 static bool supported();
154
155 Q_INVOKABLE void checkItemDraggedOutOfScreen(QQuickItem *item);
156 Q_INVOKABLE void checkItemDroppedOutOfScreen(const QPointF &globalPos, QQuickItem *item);
157
158Q_SIGNALS:
159 void itemDraggedOutOfScreen(QQuickItem *item, QList<Output *> screens);
160 void itemDroppedOutOfScreen(const QPointF &globalPos, QQuickItem *item, Output *screen);
161 void activeViewChanged(KWin::QuickSceneView *view);
162 void delegateChanged();
163
164protected:
171 virtual QVariantMap initialProperties(Output *screen);
172
173private:
174 void handleScreenAdded(Output *screen);
175 void handleScreenRemoved(Output *screen);
176
177 void addScreen(Output *screen);
178 void startInternal();
179 void stopInternal();
180
181 std::unique_ptr<QuickSceneEffectPrivate> d;
183};
184
185} // namespace KWin
186
187QML_DECLARE_TYPEINFO(KWin::QuickSceneView, QML_HAS_ATTACHED_PROPERTIES)
Base class for all KWin effects.
Definition effect.h:535
The KwinQuickView class provides a convenient API for exporting QtQuick scenes as buffers that can be...
#define private
#define explicit