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 
130 Q_DECLARE_OPERATORS_FOR_FLAGS(XdgPositioner::Constraints)
131 
132 
156 class KWAYLANDCLIENT_EXPORT XdgShell : public QObject
157 {
158  Q_OBJECT
159 public:
160  virtual ~XdgShell();
161 
167  void setup(xdg_shell *xdgshellv5);
168 
174  void setup(zxdg_shell_v6 *xdgshellv6);
175 
181  void setup(xdg_wm_base *xdg_wm_base);
185  bool isValid() const;
191  void release();
206  void destroy();
207 
211  void setEventQueue(EventQueue *queue);
215  EventQueue *eventQueue();
216 
220  XdgShellSurface *createSurface(Surface *surface, QObject *parent = nullptr);
221 
226  XdgShellPopup *createPopup(Surface *surface, Surface *parentSurface, Seat *seat, quint32 serial, const QPoint &parentPos, QObject *parent = nullptr);
227 
233  XdgShellPopup *createPopup(Surface *surface, XdgShellSurface *parentSurface, const XdgPositioner &positioner, QObject *parent = nullptr);
234 
239  XdgShellPopup *createPopup(Surface *surface, XdgShellPopup *parentSurface, const XdgPositioner &positioner, QObject *parent = nullptr);
240 
241  operator xdg_wm_base*();
242  operator xdg_wm_base*() const;
243  operator xdg_shell*();
244  operator xdg_shell*() const;
245  operator zxdg_shell_v6*();
246  operator zxdg_shell_v6*() const;
247 
248 Q_SIGNALS:
255  void removed();
256 
257 protected:
264  class Private;
265  explicit XdgShell(Private *p, QObject *parent = nullptr);
266 
267 private:
269 };
270 
275 class KWAYLANDCLIENT_EXPORT XdgShellSurface : public QObject
276 {
277  Q_OBJECT
278 public:
279  virtual ~XdgShellSurface();
283  enum class State {
287  Maximized = 1 << 0,
291  Fullscreen = 1 << 1,
295  Resizing = 1 << 2,
299  Activated = 1 << 3
300  };
301  Q_DECLARE_FLAGS(States, State)
302 
303 
308  void setup(xdg_surface *xdgsurfacev5);
309 
315  void setup(zxdg_surface_v6 *xdgsurfacev6, zxdg_toplevel_v6 *toplevel);
316 
322  void setup(xdg_surface *xdgsurface, xdg_toplevel *toplevel);
323 
327  bool isValid() const;
333  void release();
350  void destroy();
354  void setEventQueue(EventQueue *queue);
358  EventQueue *eventQueue();
359 
365  QSize size() const;
366 
376  void setSize(const QSize &size);
377 
381  void setTransientFor(XdgShellSurface *parent);
382 
386  void setTitle(const QString &title);
387 
391  void setAppId(const QByteArray &appId);
392 
396  void requestShowWindowMenu(Seat *seat, quint32 serial, const QPoint &pos);
397 
404  void requestMove(Seat *seat, quint32 serial);
405 
413  void requestResize(Seat *seat, quint32 serial, Qt::Edges edges);
414 
422  void ackConfigure(quint32 serial);
423 
430  void setMaximized(bool set);
431 
440  void setFullscreen(bool set, Output *output = nullptr);
441 
445  void requestMinimize();
446 
451  void setMaxSize(const QSize &size);
452 
457  void setMinSize(const QSize &size);
458 
463  void setWindowGeometry(const QRect &windowGeometry);
464 
465  operator xdg_surface*();
466  operator xdg_surface*() const;
467  operator xdg_toplevel*();
468  operator xdg_toplevel*() const;
469  operator zxdg_surface_v6*();
470  operator zxdg_surface_v6*() const;
471  operator zxdg_toplevel_v6*();
472  operator zxdg_toplevel_v6*() const;
473 
474 Q_SIGNALS:
478  void closeRequested();
483  void configureRequested(const QSize &size, KWayland::Client::XdgShellSurface::States states, quint32 serial);
484 
492  void sizeChanged(const QSize &);
493 
494 protected:
495  class Private;
496  explicit XdgShellSurface(Private *p, QObject *parent = nullptr);
497 
498 private:
500 };
501 
502 Q_DECLARE_OPERATORS_FOR_FLAGS(XdgShellSurface::States)
503 
504 
512 class KWAYLANDCLIENT_EXPORT XdgShellPopup : public QObject
513 {
514  Q_OBJECT
515 public:
516  virtual ~XdgShellPopup();
517 
525  KWAYLANDCLIENT_DEPRECATED_VERSION(5, 49, "Use XDGShell version >5")
526  void setup(xdg_popup *xdgpopupv5);
527 
534  void setup(zxdg_surface_v6 *xdgsurfacev6, zxdg_popup_v6 *xdgpopup6);
535 
542  void setup(xdg_surface *xdgsurface, xdg_popup *xdgpopup);
543 
547  bool isValid() const;
553  void release();
570  void destroy();
574  void setEventQueue(EventQueue *queue);
578  EventQueue *eventQueue();
579 
584  void requestGrab(Seat *seat, quint32 serial);
585 
594  void ackConfigure(quint32 serial);
595 
600  void setWindowGeometry(const QRect &windowGeometry);
601 
602  operator xdg_surface*();
603  operator xdg_surface*() const;
604  operator xdg_popup*();
605  operator xdg_popup*() const;
606  operator zxdg_surface_v6*();
607  operator zxdg_surface_v6*() const;
608  operator zxdg_popup_v6*();
609  operator zxdg_popup_v6*() const;
610 
611 
612 Q_SIGNALS:
617  void popupDone();
618 
624  void configureRequested(const QRect &relativePosition, quint32 serial);
625 
626 
627 protected:
628  class Private;
629  explicit XdgShellPopup(Private *p, QObject *parent = nullptr);
630 
631 private:
633 };
634 
635 }
636 }
637 
638 Q_DECLARE_METATYPE(KWayland::Client::XdgPositioner)
641 Q_DECLARE_METATYPE(KWayland::Client::XdgPositioner::Constraint)
643 
644 
645 #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:156
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:512
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:283
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 Thu Nov 26 2020 22:49:00 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.