Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qwaylandcompositor.h
Go to the documentation of this file.
1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QWAYLANDCOMPOSITOR_H
6#define QWAYLANDCOMPOSITOR_H
7
8#include <QtWaylandCompositor/qtwaylandcompositorglobal.h>
9#include <QtWaylandCompositor/qtwaylandqmlinclude.h>
10#include <QtWaylandCompositor/qwaylandcompositorextension.h>
11#include <QtWaylandCompositor/QWaylandOutput>
12
13#include <QtCore/QObject>
14#include <QtGui/QImage>
15#include <QtCore/QRect>
16#include <QtCore/QLoggingCategory>
17
18struct wl_display;
19
20QT_BEGIN_NAMESPACE
21
22class QInputEvent;
23
24class QMimeData;
25class QUrl;
26class QOpenGLContext;
27class QWaylandCompositorPrivate;
28class QWaylandClient;
29class QWaylandSurface;
30class QWaylandSeat;
31class QWaylandView;
32class QWaylandPointer;
33class QWaylandKeyboard;
34class QWaylandTouch;
35class QWaylandSurfaceGrabber;
36class QWaylandBufferRef;
37
38Q_WAYLANDCOMPOSITOR_EXPORT const QLoggingCategory &qLcWaylandCompositor();
39Q_WAYLANDCOMPOSITOR_EXPORT const QLoggingCategory &qLcWaylandCompositorHardwareIntegration();
42
43class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandCompositor : public QWaylandObject
44{
45 Q_OBJECT
46 Q_DECLARE_PRIVATE(QWaylandCompositor)
47 Q_PROPERTY(QByteArray socketName READ socketName WRITE setSocketName NOTIFY socketNameChanged)
48 Q_PROPERTY(bool created READ isCreated NOTIFY createdChanged)
49 Q_PROPERTY(bool retainedSelection READ retainedSelectionEnabled WRITE setRetainedSelectionEnabled NOTIFY retainedSelectionChanged)
50 Q_PROPERTY(QWaylandOutput *defaultOutput READ defaultOutput WRITE setDefaultOutput NOTIFY defaultOutputChanged)
51 Q_PROPERTY(bool useHardwareIntegrationExtension READ useHardwareIntegrationExtension WRITE setUseHardwareIntegrationExtension NOTIFY useHardwareIntegrationExtensionChanged)
52 Q_PROPERTY(QWaylandSeat *defaultSeat READ defaultSeat NOTIFY defaultSeatChanged)
53 Q_PROPERTY(QVector<ShmFormat> additionalShmFormats READ additionalShmFormats WRITE setAdditionalShmFormats NOTIFY additionalShmFormatsChanged REVISION(6, 0))
54 Q_MOC_INCLUDE("qwaylandseat.h")
55 QML_NAMED_ELEMENT(WaylandCompositorBase)
56 QML_UNCREATABLE("Cannot create instance of WaylandCompositorBase, use WaylandCompositor instead")
57 QML_ADDED_IN_VERSION(1, 0)
58public:
59 // Duplicates subset of supported values wl_shm_format enum
60 enum ShmFormat {
61 ShmFormat_ARGB8888 = 0,
62 ShmFormat_XRGB8888 = 1,
63 ShmFormat_C8 = 0x20203843,
64 ShmFormat_XRGB4444 = 0x32315258,
65 ShmFormat_ARGB4444 = 0x32315241,
66 ShmFormat_XRGB1555 = 0x35315258,
67 ShmFormat_RGB565 = 0x36314752,
68 ShmFormat_RGB888 = 0x34324752,
69 ShmFormat_XBGR8888 = 0x34324258,
70 ShmFormat_ABGR8888 = 0x34324241,
71 ShmFormat_BGR888 = 0x34324742,
72 ShmFormat_XRGB2101010 = 0x30335258,
73 ShmFormat_XBGR2101010 = 0x30334258,
74 ShmFormat_ARGB2101010 = 0x30335241,
75 ShmFormat_ABGR2101010 = 0x30334241
76 };
77 Q_ENUM(ShmFormat)
78
79 QWaylandCompositor(QObject *parent = nullptr);
80 ~QWaylandCompositor() override;
81
82 virtual void create();
83 bool isCreated() const;
84
85 void setSocketName(const QByteArray &name);
86 QByteArray socketName() const;
87
88 Q_INVOKABLE void addSocketDescriptor(int fd);
89
90 ::wl_display *display() const;
91 uint32_t nextSerial();
92
93 QList<QWaylandClient *>clients() const;
94 Q_INVOKABLE void destroyClientForSurface(QWaylandSurface *surface);
95 Q_INVOKABLE void destroyClient(QWaylandClient *client);
96
97 QList<QWaylandSurface *> surfaces() const;
98 QList<QWaylandSurface *> surfacesForClient(QWaylandClient* client) const;
99
100 Q_INVOKABLE QWaylandOutput *outputFor(QWindow *window) const;
101
102 QWaylandOutput *defaultOutput() const;
103 void setDefaultOutput(QWaylandOutput *output);
104 QList<QWaylandOutput *> outputs() const;
105
106 uint currentTimeMsecs() const;
107
108 void setRetainedSelectionEnabled(bool enabled);
109 bool retainedSelectionEnabled() const;
110 void overrideSelection(const QMimeData *data);
111
112 QWaylandSeat *defaultSeat() const;
113
114 QWaylandSeat *seatFor(QInputEvent *inputEvent);
115
116 bool useHardwareIntegrationExtension() const;
117 void setUseHardwareIntegrationExtension(bool use);
118
119 QVector<ShmFormat> additionalShmFormats() const;
120 void setAdditionalShmFormats(const QVector<ShmFormat> &additionalShmFormats);
121
122 virtual void grabSurface(QWaylandSurfaceGrabber *grabber, const QWaylandBufferRef &buffer);
123
124public Q_SLOTS:
125 void processWaylandEvents();
126
127private Q_SLOTS:
128 void applicationStateChanged(Qt::ApplicationState state);
129
130Q_SIGNALS:
131 void createdChanged();
132 void socketNameChanged(const QByteArray &socketName);
133 void retainedSelectionChanged(bool retainedSelection);
134
135 void surfaceRequested(QWaylandClient *client, uint id, int version);
136 void surfaceCreated(QWaylandSurface *surface);
137 void surfaceAboutToBeDestroyed(QWaylandSurface *surface);
138 void subsurfaceChanged(QWaylandSurface *child, QWaylandSurface *parent);
139
140 void defaultOutputChanged();
141 void defaultSeatChanged(QWaylandSeat *newDevice, QWaylandSeat *oldDevice);
142
143 void useHardwareIntegrationExtensionChanged();
144
145 void outputAdded(QWaylandOutput *output);
146 void outputRemoved(QWaylandOutput *output);
147
148 void additionalShmFormatsChanged();
149
150protected:
151 virtual void retainedSelectionReceived(QMimeData *mimeData);
152 virtual QWaylandSeat *createSeat();
153 virtual QWaylandPointer *createPointerDevice(QWaylandSeat *seat);
154 virtual QWaylandKeyboard *createKeyboardDevice(QWaylandSeat *seat);
155 virtual QWaylandTouch *createTouchDevice(QWaylandSeat *seat);
156
157 QWaylandCompositor(QWaylandCompositorPrivate &dptr, QObject *parent = nullptr);
158};
159
160QT_END_NAMESPACE
161
162#endif // QWAYLANDCOMPOSITOR_H
\qmltype WaylandCompositor \nativetype QWaylandCompositor \inqmlmodule QtWayland.Compositor
const QLoggingCategory & qLcWaylandCompositorTextInput()
const QLoggingCategory & qLcWaylandCompositorInputMethods()