KWayland

xdgshell.h
1 /*
2  SPDX-FileCopyrightText: 2016 Martin Gräßlin <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5 */
6 #ifndef KWAYLAND_CLIENT_XDG_SHELL_H
7 #define KWAYLAND_CLIENT_XDG_SHELL_H
8 
9 #include <QObject>
10 #include <QSize>
11 #include <QRect>
12 #include <KWayland/Client/kwaylandclient_export.h>
13 
14 //This is a mix of structs for both xdgshell unstable v5 AND xdg wm base stable
15 struct xdg_wm_base;
16 struct xdg_shell;
17 struct xdg_surface;
18 struct xdg_popup;
19 struct xdg_toplevel;
20 
21 struct zxdg_shell_v6;
22 struct zxdg_toplevel_v6;
23 struct zxdg_surface_v6;
24 struct zxdg_popup_v6;
25 struct zxdg_position_v6;
26 
27 namespace KWayland
28 {
29 namespace Client
30 {
31 
32 class EventQueue;
33 class Output;
34 class Surface;
35 class Seat;
36 class XdgShellPopup;
37 class XdgShellSurface;
38 
45 class KWAYLANDCLIENT_EXPORT XdgPositioner
46 {
47 public:
48  /*
49  * Flags describing how a popup should be reposition if constrained
50  */
51  enum class Constraint {
52  /*
53  * Slide the popup on the X axis until there is room
54  */
55  SlideX = 1 << 0,
56  /*
57  * Slide the popup on the Y axis until there is room
58  */
59  SlideY = 1 << 1,
60  /*
61  * Invert the anchor and gravity on the X axis
62  */
63  FlipX = 1 << 2,
64  /*
65  * Invert the anchor and gravity on the Y axis
66  */
67  FlipY = 1 << 3,
68  /*
69  * Resize the popup in the X axis
70  */
71  ResizeX = 1 << 4,
72  /*
73  * Resize the popup in the Y axis
74  */
75  ResizeY = 1 << 5
76  };
77 
78  Q_DECLARE_FLAGS(Constraints, Constraint)
79 
80  XdgPositioner(const QSize &initialSize = QSize(), const QRect &anchor = QRect());
81  XdgPositioner(const XdgPositioner &other);
82  ~XdgPositioner();
83 
87  //KF6 TODO use a better data type (enum of 8 options) rather than flags which allow invalid values
88  Qt::Edges anchorEdge() const;
89  void setAnchorEdge(Qt::Edges edge);
90 
97  //KF6 TODO use a better data type (enum of 8 options) rather than flags which allow invalid values
98  Qt::Edges gravity() const;
99  void setGravity(Qt::Edges edge);
100 
104  QRect anchorRect() const;
105  void setAnchorRect(const QRect &anchor);
106 
110  QSize initialSize() const;
111  void setInitialSize(const QSize &size);
112 
116  Constraints constraints() const;
117  void setConstraints(Constraints constraints);
118 
122  QPoint anchorOffset() const;
123  void setAnchorOffset(const QPoint &offset);
124 
125 private:
126  class Private;
128 };
129 
154 class KWAYLANDCLIENT_EXPORT XdgShell : public QObject
155 {
156  Q_OBJECT
157 public:
158  virtual ~XdgShell();
159 
165  void setup(xdg_shell *xdgshellv5);
166 
172  void setup(zxdg_shell_v6 *xdgshellv6);
173 
179  void setup(xdg_wm_base *xdg_wm_base);
183  bool isValid() const;
189  void release();
204  void destroy();
205 
209  void setEventQueue(EventQueue *queue);
213  EventQueue *eventQueue();
214 
218  XdgShellSurface *createSurface(Surface *surface, QObject *parent = nullptr);
219 
224  XdgShellPopup *createPopup(Surface *surface, Surface *parentSurface, Seat *seat, quint32 serial, const QPoint &parentPos, QObject *parent = nullptr);
225 
231  XdgShellPopup *createPopup(Surface *surface, XdgShellSurface *parentSurface, const XdgPositioner &positioner, QObject *parent = nullptr);
232 
237  XdgShellPopup *createPopup(Surface *surface, XdgShellPopup *parentSurface, const XdgPositioner &positioner, QObject *parent = nullptr);
238 
239  operator xdg_wm_base*();
240  operator xdg_wm_base*() const;
241  operator xdg_shell*();
242  operator xdg_shell*() const;
243  operator zxdg_shell_v6*();
244  operator zxdg_shell_v6*() const;
245 
246 Q_SIGNALS:
253  void removed();
254 
255 protected:
262  class Private;
263  explicit XdgShell(Private *p, QObject *parent = nullptr);
264 
265 private:
267 };
268 
273 class KWAYLANDCLIENT_EXPORT XdgShellSurface : public QObject
274 {
275  Q_OBJECT
276 public:
277  virtual ~XdgShellSurface();
281  enum class State {
285  Maximized = 1 << 0,
289  Fullscreen = 1 << 1,
293  Resizing = 1 << 2,
297  Activated = 1 << 3
298  };
299  Q_DECLARE_FLAGS(States, State)
300 
301 
306  void setup(xdg_surface *xdgsurfacev5);
307 
313  void setup(zxdg_surface_v6 *xdgsurfacev6, zxdg_toplevel_v6 *toplevel);
314 
320  void setup(xdg_surface *xdgsurface, xdg_toplevel *toplevel);
321 
325  bool isValid() const;
331  void release();
348  void destroy();
352  void setEventQueue(EventQueue *queue);
356  EventQueue *eventQueue();
357 
363  QSize size() const;
364 
374  void setSize(const QSize &size);
375 
379  void setTransientFor(XdgShellSurface *parent);
380 
384  void setTitle(const QString &title);
385 
389  void setAppId(const QByteArray &appId);
390 
394  void requestShowWindowMenu(Seat *seat, quint32 serial, const QPoint &pos);
395 
402  void requestMove(Seat *seat, quint32 serial);
403 
411  void requestResize(Seat *seat, quint32 serial, Qt::Edges edges);
412 
420  void ackConfigure(quint32 serial);
421 
428  void setMaximized(bool set);
429 
438  void setFullscreen(bool set, Output *output = nullptr);
439 
443  void requestMinimize();
444 
449  void setMaxSize(const QSize &size);
450 
455  void setMinSize(const QSize &size);
456 
461  void setWindowGeometry(const QRect &windowGeometry);
462 
463  operator xdg_surface*();
464  operator xdg_surface*() const;
465  operator xdg_toplevel*();
466  operator xdg_toplevel*() const;
467  operator zxdg_surface_v6*();
468  operator zxdg_surface_v6*() const;
469  operator zxdg_toplevel_v6*();
470  operator zxdg_toplevel_v6*() const;
471 
472 Q_SIGNALS:
476  void closeRequested();
481  void configureRequested(const QSize &size, KWayland::Client::XdgShellSurface::States states, quint32 serial);
482 
490  void sizeChanged(const QSize &);
491 
492 protected:
493  class Private;
494  explicit XdgShellSurface(Private *p, QObject *parent = nullptr);
495 
496 private:
498 };
499 
508 class KWAYLANDCLIENT_EXPORT XdgShellPopup : public QObject
509 {
510  Q_OBJECT
511 public:
512  virtual ~XdgShellPopup();
513 
521  KWAYLANDCLIENT_DEPRECATED_VERSION(5, 49, "Use XDGShell version >5")
522  void setup(xdg_popup *xdgpopupv5);
523 
530  void setup(zxdg_surface_v6 *xdgsurfacev6, zxdg_popup_v6 *xdgpopup6);
531 
538  void setup(xdg_surface *xdgsurface, xdg_popup *xdgpopup);
539 
543  bool isValid() const;
549  void release();
566  void destroy();
570  void setEventQueue(EventQueue *queue);
574  EventQueue *eventQueue();
575 
580  void requestGrab(Seat *seat, quint32 serial);
581 
590  void ackConfigure(quint32 serial);
591 
596  void setWindowGeometry(const QRect &windowGeometry);
597 
598  operator xdg_surface*();
599  operator xdg_surface*() const;
600  operator xdg_popup*();
601  operator xdg_popup*() const;
602  operator zxdg_surface_v6*();
603  operator zxdg_surface_v6*() const;
604  operator zxdg_popup_v6*();
605  operator zxdg_popup_v6*() const;
606 
607 
608 Q_SIGNALS:
613  void popupDone();
614 
620  void configureRequested(const QRect &relativePosition, quint32 serial);
621 
622 
623 protected:
624  class Private;
625  explicit XdgShellPopup(Private *p, QObject *parent = nullptr);
626 
627 private:
629 };
630 
631 }
632 }
633 
634 Q_DECLARE_OPERATORS_FOR_FLAGS(KWayland::Client::XdgShellSurface::States)
635 Q_DECLARE_OPERATORS_FOR_FLAGS(KWayland::Client::XdgPositioner::Constraints)
636 
637 Q_DECLARE_METATYPE(KWayland::Client::XdgPositioner)
640 Q_DECLARE_METATYPE(KWayland::Client::XdgPositioner::Constraint)
642 
643 
644 #endif
Builder class describing how a popup should be positioned when created.
Definition: xdgshell.h:45
typedef Edges
Wrapper for the xdg_shell interface.
Definition: xdgshell.h:154
Wrapper class for wl_event_queue interface.
Definition: event_queue.h:55
A XdgShellPopup is a short-lived, temporary surface that can be used to implement menus...
Definition: xdgshell.h:508
Wrapper for the wl_seat interface.
Definition: seat.h:52
Wrapper for the wl_output interface.
Definition: output.h:55
State
States the Surface can be in.
Definition: xdgshell.h:281
Wrapper for the wl_surface interface.
Definition: surface.h:44
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sun Aug 2 2020 22:49:10 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.