KWin
Loading...
Searching...
No Matches
offscreenquickview.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: 2019 David Edmundson <davidedmundson@kde.org>
6
7 SPDX-License-Identifier: GPL-2.0-or-later
8*/
9
10#pragma once
11
12#include "kwin_export.h"
13
14#include <QObject>
15#include <QRect>
16#include <QUrl>
17
18#include <memory>
19
20class QKeyEvent;
21class QMouseEvent;
22
23class QMouseEvent;
24class QKeyEvent;
25
26class QQmlContext;
27class QQuickItem;
28class QQuickWindow;
29
30namespace KWin
31{
32class GLTexture;
33
34class OffscreenQuickView;
35
45class KWIN_EXPORT OffscreenQuickView : public QObject
46{
47 Q_OBJECT
48
49public:
50 enum class ExportMode {
52 Texture,
54 Image
55 };
56
61 explicit OffscreenQuickView(ExportMode exportMode = ExportMode::Texture, bool alpha = true);
62
67
68 QSize size() const;
69
74 void setGeometry(const QRect &rect);
75 QRect geometry() const;
76
77 void setOpacity(qreal opacity);
78 qreal opacity() const;
79 bool hasAlphaChannel() const;
80
89 void update();
90
92 QQuickItem *contentItem() const;
93 QQuickWindow *window() const;
94
100 void setVisible(bool visible);
101 bool isVisible() const;
102
103 void show();
104 void hide();
105
106 bool automaticRepaint() const;
107 void setAutomaticRepaint(bool set);
108
113 GLTexture *bufferAsTexture();
114
118 QImage bufferAsImage() const;
119
125 void forwardMouseEvent(QEvent *mouseEvent);
130 void forwardKeyEvent(QKeyEvent *keyEvent);
131
132 bool forwardTouchDown(qint32 id, const QPointF &pos, std::chrono::microseconds time);
133 bool forwardTouchMotion(qint32 id, const QPointF &pos, std::chrono::microseconds time);
134 bool forwardTouchUp(qint32 id, std::chrono::microseconds time);
135
136Q_SIGNALS:
141 void geometryChanged(const QRect &oldGeometry, const QRect &newGeometry);
144
145private:
146 void handleRenderRequested();
147 void handleSceneChanged();
148
149 class Private;
150 std::unique_ptr<Private> d;
151};
152
158class KWIN_EXPORT OffscreenQuickScene : public OffscreenQuickView
159{
160public:
161 explicit OffscreenQuickScene(ExportMode exportMode = ExportMode::Texture, bool alpha = true);
163
165 QQuickItem *rootItem() const;
166
167 void setSource(const QUrl &source);
168 void setSource(const QUrl &source, const QVariantMap &initialProperties);
169
170private:
171 class Private;
172 std::unique_ptr<Private> d;
173};
174
175}
The KwinQuickView class provides a convenient API for exporting QtQuick scenes as buffers that can be...
void geometryChanged(const QRect &oldGeometry, const QRect &newGeometry)