1/*
2 SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6#include "../compat/wayland-xdg-shell-v5-client-protocol.h"
7#include "event_queue.h"
8#include "output.h"
9#include "seat.h"
10#include "surface.h"
11#include "wayland_pointer_p.h"
12#include "xdgshell_p.h"
13
14namespace KWayland
15{
16namespace Client
17{
18XdgShell::Private::~Private() = default;
19
20XdgShell::XdgShell(Private *p, QObject *parent)
21 : QObject(parent)
22 , d(p)
23{
24}
25
26XdgShell::~XdgShell()
27{
28 release();
29}
30
31void XdgShell::setup(xdg_shell *xdgshellv5)
32{
33 d->setupV5(xdgshellv5);
34}
35
36void XdgShell::setup(zxdg_shell_v6 *xdgshellv6)
37{
38 d->setupV6(xdgshellv6);
39}
40
41void XdgShell::setup(xdg_wm_base *xdg_wm_base)
42{
43 d->setup(xdg_wm_base);
44}
45
46void XdgShell::release()
47{
48 d->release();
49}
50
51void XdgShell::destroy()
52{
53 d->destroy();
54}
55
56void XdgShell::setEventQueue(EventQueue *queue)
57{
58 d->queue = queue;
59}
60
61EventQueue *XdgShell::eventQueue()
62{
63 return d->queue;
64}
65
66XdgShell::operator xdg_shell *()
67{
68 return *(d.data());
69}
70
71XdgShell::operator xdg_shell *() const
72{
73 return *(d.data());
74}
75
76XdgShell::operator zxdg_shell_v6 *()
77{
78 return *(d.data());
79}
80
81XdgShell::operator zxdg_shell_v6 *() const
82{
83 return *(d.data());
84}
85
86XdgShell::operator xdg_wm_base *()
87{
88 return *(d.data());
89}
90
91XdgShell::operator xdg_wm_base *() const
92{
93 return *(d.data());
94}
95
96bool XdgShell::isValid() const
97{
98 return d->isValid();
99}
100
101XdgShellSurface *XdgShell::createSurface(Surface *surface, QObject *parent)
102{
103 return d->getXdgSurface(surface, parent);
104}
105
106XdgShellPopup *XdgShell::createPopup(Surface *surface, Surface *parentSurface, Seat *seat, quint32 serial, const QPoint &parentPos, QObject *parent)
107{
108 return d->getXdgPopup(surface, parentSurface, seat, serial, parentPos, parent);
109}
110
111XdgShellPopup *XdgShell::createPopup(Surface *surface, XdgShellSurface *parentSurface, const XdgPositioner &positioner, QObject *parent)
112{
113 return d->getXdgPopup(surface, parentSurface, positioner, parent);
114}
115
116XdgShellPopup *XdgShell::createPopup(Surface *surface, XdgShellPopup *parentSurface, const XdgPositioner &positioner, QObject *parent)
117{
118 return d->getXdgPopup(surface, parentSurface, positioner, parent);
119}
120
121XdgShellSurface::Private::Private(XdgShellSurface *q)
122 : q(q)
123{
124}
125
126XdgShellSurface::Private::~Private() = default;
127
128XdgShellSurface::XdgShellSurface(Private *p, QObject *parent)
129 : QObject(parent)
130 , d(p)
131{
132}
133
134XdgShellSurface::~XdgShellSurface()
135{
136 release();
137}
138
139void XdgShellSurface::setup(xdg_surface *xdgsurfacev5)
140{
141 d->setupV5(xdgsurfacev5);
142}
143
144void XdgShellSurface::setup(zxdg_surface_v6 *xdgsurfacev6, zxdg_toplevel_v6 *xdgtoplevelv6)
145{
146 d->setupV6(surface: xdgsurfacev6, toplevel: xdgtoplevelv6);
147}
148
149void XdgShellSurface::setup(xdg_surface *xdgsurface, xdg_toplevel *xdgtoplevel)
150{
151 d->setup(surface: xdgsurface, toplevel: xdgtoplevel);
152}
153
154void XdgShellSurface::release()
155{
156 d->release();
157}
158
159void XdgShellSurface::destroy()
160{
161 d->destroy();
162}
163
164void XdgShellSurface::setEventQueue(EventQueue *queue)
165{
166 d->queue = queue;
167}
168
169EventQueue *XdgShellSurface::eventQueue()
170{
171 return d->queue;
172}
173
174XdgShellSurface::operator xdg_surface *()
175{
176 return *(d.data());
177}
178
179XdgShellSurface::operator xdg_surface *() const
180{
181 return *(d.data());
182}
183
184XdgShellSurface::operator xdg_toplevel *()
185{
186 return *(d.data());
187}
188
189XdgShellSurface::operator xdg_toplevel *() const
190{
191 return *(d.data());
192}
193
194XdgShellSurface::operator zxdg_surface_v6 *()
195{
196 return *(d.data());
197}
198
199XdgShellSurface::operator zxdg_surface_v6 *() const
200{
201 return *(d.data());
202}
203
204XdgShellSurface::operator zxdg_toplevel_v6 *()
205{
206 return *(d.data());
207}
208
209XdgShellSurface::operator zxdg_toplevel_v6 *() const
210{
211 return *(d.data());
212}
213
214bool XdgShellSurface::isValid() const
215{
216 return d->isValid();
217}
218
219void XdgShellSurface::setTransientFor(XdgShellSurface *parent)
220{
221 d->setTransientFor(parent);
222}
223
224void XdgShellSurface::setTitle(const QString &title)
225{
226 d->setTitle(title);
227}
228
229void XdgShellSurface::setAppId(const QByteArray &appId)
230{
231 d->setAppId(appId);
232}
233
234void XdgShellSurface::requestShowWindowMenu(Seat *seat, quint32 serial, const QPoint &pos)
235{
236 d->showWindowMenu(seat, serial, x: pos.x(), y: pos.y());
237}
238
239void XdgShellSurface::requestMove(Seat *seat, quint32 serial)
240{
241 d->move(seat, serial);
242}
243
244void XdgShellSurface::requestResize(Seat *seat, quint32 serial, Qt::Edges edges)
245{
246 d->resize(seat, serial, edges);
247}
248
249void XdgShellSurface::ackConfigure(quint32 serial)
250{
251 d->ackConfigure(serial);
252}
253
254void XdgShellSurface::setMaximized(bool set)
255{
256 if (set) {
257 d->setMaximized();
258 } else {
259 d->unsetMaximized();
260 }
261}
262
263void XdgShellSurface::setFullscreen(bool set, Output *output)
264{
265 if (set) {
266 d->setFullscreen(output);
267 } else {
268 d->unsetFullscreen();
269 }
270}
271
272void XdgShellSurface::setMaxSize(const QSize &size)
273{
274 d->setMaxSize(size);
275}
276
277void XdgShellSurface::setMinSize(const QSize &size)
278{
279 d->setMinSize(size);
280}
281
282void XdgShellSurface::setWindowGeometry(const QRect &windowGeometry)
283{
284 d->setWindowGeometry(windowGeometry);
285}
286
287void XdgShellSurface::requestMinimize()
288{
289 d->setMinimized();
290}
291
292void XdgShellSurface::setSize(const QSize &size)
293{
294 if (d->size == size) {
295 return;
296 }
297 d->size = size;
298 Q_EMIT sizeChanged(size);
299}
300
301QSize XdgShellSurface::size() const
302{
303 return d->size;
304}
305
306XdgShellPopup::Private::~Private() = default;
307
308XdgShellPopup::Private::Private(XdgShellPopup *q)
309 : q(q)
310{
311}
312
313XdgShellPopup::XdgShellPopup(Private *p, QObject *parent)
314 : QObject(parent)
315 , d(p)
316{
317}
318
319XdgShellPopup::~XdgShellPopup()
320{
321 release();
322}
323
324void XdgShellPopup::setup(xdg_popup *xdgpopupv5)
325{
326 d->setupV5(xdgpopupv5);
327}
328
329void XdgShellPopup::setup(zxdg_surface_v6 *xdgsurfacev6, zxdg_popup_v6 *xdgpopupv6)
330{
331 d->setupV6(s: xdgsurfacev6, p: xdgpopupv6);
332}
333
334void XdgShellPopup::setup(xdg_surface *surface, xdg_popup *popup)
335{
336 d->setup(s: surface, p: popup);
337}
338
339void XdgShellPopup::release()
340{
341 d->release();
342}
343
344void XdgShellPopup::destroy()
345{
346 d->destroy();
347}
348
349void XdgShellPopup::setEventQueue(EventQueue *queue)
350{
351 d->queue = queue;
352}
353
354EventQueue *XdgShellPopup::eventQueue()
355{
356 return d->queue;
357}
358
359void XdgShellPopup::requestGrab(KWayland::Client::Seat *seat, quint32 serial)
360{
361 d->requestGrab(seat, serial);
362}
363
364void XdgShellPopup::ackConfigure(quint32 serial)
365{
366 d->ackConfigure(serial);
367}
368
369void XdgShellPopup::setWindowGeometry(const QRect &windowGeometry)
370{
371 d->setWindowGeometry(windowGeometry);
372}
373
374XdgShellPopup::operator xdg_surface *()
375{
376 return *(d.data());
377}
378
379XdgShellPopup::operator xdg_surface *() const
380{
381 return *(d.data());
382}
383
384XdgShellPopup::operator xdg_popup *()
385{
386 return *(d.data());
387}
388
389XdgShellPopup::operator xdg_popup *() const
390{
391 return *(d.data());
392}
393
394XdgShellPopup::operator zxdg_surface_v6 *()
395{
396 return *(d.data());
397}
398
399XdgShellPopup::operator zxdg_surface_v6 *() const
400{
401 return *(d.data());
402}
403
404XdgShellPopup::operator zxdg_popup_v6 *()
405{
406 return *(d.data());
407}
408
409XdgShellPopup::operator zxdg_popup_v6 *() const
410{
411 return *(d.data());
412}
413
414bool XdgShellPopup::isValid() const
415{
416 return d->isValid();
417}
418
419XdgPositioner::XdgPositioner(const QSize &initialSize, const QRect &anchor)
420 : d(new Private)
421{
422 d->initialSize = initialSize;
423 d->anchorRect = anchor;
424}
425
426XdgPositioner::XdgPositioner(const XdgPositioner &other)
427 : d(new Private)
428{
429 *d = *other.d;
430}
431
432XdgPositioner::~XdgPositioner()
433{
434}
435
436void XdgPositioner::setInitialSize(const QSize &size)
437{
438 d->initialSize = size;
439}
440
441QSize XdgPositioner::initialSize() const
442{
443 return d->initialSize;
444}
445
446void XdgPositioner::setAnchorRect(const QRect &anchor)
447{
448 d->anchorRect = anchor;
449}
450
451QRect XdgPositioner::anchorRect() const
452{
453 return d->anchorRect;
454}
455
456void XdgPositioner::setAnchorEdge(Qt::Edges edge)
457{
458 d->anchorEdge = edge;
459}
460
461Qt::Edges XdgPositioner::anchorEdge() const
462{
463 return d->anchorEdge;
464}
465
466void XdgPositioner::setAnchorOffset(const QPoint &offset)
467{
468 d->anchorOffset = offset;
469}
470
471QPoint XdgPositioner::anchorOffset() const
472{
473 return d->anchorOffset;
474}
475
476void XdgPositioner::setGravity(Qt::Edges edge)
477{
478 d->gravity = edge;
479}
480
481Qt::Edges XdgPositioner::gravity() const
482{
483 return d->gravity;
484}
485
486void XdgPositioner::setConstraints(Constraints constraints)
487{
488 d->constraints = constraints;
489}
490
491XdgPositioner::Constraints XdgPositioner::constraints() const
492{
493 return d->constraints;
494}
495
496}
497}
498
499#include "moc_xdgshell.cpp"
500#include "moc_xdgshell_p.cpp"
501

source code of kwayland/src/client/xdgshell.cpp