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
qwaylandxdgshell_p.h
Go to the documentation of this file.
1// Copyright (C) 2018 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3// Qt-Security score:critical reason:network-protocol
4
5#ifndef QWAYLANDXDGSHELL_P_H
6#define QWAYLANDXDGSHELL_P_H
7
8#include <QtWaylandCompositor/private/qwaylandshellsurface_p.h>
9#include <QtWaylandCompositor/private/qwaylandshell_p.h>
10#include <QtWaylandCompositor/private/qwayland-server-xdg-shell.h>
11
12#include <QtWaylandCompositor/QWaylandXdgShell>
13
14#include <QtWaylandCompositor/private/qwaylandxdgdecorationv1_p.h>
15
16#include <QtCore/QSet>
17
18//
19// W A R N I N G
20// -------------
21//
22// This file is not part of the Qt API. It exists purely as an
23// implementation detail. This header file may change from version to
24// version without notice, or even be removed.
25//
26// We mean it.
27//
28
30
31struct Q_WAYLANDCOMPOSITOR_EXPORT QWaylandXdgPositionerData {
32 QSize size;
33 QRect anchorRect;
34 Qt::Edges anchorEdges = {};
35 Qt::Edges gravityEdges = {};
36 uint constraintAdjustments = XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_NONE;
37 QPoint offset;
38 QWaylandXdgPositionerData();
39 bool isComplete() const;
40 QPoint anchorPoint() const;
41 QPoint unconstrainedPosition() const;
42};
43
44class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandXdgShellPrivate
45 : public QWaylandShellPrivate
46 , public QtWaylandServer::xdg_wm_base
47{
48 Q_DECLARE_PUBLIC(QWaylandXdgShell)
49public:
50 QWaylandXdgShellPrivate();
51 void ping(Resource *resource, uint32_t serial);
52 void registerXdgSurface(QWaylandXdgSurface *xdgSurface);
53 void unregisterXdgSurface(QWaylandXdgSurface *xdgSurface);
54 static QWaylandXdgShellPrivate *get(QWaylandXdgShell *xdgShell) { return xdgShell->d_func(); }
55
56 QSet<uint32_t> m_pings;
57 QMultiMap<struct wl_client *, QWaylandXdgSurface *> m_xdgSurfaces;
58
59 QWaylandXdgSurface *xdgSurfaceFromSurface(QWaylandSurface *surface);
60
61protected:
62 void xdg_wm_base_destroy(Resource *resource) override;
63 void xdg_wm_base_create_positioner(Resource *resource, uint32_t id) override;
64 void xdg_wm_base_get_xdg_surface(Resource *resource, uint32_t id,
65 struct ::wl_resource *surface) override;
66 void xdg_wm_base_pong(Resource *resource, uint32_t serial) override;
67};
68
69class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandXdgSurfacePrivate
70 : public QWaylandShellSurfacePrivate
71 , public QtWaylandServer::xdg_surface
72{
73 Q_DECLARE_PUBLIC(QWaylandXdgSurface)
74public:
75 QWaylandXdgSurfacePrivate();
76 void setWindowType(Qt::WindowType windowType);
77 void handleFocusLost();
78 void handleFocusReceived();
79 static QWaylandXdgSurfacePrivate *get(QWaylandXdgSurface *xdgSurface) { return xdgSurface->d_func(); }
80
81 QRect calculateFallbackWindowGeometry() const;
82 void updateFallbackWindowGeometry();
83
84private:
85 QWaylandXdgShell *m_xdgShell = nullptr;
86 QWaylandSurface *m_surface = nullptr;
87
88 QWaylandXdgToplevel *m_toplevel = nullptr;
89 QWaylandXdgPopup *m_popup = nullptr;
90 QRect m_windowGeometry;
91 bool m_unsetWindowGeometry = true;
92 QMargins m_windowMargins;
93 Qt::WindowType m_windowType = Qt::WindowType::Window;
94
95 void xdg_surface_destroy_resource(Resource *resource) override;
96 void xdg_surface_destroy(Resource *resource) override;
97 void xdg_surface_get_toplevel(Resource *resource, uint32_t id) override;
98 void xdg_surface_get_popup(Resource *resource, uint32_t id, struct ::wl_resource *parent, struct ::wl_resource *positioner) override;
99 void xdg_surface_ack_configure(Resource *resource, uint32_t serial) override;
100 void xdg_surface_set_window_geometry(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) override;
101};
102
103class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandXdgToplevelPrivate : public QObjectPrivate, public QtWaylandServer::xdg_toplevel
104{
105 Q_DECLARE_PUBLIC(QWaylandXdgToplevel)
106public:
107 struct ConfigureEvent {
108 ConfigureEvent() = default;
109 ConfigureEvent(const QList<QWaylandXdgToplevel::State>
110 &incomingStates,
111 const QSize &incomingSize, uint incomingSerial)
112 : states(incomingStates), size(incomingSize), serial(incomingSerial)
113 { }
114 QList<QWaylandXdgToplevel::State> states;
115 QSize size = {0, 0};
116 uint serial = 0;
117 };
118
119 QWaylandXdgToplevelPrivate(QWaylandXdgSurface *xdgSurface, const QWaylandResource& resource);
120 ConfigureEvent lastSentConfigure() const { return m_pendingConfigures.empty() ? m_lastAckedConfigure : m_pendingConfigures.last(); }
121 void handleAckConfigure(uint serial); //TODO: move?
122 void handleFocusLost();
123 void handleFocusReceived();
124
125 static QWaylandXdgToplevelPrivate *get(QWaylandXdgToplevel *toplevel) { return toplevel->d_func(); }
126 static Qt::Edges convertToEdges(resize_edge edge);
127
128protected:
129
130 void xdg_toplevel_destroy_resource(Resource *resource) override;
131
132 void xdg_toplevel_destroy(Resource *resource) override;
133 void xdg_toplevel_set_parent(Resource *resource, struct ::wl_resource *parent) override;
134 void xdg_toplevel_set_title(Resource *resource, const QString &title) override;
135 void xdg_toplevel_set_app_id(Resource *resource, const QString &app_id) override;
136 void xdg_toplevel_show_window_menu(Resource *resource, struct ::wl_resource *seat, uint32_t serial, int32_t x, int32_t y) override;
137 void xdg_toplevel_move(Resource *resource, struct ::wl_resource *seatResource, uint32_t serial) override;
138 void xdg_toplevel_resize(Resource *resource, struct ::wl_resource *seat, uint32_t serial, uint32_t edges) override;
139 void xdg_toplevel_set_max_size(Resource *resource, int32_t width, int32_t height) override;
140 void xdg_toplevel_set_min_size(Resource *resource, int32_t width, int32_t height) override;
141 void xdg_toplevel_set_maximized(Resource *resource) override;
142 void xdg_toplevel_unset_maximized(Resource *resource) override;
143 void xdg_toplevel_set_fullscreen(Resource *resource, struct ::wl_resource *output) override;
144 void xdg_toplevel_unset_fullscreen(Resource *resource) override;
145 void xdg_toplevel_set_minimized(Resource *resource) override;
146
147public:
148 QWaylandXdgSurface *m_xdgSurface = nullptr;
149 QWaylandXdgToplevel *m_parentToplevel = nullptr;
150 QList<ConfigureEvent> m_pendingConfigures;
151 ConfigureEvent m_lastAckedConfigure;
152 QString m_title;
153 QString m_appId;
154 QSize m_maxSize;
155 QSize m_minSize = {0, 0};
156 QWaylandXdgToplevelDecorationV1 *m_decoration = nullptr;
157 bool m_modal = false;
158
159 static QWaylandSurfaceRole s_role;
160};
161
162class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandXdgPopupPrivate : public QObjectPrivate, public QtWaylandServer::xdg_popup
163{
164 Q_DECLARE_PUBLIC(QWaylandXdgPopup)
165public:
166 struct ConfigureEvent {
167 QRect geometry;
168 uint serial;
169 };
170
171 QWaylandXdgPopupPrivate(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parentXdgSurface,
172 QWaylandXdgPositioner *positioner, const QWaylandResource& resource);
173
174 void handleAckConfigure(uint serial);
175
176 static QWaylandXdgPopupPrivate *get(QWaylandXdgPopup *popup) { return popup->d_func(); }
177
178 static QWaylandSurfaceRole s_role;
179
180private:
181 uint sendConfigure(const QRect &geometry);
182
183protected:
184 void xdg_popup_destroy(Resource *resource) override;
185 void xdg_popup_grab(Resource *resource, struct ::wl_resource *seat, uint32_t serial) override;
186
187private:
188 QWaylandXdgSurface *m_xdgSurface = nullptr;
189 QWaylandXdgSurface *m_parentXdgSurface = nullptr;
190 QWaylandXdgPositionerData m_positionerData;
191 QRect m_geometry;
192 QList<ConfigureEvent> m_pendingConfigures;
193};
194
195class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandXdgPositioner : public QtWaylandServer::xdg_positioner
196{
197public:
198 QWaylandXdgPositioner(const QWaylandResource& resource);
199 static QWaylandXdgPositioner *fromResource(wl_resource *resource);
200 static Qt::Edges convertToEdges(anchor anchor);
201 static Qt::Edges convertToEdges(gravity gravity);
202
203protected:
204 void xdg_positioner_destroy_resource(Resource *resource) override; //TODO: do something special here?
205
206 void xdg_positioner_destroy(Resource *resource) override;
207 void xdg_positioner_set_size(Resource *resource, int32_t width, int32_t height) override;
208 void xdg_positioner_set_anchor_rect(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) override;
209 void xdg_positioner_set_anchor(Resource *resource, uint32_t anchor) override;
210 void xdg_positioner_set_gravity(Resource *resource, uint32_t gravity) override;
211 void xdg_positioner_set_constraint_adjustment(Resource *resource, uint32_t constraint_adjustment) override;
212 void xdg_positioner_set_offset(Resource *resource, int32_t x, int32_t y) override;
213
214public:
215 QWaylandXdgPositionerData m_data;
216};
217
218QT_END_NAMESPACE
219
220#endif // QWAYLANDXDGSHELL_P_H
Combined button and popup list for selecting options.