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 QWAYLANDXDGSHELLV5_H
31#define QWAYLANDXDGSHELLV5_H
32
33#include <QtWaylandCompositor/QWaylandCompositorExtension>
34#include <QtWaylandCompositor/QWaylandResource>
35#include <QtWaylandCompositor/QWaylandShell>
36#include <QtWaylandCompositor/QWaylandShellSurface>
37#include <QtWaylandCompositor/qwaylandquickchildren.h>
38
39#include <QtCore/QRect>
40
41struct wl_resource;
42
43QT_BEGIN_NAMESPACE
44
45#if QT_DEPRECATED_SINCE(5, 15)
46
47class QWaylandXdgShellV5Private;
48class QWaylandXdgSurfaceV5;
49class QWaylandXdgSurfaceV5Private;
50class QWaylandXdgPopupV5;
51class QWaylandXdgPopupV5Private;
52
53class QWaylandSurface;
54class QWaylandSurfaceRole;
55class QWaylandSeat;
56class QWaylandOutput;
57class QWaylandClient;
58
59class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgShellV5 : public QWaylandShellTemplate<QWaylandXdgShellV5>
60{
61 Q_OBJECT
62 Q_DECLARE_PRIVATE(QWaylandXdgShellV5)
63public:
64 QWaylandXdgShellV5();
65 QWaylandXdgShellV5(QWaylandCompositor *compositor);
66
67 void initialize() override;
68 QWaylandClient *popupClient() const;
69
70 static const struct wl_interface *interface();
71 static QByteArray interfaceName();
72
73public Q_SLOTS:
74 uint ping(QWaylandClient *client);
75 void closeAllPopups();
76
77Q_SIGNALS:
78 void xdgSurfaceRequested(QWaylandSurface *surface, const QWaylandResource &resource);
79 void xdgSurfaceCreated(QWaylandXdgSurfaceV5 *xdgSurface);
80 void xdgPopupCreated(QWaylandXdgPopupV5 *xdgPopup);
81 void xdgPopupRequested(QWaylandSurface *surface, QWaylandSurface *parent, QWaylandSeat *seat, const QPoint &position, const QWaylandResource &resource);
82 void pong(uint serial);
83
84private Q_SLOTS:
85 void handleSeatChanged(QWaylandSeat *newSeat, QWaylandSeat *oldSeat);
86 void handleFocusChanged(QWaylandSurface *newSurface, QWaylandSurface *oldSurface);
87
88};
89
90class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgSurfaceV5 : public QWaylandShellSurfaceTemplate<QWaylandXdgSurfaceV5>
91{
92 Q_OBJECT
93 Q_DECLARE_PRIVATE(QWaylandXdgSurfaceV5)
94 Q_WAYLAND_COMPOSITOR_DECLARE_QUICK_CHILDREN(QWaylandXdgSurfaceV5)
95 Q_PROPERTY(QWaylandXdgShellV5 *shell READ shell NOTIFY shellChanged)
96 Q_PROPERTY(QWaylandSurface *surface READ surface NOTIFY surfaceChanged)
97 Q_PROPERTY(QWaylandXdgSurfaceV5 *parentSurface READ parentSurface NOTIFY parentSurfaceChanged)
98 Q_PROPERTY(QString title READ title NOTIFY titleChanged)
99 Q_PROPERTY(QString appId READ appId NOTIFY appIdChanged)
100 Q_PROPERTY(QRect windowGeometry READ windowGeometry NOTIFY windowGeometryChanged)
101
102 Q_PROPERTY(QList<int> states READ statesAsInts NOTIFY statesChanged)
103 Q_PROPERTY(bool maximized READ maximized NOTIFY maximizedChanged)
104 Q_PROPERTY(bool fullscreen READ fullscreen NOTIFY fullscreenChanged)
105 Q_PROPERTY(bool resizing READ resizing NOTIFY resizingChanged)
106 Q_PROPERTY(bool activated READ activated NOTIFY activatedChanged)
107
108public:
109 enum State : uint {
110 MaximizedState = 1,
111 FullscreenState = 2,
112 ResizingState = 3,
113 ActivatedState = 4
114 };
115 Q_ENUM(State)
116
117 enum ResizeEdge : uint {
118 NoneEdge = 0,
119 TopEdge = 1,
120 BottomEdge = 2,
121 LeftEdge = 4,
122 TopLeftEdge = 5,
123 BottomLeftEdge = 6,
124 RightEdge = 8,
125 TopRightEdge = 9,
126 BottomRightEdge = 10
127 };
128 Q_ENUM(ResizeEdge)
129
130 QWaylandXdgSurfaceV5();
131 QWaylandXdgSurfaceV5(QWaylandXdgShellV5* xdgShell, QWaylandSurface *surface, const QWaylandResource &resource);
132
133 Q_INVOKABLE void initialize(QWaylandXdgShellV5* xdgShell, QWaylandSurface *surface, const QWaylandResource &resource);
134
135 Qt::WindowType windowType() const override;
136
137 QString title() const;
138 QString appId() const;
139 QRect windowGeometry() const;
140 QVector<uint> states() const;
141 bool maximized() const;
142 bool fullscreen() const;
143 bool resizing() const;
144 bool activated() const;
145
146 QWaylandXdgShellV5 *shell() const;
147
148 QWaylandSurface *surface() const;
149 QWaylandXdgSurfaceV5 *parentSurface() const;
150
151 static const struct wl_interface *interface();
152 static QByteArray interfaceName();
153 static QWaylandSurfaceRole *role();
154 static QWaylandXdgSurfaceV5 *fromResource(::wl_resource *resource);
155
156 Q_INVOKABLE QSize sizeForResize(const QSizeF &size, const QPointF &delta, ResizeEdge edge);
157 Q_INVOKABLE uint sendConfigure(const QSize &size, const QVector<uint> &states);
158 Q_INVOKABLE uint sendConfigure(const QSize &size, const QVector<State> &states);
159 Q_INVOKABLE void sendClose();
160
161 Q_INVOKABLE uint sendMaximized(const QSize &size);
162 Q_INVOKABLE uint sendUnmaximized(const QSize &size = QSize(0, 0));
163 Q_INVOKABLE uint sendFullscreen(const QSize &size);
164 Q_INVOKABLE uint sendResizing(const QSize &maxSize);
165
166#if QT_CONFIG(wayland_compositor_quick)
167 QWaylandQuickShellIntegration *createIntegration(QWaylandQuickShellSurfaceItem *item) override;
168#endif
169
170Q_SIGNALS:
171 void shellChanged();
172 void surfaceChanged();
173 void titleChanged();
174 void windowGeometryChanged();
175 void appIdChanged();
176 void parentSurfaceChanged();
177
178 void statesChanged();
179 void maximizedChanged();
180 void fullscreenChanged();
181 void resizingChanged();
182 void activatedChanged();
183
184 void showWindowMenu(QWaylandSeat *seat, const QPoint &localSurfacePosition);
185 void startMove(QWaylandSeat *seat);
186 void startResize(QWaylandSeat *seat, ResizeEdge edges);
187 void setTopLevel();
188 void setTransient();
189 void setMaximized();
190 void unsetMaximized();
191 void setFullscreen(QWaylandOutput *output);
192 void unsetFullscreen();
193 void setMinimized();
194 void ackConfigure(uint serial);
195
196private:
197 void initialize() override;
198 QList<int> statesAsInts() const;
199
200private Q_SLOTS:
201 void handleSurfaceSizeChanged();
202 void handleBufferScaleChanged();
203};
204
205class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgPopupV5 : public QWaylandShellSurfaceTemplate<QWaylandXdgPopupV5>
206{
207 Q_OBJECT
208 Q_DECLARE_PRIVATE(QWaylandXdgPopupV5)
209 Q_WAYLAND_COMPOSITOR_DECLARE_QUICK_CHILDREN(QWaylandXdgPopupV5)
210 Q_PROPERTY(QWaylandXdgShellV5 *shell READ shell NOTIFY shellChanged)
211 Q_PROPERTY(QWaylandSurface *surface READ surface NOTIFY surfaceChanged)
212 Q_PROPERTY(QWaylandSurface *parentSurface READ parentSurface NOTIFY parentSurfaceChanged)
213 Q_PROPERTY(QPoint position READ position NOTIFY positionChanged)
214
215public:
216 QWaylandXdgPopupV5();
217 QWaylandXdgPopupV5(QWaylandXdgShellV5 *xdgShell, QWaylandSurface *surface, QWaylandSurface *parentSurface,
218 const QPoint &position, const QWaylandResource &resource);
219
220 Qt::WindowType windowType() const override { return Qt::WindowType::Popup; }
221
222 Q_INVOKABLE void initialize(QWaylandXdgShellV5 *shell, QWaylandSurface *surface,
223 QWaylandSurface *parentSurface, const QPoint &position, const QWaylandResource &resource);
224
225 QWaylandXdgShellV5 *shell() const;
226
227 QWaylandSurface *surface() const;
228 QWaylandSurface *parentSurface() const;
229 QPoint position() const;
230
231 static const struct wl_interface *interface();
232 static QByteArray interfaceName();
233 static QWaylandSurfaceRole *role();
234 static QWaylandXdgPopupV5 *fromResource(::wl_resource *resource);
235
236 Q_INVOKABLE void sendPopupDone();
237
238#if QT_CONFIG(wayland_compositor_quick)
239 QWaylandQuickShellIntegration *createIntegration(QWaylandQuickShellSurfaceItem *item) override;
240#endif
241
242Q_SIGNALS:
243 void shellChanged();
244 void surfaceChanged();
245 void parentSurfaceChanged();
246 void positionChanged();
247
248private:
249 void initialize() override;
250};
251
252#endif // QT_DEPRECATED_SINCE(5, 15)
253
254QT_END_NAMESPACE
255
256#endif /*QWAYLANDXDGSHELLV5_H*/
257

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