1 | /**************************************************************************** |
---|---|
2 | ** |
3 | ** Copyright (C) 2017 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the QtWaylandCompositor module of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU |
19 | ** General Public License version 3 or (at your option) any later version |
20 | ** approved by the KDE Free Qt Foundation. The licenses are as published by |
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 |
22 | ** included in the packaging of this file. Please review the following |
23 | ** information to ensure the GNU General Public License requirements will |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
25 | ** |
26 | ** $QT_END_LICENSE$ |
27 | ** |
28 | ****************************************************************************/ |
29 | |
30 | #ifndef QWAYLANDCOMPOSITOR_H |
31 | #define QWAYLANDCOMPOSITOR_H |
32 | |
33 | #include <QtWaylandCompositor/qtwaylandcompositorglobal.h> |
34 | #include <QtWaylandCompositor/qwaylandcompositorextension.h> |
35 | #include <QtWaylandCompositor/QWaylandOutput> |
36 | |
37 | #include <QObject> |
38 | #include <QImage> |
39 | #include <QRect> |
40 | #include <QLoggingCategory> |
41 | |
42 | struct wl_display; |
43 | |
44 | QT_BEGIN_NAMESPACE |
45 | |
46 | class QInputEvent; |
47 | |
48 | class QMimeData; |
49 | class QUrl; |
50 | class QOpenGLContext; |
51 | class QWaylandCompositorPrivate; |
52 | class QWaylandClient; |
53 | class QWaylandSurface; |
54 | class QWaylandSeat; |
55 | class QWaylandGlobalInterface; |
56 | class QWaylandView; |
57 | class QWaylandPointer; |
58 | class QWaylandKeyboard; |
59 | class QWaylandTouch; |
60 | class QWaylandSurfaceGrabber; |
61 | class QWaylandBufferRef; |
62 | |
63 | Q_WAYLAND_COMPOSITOR_EXPORT Q_DECLARE_LOGGING_CATEGORY(qLcWaylandCompositor) |
64 | Q_WAYLAND_COMPOSITOR_EXPORT Q_DECLARE_LOGGING_CATEGORY(qLcWaylandCompositorHardwareIntegration) |
65 | Q_DECLARE_LOGGING_CATEGORY(qLcWaylandCompositorInputMethods) |
66 | |
67 | class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandCompositor : public QWaylandObject |
68 | { |
69 | Q_OBJECT |
70 | Q_DECLARE_PRIVATE(QWaylandCompositor) |
71 | Q_PROPERTY(QByteArray socketName READ socketName WRITE setSocketName NOTIFY socketNameChanged) |
72 | Q_PROPERTY(bool created READ isCreated NOTIFY createdChanged) |
73 | Q_PROPERTY(bool retainedSelection READ retainedSelectionEnabled WRITE setRetainedSelectionEnabled NOTIFY retainedSelectionChanged) |
74 | Q_PROPERTY(QWaylandOutput *defaultOutput READ defaultOutput WRITE setDefaultOutput NOTIFY defaultOutputChanged) |
75 | Q_PROPERTY(bool useHardwareIntegrationExtension READ useHardwareIntegrationExtension WRITE setUseHardwareIntegrationExtension NOTIFY useHardwareIntegrationExtensionChanged) |
76 | Q_PROPERTY(QWaylandSeat *defaultSeat READ defaultSeat NOTIFY defaultSeatChanged) |
77 | |
78 | public: |
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 | virtual void grabSurface(QWaylandSurfaceGrabber *grabber, const QWaylandBufferRef &buffer); |
120 | |
121 | public Q_SLOTS: |
122 | void processWaylandEvents(); |
123 | |
124 | Q_SIGNALS: |
125 | void createdChanged(); |
126 | void socketNameChanged(const QByteArray &socketName); |
127 | void retainedSelectionChanged(bool retainedSelection); |
128 | |
129 | void surfaceRequested(QWaylandClient *client, uint id, int version); |
130 | void surfaceCreated(QWaylandSurface *surface); |
131 | void surfaceAboutToBeDestroyed(QWaylandSurface *surface); |
132 | void subsurfaceChanged(QWaylandSurface *child, QWaylandSurface *parent); |
133 | |
134 | void defaultOutputChanged(); |
135 | void defaultSeatChanged(QWaylandSeat *newDevice, QWaylandSeat *oldDevice); |
136 | |
137 | void useHardwareIntegrationExtensionChanged(); |
138 | |
139 | void outputAdded(QWaylandOutput *output); |
140 | void outputRemoved(QWaylandOutput *output); |
141 | |
142 | protected: |
143 | virtual void retainedSelectionReceived(QMimeData *mimeData); |
144 | virtual QWaylandSeat *createSeat(); |
145 | virtual QWaylandPointer *createPointerDevice(QWaylandSeat *seat); |
146 | virtual QWaylandKeyboard *createKeyboardDevice(QWaylandSeat *seat); |
147 | virtual QWaylandTouch *createTouchDevice(QWaylandSeat *seat); |
148 | |
149 | QWaylandCompositor(QWaylandCompositorPrivate &dptr, QObject *parent = nullptr); |
150 | }; |
151 | |
152 | QT_END_NAMESPACE |
153 | |
154 | #endif // QWAYLANDCOMPOSITOR_H |
155 |