KWayland

shell_interface.h
1 /*
2  SPDX-FileCopyrightText: 2014 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 WAYLAND_SERVER_SHELL_INTERFACE_H
7 #define WAYLAND_SERVER_SHELL_INTERFACE_H
8 
9 #include <QObject>
10 
11 #include "seat_interface.h"
12 #include <KWayland/Server/kwaylandserver_export.h>
13 
14 #include "global.h"
15 #include "resource.h"
16 
17 class QSize;
18 struct wl_resource;
19 
20 namespace KWayland
21 {
22 namespace Server
23 {
24 class Display;
25 class SeatInterface;
26 class SurfaceInterface;
27 class ShellSurfaceInterface;
28 template<typename T>
29 class GenericShellSurface;
30 
31 /**
32  * @brief Global for the wl_shell interface.
33  *
34  * @see ShellSurfaceInterface
35  * @see SurfaceInterface
36  **/
37 class KWAYLANDSERVER_EXPORT ShellInterface : public Global
38 {
39  Q_OBJECT
40 public:
41  virtual ~ShellInterface();
42 
43 Q_SIGNALS:
44  /**
45  * Emitted whenever a new ShellSurfaceInterface gets created for a SurfaceInterface.
46  **/
47  void surfaceCreated(KWayland::Server::ShellSurfaceInterface *);
48 
49 private:
50  friend class Display;
51  explicit ShellInterface(Display *display, QObject *parent);
52  class Private;
53 };
54 
55 /**
56  * @brief Resource for a wl_shell_surface.
57  *
58  * The ShellSurfaceInterface represents a "normal window". It gets created for a
59  * SurfaceInterface, thus has visible content. Through the ShellSurfaceInterface the
60  * client can specify further meta-information about how the SurfaceInterface should be
61  * represented.
62  *
63  * @see SurfaceInterface
64  * @see ShellInterface
65  **/
66 class KWAYLANDSERVER_EXPORT ShellSurfaceInterface : public Resource
67 {
68  Q_OBJECT
69  /**
70  * The window title
71  **/
72  Q_PROPERTY(QString title READ title NOTIFY titleChanged)
73  /**
74  * The window class, representing the desktop file name.
75  **/
76  Q_PROPERTY(QByteArray windowClass READ windowClass NOTIFY windowClassChanged)
77  /**
78  * Whether the window is fullscreen.
79  **/
80  Q_PROPERTY(bool fullscreen READ isFullscreen NOTIFY fullscreenChanged)
81  /**
82  * Whether the window is a normal toplevel window (not a child).
83  **/
84  Q_PROPERTY(bool toplevel READ isToplevel NOTIFY toplevelChanged)
85  /**
86  * Whether the window is maximized.
87  **/
88  Q_PROPERTY(bool maximized READ isMaximized NOTIFY maximizedChanged)
89  /**
90  * Whether the ShellSurfaceInterface is a popup for another SurfaceInterface.
91  *
92  * Popup implies transient.
93  * @since 5.5
94  **/
95  Q_PROPERTY(bool popup READ isPopup NOTIFY popupChanged)
96  /**
97  * Whether the ShellSurfaceInterface is a transient for another SurfaceInterface.
98  *
99  * Popup implies transient.
100  * @since 5.5
101  **/
102  Q_PROPERTY(bool transient READ isTransient NOTIFY transientChanged)
103  /**
104  * Offset of the upper left corner in the parent SurfaceInterface's coordinate system.
105  * @since 5.5
106  **/
107  Q_PROPERTY(QPoint transientOffset READ transientOffset NOTIFY transientOffsetChanged)
108  /**
109  * Whether the ShellSurfaceInterface can accept keyboard focus.
110  *
111  * By default ShellSurfaceInterface accepts keyboard focus, only transient surfaces
112  * might not want keyboard focus.
113  *
114  * @since 5.5
115  **/
116  Q_PROPERTY(bool acceptsKeyboardFocus READ acceptsKeyboardFocus NOTIFY acceptsKeyboardFocusChanged)
117 public:
118  virtual ~ShellSurfaceInterface();
119 
120  /**
121  * Pings the client.
122  * The client is required to send a pong. If that is not received in the times tamp
123  * set through setPingTimeout the signal @link pingTimeout @endlink will be emitted.
124  * If a pong is received the signal @link pongReceived @endlink will be emitted.
125  *
126  * @see setPingTimeout
127  * @see pingTimeout
128  * @see pongReceived
129  * @see isPinged
130  **/
131  void ping();
132  /**
133  * Sets the ping time out for @link ping @endlink requests to @p msec.
134  *
135  * @param msec The time out in msec
136  * @see ping
137  * @see isPinged
138  **/
139  void setPingTimeout(uint msec);
140  /**
141  * @returns whether the ShellSurfaceInterface got pinged, but no pong received.
142  * @see ping
143  **/
144  bool isPinged() const;
145  /**
146  * Requests that the ShellSurfaceInterface resizes the SurfaceInterface to @p size.
147  **/
148  void requestSize(const QSize &size);
149 
150  /**
151  * @return The SurfaceInterface this ShellSurfaceInterface got created for.
152  **/
153  SurfaceInterface *surface() const;
154  /**
155  * @returns The ShellInterface which created this ShellSurfaceInterface.
156  **/
157  ShellInterface *shell() const;
158 
159  QString title() const;
160  QByteArray windowClass() const;
161  bool isFullscreen() const;
162  bool isToplevel() const;
163  bool isMaximized() const;
164  /**
165  * @returns @c true if the ShellSurfaceInterface is a popup.
166  * @see isTransient
167  * @see transientOffset
168  * @see transientFor
169  * @since 5.5
170  **/
171  bool isPopup() const;
172  /**
173  * @returns @c true if the ShellSurfaceInterface is a transient or popup for another SurfaceInterface.
174  * @see isPopup
175  * @see transientOffset
176  * @see transientFor
177  * @since 5.5
178  **/
179  bool isTransient() const;
180  /**
181  * In case the ShellSurfaceInterface is a transient this is the offset of the ShellSurfaceInterface
182  * in the coordinate system of the SurfaceInterface this surface is a transient for.
183  *
184  * @returns offset in parent coordinate system.
185  * @see isTransient
186  * @see transientFor
187  * @since 5.5
188  **/
189  QPoint transientOffset() const;
190  /**
191  * The SurfaceInterface for which this ShellSurfaceInterface is a transient.
192  * This is only relevant if the ShellSurfaceInterface is either a transient or a
193  * popup.
194  *
195  * The transientOffset is in the local coordinate system of the SurfaceInterface
196  * returned by this method.
197  *
198  * @returns The SurfaceInterface for which this Surface is a transient
199  * @see isTransient
200  * @see isPopup
201  * @see transientOffset
202  * @since 5.5
203  **/
204  QPointer<SurfaceInterface> transientFor() const;
205 
206  /**
207  * Whether the ShellSurfaceInterface can accept keyboard focus.
208  *
209  * This is only relevant for transient and popup windows. By default all ShellSurfaces
210  * accept keyboard focus.
211  *
212  * @returns Whether the ShellSurfaceInterface can accept keyboard focus.
213  * @see isTransient()
214  * @see acceptsKeyboardFocusChanged
215  * @since 5.5
216  **/
217  bool acceptsKeyboardFocus() const;
218 
219  /**
220  * Sends a popup done event to the shell surface.
221  * This is only relevant for popup windows. It indicates that the popup grab
222  * got canceled. This happens when e.g. the user clicks outside of any surface
223  * of the same client as this ShellSurfaceInterface. It is the task of the
224  * compositor to send the popupDone event appropriately.
225  *
226  * @see isPopup
227  * @since 5.33
228  **/
229  void popupDone();
230 
231 Q_SIGNALS:
232  /**
233  * Emitted whenever the title changes.
234  **/
235  void titleChanged(const QString &);
236  /**
237  * Emitted whenever the window class changes.
238  **/
239  void windowClassChanged(const QByteArray &);
240  /**
241  * Emitted when the ping timed out.
242  * @see ping
243  * @see pingTimeout
244  * @see isPinged
245  **/
246  void pingTimeout();
247  /**
248  * Emitted when the server received a pong for this ShellSurfaceInterface.
249  **/
250  void pongReceived();
251  void fullscreenChanged(bool);
252  void toplevelChanged(bool);
253  void maximizedChanged(bool);
254  /**
255  * @since 5.5
256  **/
257  void popupChanged(bool);
258  /**
259  * @since 5.5
260  **/
261  void transientChanged(bool);
262  /**
263  * @since 5.5
264  **/
265  void transientOffsetChanged(const QPoint &);
266  /**
267  * @since 5.5
268  **/
269  void transientForChanged();
270  /**
271  * @since 5.5
272  **/
273  void acceptsKeyboardFocusChanged();
274  /**
275  * The surface requested a window move.
276  *
277  * @param seat The SeatInterface on which the surface requested the move
278  * @param serial The serial of the implicit mouse grab which triggered the move
279  * @since 5.5
280  **/
281  void moveRequested(KWayland::Server::SeatInterface *seat, quint32 serial);
282  /**
283  * The surface requested a window resize.
284  *
285  * @param seat The SeatInterface on which the surface requested the resize
286  * @param serial The serial of the implicit mouse grab which triggered the resize
287  * @param edges A hint which edges are involved in the resize
288  * @since 5.5
289  **/
290  void resizeRequested(KWayland::Server::SeatInterface *seat, quint32 serial, Qt::Edges edges);
291 
292 private:
293  friend class ShellInterface;
294  explicit ShellSurfaceInterface(ShellInterface *shell, SurfaceInterface *parent, wl_resource *parentResource);
295  friend class GenericShellSurface<ShellSurfaceInterface>;
296  class Private;
297  Private *d_func() const;
298 };
299 
300 }
301 }
302 
303 #endif
Represents a Seat on the Wayland Display.
Resource representing a wl_surface.
Class holding the Wayland server display loop.
Definition: display.h:86
Base class for all Globals.
Definition: global.h:46
Represents a bound Resource.
Definition: resource.h:31
Global for the wl_shell interface.
Resource for a wl_shell_surface.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Thu Sep 23 2021 22:51:10 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.