1
2// Copyright (C) 2018 The Qt Company Ltd.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
4
5#ifndef QWAYLANDXDGSHELL_H
6#define QWAYLANDXDGSHELL_H
7
8#include <QtWaylandCompositor/QWaylandCompositorExtension>
9#include <QtWaylandCompositor/QWaylandResource>
10#include <QtWaylandCompositor/QWaylandShell>
11#include <QtWaylandCompositor/QWaylandShellSurface>
12#if QT_CONFIG(wayland_compositor_quick)
13#include <QtWaylandCompositor/qwaylandquickchildren.h>
14#endif
15
16#include <QtCore/QRect>
17
18struct wl_resource;
19
20QT_BEGIN_NAMESPACE
21
22class QWaylandClient;
23class QWaylandOutput;
24class QWaylandSeat;
25class QWaylandSurface;
26class QWaylandSurfaceRole;
27class QWaylandXdgShellPrivate;
28class QWaylandXdgSurface;
29class QWaylandXdgSurfacePrivate;
30class QWaylandXdgToplevel;
31class QWaylandXdgToplevelPrivate;
32class QWaylandXdgPopup;
33class QWaylandXdgPopupPrivate;
34class QWaylandXdgPositioner;
35
36class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandXdgShell : public QWaylandShellTemplate<QWaylandXdgShell>
37{
38 Q_OBJECT
39 Q_DECLARE_PRIVATE(QWaylandXdgShell)
40public:
41 explicit QWaylandXdgShell();
42 explicit QWaylandXdgShell(QWaylandCompositor *compositor);
43
44 void initialize() override;
45
46 static const struct wl_interface *interface();
47 static QByteArray interfaceName();
48
49public Q_SLOTS:
50 uint ping(QWaylandClient *client);
51
52Q_SIGNALS:
53 void xdgSurfaceCreated(QWaylandXdgSurface *xdgSurface);
54 void toplevelCreated(QWaylandXdgToplevel *toplevel, QWaylandXdgSurface *xdgSurface);
55 void popupCreated(QWaylandXdgPopup *popup, QWaylandXdgSurface *xdgSurface);
56 void pong(uint serial);
57
58private Q_SLOTS:
59 void handleSeatChanged(QWaylandSeat *newSeat, QWaylandSeat *oldSeat);
60 void handleFocusChanged(QWaylandSurface *newSurface, QWaylandSurface *oldSurface);
61};
62
63class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandXdgSurface : public QWaylandShellSurfaceTemplate<QWaylandXdgSurface>
64{
65 Q_OBJECT
66 Q_DECLARE_PRIVATE(QWaylandXdgSurface)
67#if QT_CONFIG(wayland_compositor_quick)
68 Q_WAYLAND_COMPOSITOR_DECLARE_QUICK_CHILDREN(QWaylandXdgSurface)
69#endif
70 Q_PROPERTY(QWaylandXdgShell *shell READ shell NOTIFY shellChanged)
71 Q_PROPERTY(QWaylandSurface *surface READ surface NOTIFY surfaceChanged)
72 Q_PROPERTY(QWaylandXdgToplevel *toplevel READ toplevel NOTIFY toplevelCreated)
73 Q_PROPERTY(QWaylandXdgPopup *popup READ popup NOTIFY popupCreated)
74 Q_PROPERTY(QRect windowGeometry READ windowGeometry NOTIFY windowGeometryChanged)
75 Q_MOC_INCLUDE("qwaylandsurface.h")
76
77public:
78 explicit QWaylandXdgSurface();
79 explicit QWaylandXdgSurface(QWaylandXdgShell* xdgShell, QWaylandSurface *surface, const QWaylandResource &resource);
80
81 Q_INVOKABLE void initialize(QWaylandXdgShell* xdgShell, QWaylandSurface *surface, const QWaylandResource &resource);
82
83 Qt::WindowType windowType() const override;
84
85 QWaylandXdgShell *shell() const;
86 QWaylandSurface *surface() const;
87 QWaylandXdgToplevel *toplevel() const;
88 QWaylandXdgPopup *popup() const;
89 QRect windowGeometry() const;
90
91 static const struct wl_interface *interface();
92 static QByteArray interfaceName();
93 static QWaylandXdgSurface *fromResource(::wl_resource *resource);
94
95#if QT_CONFIG(wayland_compositor_quick)
96 QWaylandQuickShellIntegration *createIntegration(QWaylandQuickShellSurfaceItem *item) override;
97#endif
98
99Q_SIGNALS:
100 void shellChanged();
101 void surfaceChanged();
102 void toplevelCreated();
103 void popupCreated();
104 void windowGeometryChanged();
105
106private:
107 void initialize() override;
108
109private Q_SLOTS:
110 void handleSurfaceSizeChanged();
111 void handleBufferScaleChanged();
112};
113
114class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandXdgToplevel : public QObject
115{
116 Q_OBJECT
117 Q_DECLARE_PRIVATE(QWaylandXdgToplevel)
118 Q_PROPERTY(QWaylandXdgSurface *xdgSurface READ xdgSurface CONSTANT)
119 Q_PROPERTY(QWaylandXdgToplevel *parentToplevel READ parentToplevel NOTIFY parentToplevelChanged)
120 Q_PROPERTY(QString title READ title NOTIFY titleChanged)
121 Q_PROPERTY(QString appId READ appId NOTIFY appIdChanged)
122 Q_PROPERTY(QSize maxSize READ maxSize NOTIFY maxSizeChanged)
123 Q_PROPERTY(QSize minSize READ minSize NOTIFY minSizeChanged)
124 Q_PROPERTY(QList<int> states READ statesAsInts NOTIFY statesChanged)
125 Q_PROPERTY(bool maximized READ maximized NOTIFY maximizedChanged)
126 Q_PROPERTY(bool fullscreen READ fullscreen NOTIFY fullscreenChanged)
127 Q_PROPERTY(bool resizing READ resizing NOTIFY resizingChanged)
128 Q_PROPERTY(bool activated READ activated NOTIFY activatedChanged)
129 Q_PROPERTY(bool modal READ isModal NOTIFY modalChanged FINAL REVISION(6,8))
130 Q_PROPERTY(enum DecorationMode decorationMode READ decorationMode NOTIFY decorationModeChanged)
131
132public:
133 enum State : uint {
134 MaximizedState = 1,
135 FullscreenState = 2,
136 ResizingState = 3,
137 ActivatedState = 4
138 };
139 Q_ENUM(State)
140
141 enum DecorationMode {
142 ClientSideDecoration = 1,
143 ServerSideDecoration = 2,
144 };
145 Q_ENUM(DecorationMode)
146
147 explicit QWaylandXdgToplevel(QWaylandXdgSurface *xdgSurface, QWaylandResource &resource);
148 ~QWaylandXdgToplevel() override;
149
150 QWaylandXdgSurface *xdgSurface() const;
151 QWaylandXdgToplevel *parentToplevel() const;
152
153 QString title() const;
154 QString appId() const;
155 QSize maxSize() const;
156 QSize minSize() const;
157 QList<QWaylandXdgToplevel::State> states() const;
158 bool maximized() const;
159 bool fullscreen() const;
160 bool resizing() const;
161 bool activated() const;
162 DecorationMode decorationMode() const;
163
164 Q_INVOKABLE QSize sizeForResize(const QSizeF &size, const QPointF &delta, Qt::Edges edges) const;
165 uint sendConfigure(const QSize &size, const QList<State> &states);
166 Q_INVOKABLE uint sendConfigure(const QSize &size, const QList<int> &states);
167 Q_INVOKABLE void sendClose();
168 Q_INVOKABLE uint sendMaximized(const QSize &size);
169 Q_INVOKABLE uint sendUnmaximized(const QSize &size = QSize(0, 0));
170 Q_INVOKABLE uint sendFullscreen(const QSize &size);
171 Q_INVOKABLE uint sendResizing(const QSize &maxSize);
172
173 static QWaylandSurfaceRole *role();
174 static QWaylandXdgToplevel *fromResource(::wl_resource *resource);
175
176 bool isModal() const;
177
178Q_SIGNALS:
179 void parentToplevelChanged();
180 void titleChanged();
181 void appIdChanged();
182 void maxSizeChanged();
183 void minSizeChanged();
184 void startMove(QWaylandSeat *seat);
185 void startResize(QWaylandSeat *seat, Qt::Edges edges);
186 void statesChanged();
187 void maximizedChanged();
188 void fullscreenChanged();
189 void resizingChanged();
190 void activatedChanged();
191
192 void showWindowMenu(QWaylandSeat *seat, const QPoint &localSurfacePosition);
193 void setMaximized();
194 void unsetMaximized();
195 void setFullscreen(QWaylandOutput *output);
196 void unsetFullscreen();
197 void setMinimized();
198
199 void decorationModeChanged();
200
201 Q_REVISION(6, 8) void modalChanged();
202
203private:
204 QList<int> statesAsInts() const;
205 void setModal(bool newModal);
206 friend class QWaylandXdgDialogV1;
207};
208
209class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandXdgPopup : public QObject
210{
211 Q_OBJECT
212 Q_DECLARE_PRIVATE(QWaylandXdgPopup)
213 Q_PROPERTY(QWaylandXdgSurface *xdgSurface READ xdgSurface CONSTANT)
214 Q_PROPERTY(QWaylandXdgSurface *parentXdgSurface READ parentXdgSurface CONSTANT)
215 Q_PROPERTY(QRect configuredGeometry READ configuredGeometry NOTIFY configuredGeometryChanged)
216
217 // Positioner properties
218 Q_PROPERTY(QRect anchorRect READ anchorRect CONSTANT)
219 Q_PROPERTY(Qt::Edges anchorEdges READ anchorEdges CONSTANT)
220 Q_PROPERTY(Qt::Edges gravityEdges READ gravityEdges CONSTANT)
221 Q_PROPERTY(Qt::Orientations slideConstraints READ slideConstraints CONSTANT)
222 Q_PROPERTY(Qt::Orientations flipConstraints READ flipConstraints CONSTANT)
223 Q_PROPERTY(Qt::Orientations resizeConstraints READ resizeConstraints CONSTANT)
224 Q_PROPERTY(QPoint offset READ offset CONSTANT)
225 Q_PROPERTY(QSize positionerSize READ positionerSize CONSTANT)
226 Q_PROPERTY(QPoint unconstrainedPosition READ unconstrainedPosition CONSTANT)
227public:
228 QWaylandXdgSurface *xdgSurface() const;
229 QWaylandXdgSurface *parentXdgSurface() const;
230 QRect configuredGeometry() const;
231
232 // Positioner properties
233 QRect anchorRect() const;
234 Qt::Edges anchorEdges() const ;
235 Qt::Edges gravityEdges() const ;
236 Qt::Orientations slideConstraints() const;
237 Qt::Orientations flipConstraints() const;
238 Qt::Orientations resizeConstraints() const;
239 QPoint offset() const;
240 QSize positionerSize() const;
241 QPoint unconstrainedPosition() const;
242
243 Q_INVOKABLE uint sendConfigure(const QRect &geometry);
244 Q_REVISION(1, 14) Q_INVOKABLE void sendPopupDone();
245
246 static QWaylandSurfaceRole *role();
247
248Q_SIGNALS:
249 void configuredGeometryChanged();
250
251private:
252 explicit QWaylandXdgPopup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parentXdgSurface,
253 QWaylandXdgPositioner *positioner, QWaylandResource &resource);
254 friend class QWaylandXdgSurfacePrivate;
255};
256
257QT_END_NAMESPACE
258
259#endif // QWAYLANDXDGSHELL_H
260

Provided by KDAB

Privacy Policy
Learn Advanced QML with KDAB
Find out more

source code of qtwayland/src/compositor/extensions/qwaylandxdgshell.h