KWin
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
xdgshell_p.h
Go to the documentation of this file.
1/*
2 SPDX-FileCopyrightText: 2020 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6
7#pragma once
8
9#include "qwayland-server-xdg-shell.h"
10#include "xdgshell.h"
11
12#include "surface_p.h"
13
14namespace KWin
15{
16class XdgToplevelDecorationV1Interface;
17
18class XdgShellInterfacePrivate : public QtWaylandServer::xdg_wm_base
19{
20public:
22
23 Resource *resourceForXdgSurface(XdgSurfaceInterface *surface) const;
24
26
27 void registerPing(quint32 serial);
28
30
32 Display *display = nullptr;
33 QMap<quint32, QTimer *> pings;
34 std::chrono::milliseconds pingTimeout = std::chrono::milliseconds(1000);
35
36protected:
37 void xdg_wm_base_destroy_resource(Resource *resource) override;
38 void xdg_wm_base_destroy(Resource *resource) override;
39 void xdg_wm_base_create_positioner(Resource *resource, uint32_t id) override;
40 void xdg_wm_base_get_xdg_surface(Resource *resource, uint32_t id, ::wl_resource *surface) override;
41 void xdg_wm_base_pong(Resource *resource, uint32_t serial) override;
42
43private:
44 QHash<XdgSurfaceInterface *, Resource *> xdgSurfaces;
45};
46
47class XdgPositionerData : public QSharedData
48{
49public:
51 Qt::Orientations flipConstraintAdjustments;
53 Qt::Edges anchorEdges;
54 Qt::Edges gravityEdges;
55 QPoint offset;
56 QSize size;
58 bool isReactive = false;
61};
62
63class XdgPositionerPrivate : public QtWaylandServer::xdg_positioner
64{
65public:
66 XdgPositionerPrivate(::wl_resource *resource);
67
68 QSharedDataPointer<XdgPositionerData> data;
69
70 static XdgPositionerPrivate *get(::wl_resource *resource);
71
72protected:
73 void xdg_positioner_destroy_resource(Resource *resource) override;
74 void xdg_positioner_destroy(Resource *resource) override;
75 void xdg_positioner_set_size(Resource *resource, int32_t width, int32_t height) override;
76 void xdg_positioner_set_anchor_rect(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) override;
77 void xdg_positioner_set_anchor(Resource *resource, uint32_t anchor) override;
78 void xdg_positioner_set_gravity(Resource *resource, uint32_t gravity) override;
79 void xdg_positioner_set_constraint_adjustment(Resource *resource, uint32_t constraint_adjustment) override;
80 void xdg_positioner_set_offset(Resource *resource, int32_t x, int32_t y) override;
81 void xdg_positioner_set_reactive(Resource *resource) override;
82 void xdg_positioner_set_parent_size(Resource *resource, int32_t width, int32_t height) override;
83 void xdg_positioner_set_parent_configure(Resource *resource, uint32_t serial) override;
84};
85
87{
88 std::optional<QRect> windowGeometry;
89 std::optional<quint32> acknowledgedConfigure;
90};
91
93{
94 std::optional<QSize> minimumSize;
95 std::optional<QSize> maximumSize;
96};
97
101
102class XdgSurfaceInterfacePrivate : public QtWaylandServer::xdg_surface
103{
104public:
106
107 void apply(XdgSurfaceCommit *commit);
108 void reset();
109
110 // These two point into XdgSurfaceRole's state and are valid as long as a role is assigned.
112
115 QPointer<XdgToplevelInterface> toplevel;
116 QPointer<XdgPopupInterface> popup;
117 QPointer<SurfaceInterface> surface;
120 bool isConfigured = false;
121 bool isInitialized = false;
122
124
125protected:
126 void xdg_surface_destroy_resource(Resource *resource) override;
127 void xdg_surface_destroy(Resource *resource) override;
128 void xdg_surface_get_toplevel(Resource *resource, uint32_t id) override;
129 void xdg_surface_get_popup(Resource *resource, uint32_t id, ::wl_resource *parent, ::wl_resource *positioner) override;
130 void xdg_surface_set_window_geometry(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) override;
131 void xdg_surface_ack_configure(Resource *resource, uint32_t serial) override;
132};
133
134class XdgToplevelInterfacePrivate : public SurfaceExtension<XdgToplevelCommit>, public QtWaylandServer::xdg_toplevel
135{
136public:
138
139 void apply(XdgToplevelCommit *commit) override;
140 void reset();
141
143 static XdgToplevelInterfacePrivate *get(::wl_resource *resource);
144
146 QPointer<XdgToplevelInterface> parentXdgToplevel;
147 QPointer<XdgToplevelDecorationV1Interface> decoration;
149 QString windowTitle;
150 QString windowClass;
153
154protected:
155 void xdg_toplevel_destroy_resource(Resource *resource) override;
156 void xdg_toplevel_destroy(Resource *resource) override;
157 void xdg_toplevel_set_parent(Resource *resource, ::wl_resource *parent) override;
158 void xdg_toplevel_set_title(Resource *resource, const QString &title) override;
159 void xdg_toplevel_set_app_id(Resource *resource, const QString &app_id) override;
160 void xdg_toplevel_show_window_menu(Resource *resource, ::wl_resource *seat, uint32_t serial, int32_t x, int32_t y) override;
161 void xdg_toplevel_move(Resource *resource, ::wl_resource *seat, uint32_t serial) override;
162 void xdg_toplevel_resize(Resource *resource, ::wl_resource *seat, uint32_t serial, uint32_t edges) override;
163 void xdg_toplevel_set_max_size(Resource *resource, int32_t width, int32_t height) override;
164 void xdg_toplevel_set_min_size(Resource *resource, int32_t width, int32_t height) override;
165 void xdg_toplevel_set_maximized(Resource *resource) override;
166 void xdg_toplevel_unset_maximized(Resource *resource) override;
167 void xdg_toplevel_set_fullscreen(Resource *resource, ::wl_resource *output) override;
168 void xdg_toplevel_unset_fullscreen(Resource *resource) override;
169 void xdg_toplevel_set_minimized(Resource *resource) override;
170};
171
172class XdgPopupInterfacePrivate : public SurfaceExtension<XdgPopupCommit>, public QtWaylandServer::xdg_popup
173{
174public:
176
178
179 void apply(XdgPopupCommit *commit) override;
180 void reset();
181
186
187protected:
188 void xdg_popup_destroy_resource(Resource *resource) override;
189 void xdg_popup_destroy(Resource *resource) override;
190 void xdg_popup_grab(Resource *resource, ::wl_resource *seat, uint32_t serial) override;
191 void xdg_popup_reposition(Resource *resource, struct ::wl_resource *positioner, uint32_t token) override;
192};
193
194} // namespace KWin
Class holding the Wayland server display loop.
Definition display.h:34
Resource representing a wl_surface.
Definition surface.h:80
XdgSurfaceInterface * xdgSurface
Definition xdgshell_p.h:184
static XdgPopupInterfacePrivate * get(XdgPopupInterface *popup)
Definition xdgshell.cpp:686
SurfaceInterface * parentSurface
Definition xdgshell_p.h:183
void xdg_popup_grab(Resource *resource, ::wl_resource *seat, uint32_t serial) override
Definition xdgshell.cpp:743
void xdg_popup_destroy_resource(Resource *resource) override
Definition xdgshell.cpp:730
XdgPopupInterfacePrivate(XdgPopupInterface *popup, XdgSurfaceInterface *surface)
Definition xdgshell.cpp:691
void xdg_popup_reposition(Resource *resource, struct ::wl_resource *positioner, uint32_t token) override
Definition xdgshell.cpp:753
void apply(XdgPopupCommit *commit) override
Definition xdgshell.cpp:698
void xdg_popup_destroy(Resource *resource) override
Definition xdgshell.cpp:735
Qt::Orientations flipConstraintAdjustments
Definition xdgshell_p.h:51
Qt::Orientations slideConstraintAdjustments
Definition xdgshell_p.h:50
Qt::Orientations resizeConstraintAdjustments
Definition xdgshell_p.h:52
void xdg_positioner_set_reactive(Resource *resource) override
Definition xdgshell.cpp:925
void xdg_positioner_destroy(Resource *resource) override
Definition xdgshell.cpp:859
void xdg_positioner_set_size(Resource *resource, int32_t width, int32_t height) override
Definition xdgshell.cpp:864
void xdg_positioner_set_offset(Resource *resource, int32_t x, int32_t y) override
void xdg_positioner_destroy_resource(Resource *resource) override
Definition xdgshell.cpp:854
static XdgPositionerPrivate * get(::wl_resource *resource)
Definition xdgshell.cpp:849
void xdg_positioner_set_constraint_adjustment(Resource *resource, uint32_t constraint_adjustment) override
Definition xdgshell.cpp:973
void xdg_positioner_set_gravity(Resource *resource, uint32_t gravity) override
Definition xdgshell.cpp:935
void xdg_positioner_set_parent_size(Resource *resource, int32_t width, int32_t height) override
Definition xdgshell.cpp:920
void xdg_positioner_set_anchor_rect(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) override
Definition xdgshell.cpp:873
void xdg_positioner_set_anchor(Resource *resource, uint32_t anchor) override
Definition xdgshell.cpp:882
QSharedDataPointer< XdgPositionerData > data
Definition xdgshell_p.h:68
XdgPositionerPrivate(::wl_resource *resource)
Definition xdgshell.cpp:843
void xdg_positioner_set_parent_configure(Resource *resource, uint32_t serial) override
Definition xdgshell.cpp:930
void xdg_wm_base_create_positioner(Resource *resource, uint32_t id) override
Definition xdgshell.cpp:79
void registerPing(quint32 serial)
Definition xdgshell.cpp:41
void xdg_wm_base_pong(Resource *resource, uint32_t serial) override
Definition xdgshell.cpp:100
XdgShellInterface * q
Definition xdgshell_p.h:31
std::chrono::milliseconds pingTimeout
Definition xdgshell_p.h:34
void xdg_wm_base_destroy(Resource *resource) override
Definition xdgshell.cpp:70
Resource * resourceForXdgSurface(XdgSurfaceInterface *surface) const
Definition xdgshell.cpp:27
void unregisterXdgSurface(XdgSurfaceInterface *surface)
Definition xdgshell.cpp:32
QMap< quint32, QTimer * > pings
Definition xdgshell_p.h:33
void xdg_wm_base_get_xdg_surface(Resource *resource, uint32_t id, ::wl_resource *surface) override
Definition xdgshell.cpp:85
void xdg_wm_base_destroy_resource(Resource *resource) override
Definition xdgshell.cpp:64
XdgShellInterfacePrivate(XdgShellInterface *shell)
Definition xdgshell.cpp:22
static XdgShellInterfacePrivate * get(XdgShellInterface *shell)
Definition xdgshell.cpp:59
QPointer< XdgPopupInterface > popup
Definition xdgshell_p.h:116
void xdg_surface_get_popup(Resource *resource, uint32_t id, ::wl_resource *parent, ::wl_resource *positioner) override
Definition xdgshell.cpp:213
void xdg_surface_get_toplevel(Resource *resource, uint32_t id) override
Definition xdgshell.cpp:196
void xdg_surface_ack_configure(Resource *resource, uint32_t serial) override
Definition xdgshell.cpp:267
void apply(XdgSurfaceCommit *commit)
Definition xdgshell.cpp:153
XdgSurfaceInterfacePrivate(XdgSurfaceInterface *xdgSurface)
Definition xdgshell.cpp:148
QPointer< XdgToplevelInterface > toplevel
Definition xdgshell_p.h:115
void xdg_surface_set_window_geometry(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) override
Definition xdgshell.cpp:252
void xdg_surface_destroy(Resource *resource) override
Definition xdgshell.cpp:188
void xdg_surface_destroy_resource(Resource *resource) override
Definition xdgshell.cpp:183
QPointer< SurfaceInterface > surface
Definition xdgshell_p.h:117
static XdgSurfaceInterfacePrivate * get(XdgSurfaceInterface *surface)
Definition xdgshell.cpp:178
XdgSurfaceInterface * q
Definition xdgshell_p.h:113
void apply(XdgToplevelCommit *commit) override
Definition xdgshell.cpp:339
void xdg_toplevel_set_max_size(Resource *resource, int32_t width, int32_t height) override
Definition xdgshell.cpp:463
void xdg_toplevel_move(Resource *resource, ::wl_resource *seat, uint32_t serial) override
Definition xdgshell.cpp:437
static XdgToplevelInterfacePrivate * get(XdgToplevelInterface *toplevel)
Definition xdgshell.cpp:507
void xdg_toplevel_set_fullscreen(Resource *resource, ::wl_resource *output) override
Definition xdgshell.cpp:491
void xdg_toplevel_destroy_resource(Resource *resource) override
Definition xdgshell.cpp:386
XdgToplevelInterface * q
Definition xdgshell_p.h:145
void xdg_toplevel_set_min_size(Resource *resource, int32_t width, int32_t height) override
Definition xdgshell.cpp:472
static XdgToplevelInterfacePrivate * get(::wl_resource *resource)
QPointer< XdgToplevelInterface > parentXdgToplevel
Definition xdgshell_p.h:146
void xdg_toplevel_set_maximized(Resource *resource) override
Definition xdgshell.cpp:481
void xdg_toplevel_set_title(Resource *resource, const QString &title) override
Definition xdgshell.cpp:406
QPointer< XdgToplevelDecorationV1Interface > decoration
Definition xdgshell_p.h:147
void xdg_toplevel_destroy(Resource *resource) override
Definition xdgshell.cpp:391
void xdg_toplevel_show_window_menu(Resource *resource, ::wl_resource *seat, uint32_t serial, int32_t x, int32_t y) override
Definition xdgshell.cpp:424
void xdg_toplevel_unset_maximized(Resource *resource) override
Definition xdgshell.cpp:486
XdgSurfaceInterface * xdgSurface
Definition xdgshell_p.h:148
void xdg_toplevel_set_minimized(Resource *resource) override
Definition xdgshell.cpp:502
void xdg_toplevel_set_parent(Resource *resource, ::wl_resource *parent) override
Definition xdgshell.cpp:396
void xdg_toplevel_unset_fullscreen(Resource *resource) override
Definition xdgshell.cpp:497
void xdg_toplevel_resize(Resource *resource, ::wl_resource *seat, uint32_t serial, uint32_t edges) override
Definition xdgshell.cpp:450
XdgToplevelInterfacePrivate(XdgToplevelInterface *toplevel, XdgSurfaceInterface *surface)
Definition xdgshell.cpp:332
void xdg_toplevel_set_app_id(Resource *resource, const QString &app_id) override
Definition xdgshell.cpp:415
std::optional< quint32 > acknowledgedConfigure
Definition xdgshell_p.h:89
std::optional< QRect > windowGeometry
Definition xdgshell_p.h:88
std::optional< QSize > maximumSize
Definition xdgshell_p.h:95
std::optional< QSize > minimumSize
Definition xdgshell_p.h:94