KWin
Loading...
Searching...
No Matches
xdgshell.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 "kwin_export.h"
10
11#include <QObject>
12#include <QSharedDataPointer>
13
14#include <chrono>
15#include <memory>
16
17struct wl_resource;
18
19namespace KWin
20{
21class Display;
22class OutputInterface;
23class SeatInterface;
24class SurfaceInterface;
25class SurfaceRole;
26class XdgShellInterfacePrivate;
27class XdgSurfaceInterfacePrivate;
28class XdgToplevelInterfacePrivate;
29class XdgPopupInterfacePrivate;
30class XdgPositionerData;
31class XdgToplevelInterface;
32class XdgPopupInterface;
33class XdgSurfaceInterface;
34
44class KWIN_EXPORT XdgShellInterface : public QObject
45{
46 Q_OBJECT
47
48public:
52 XdgShellInterface(Display *display, QObject *parent = nullptr);
56 ~XdgShellInterface() override;
57
61 Display *display() const;
62
68 quint32 ping(XdgSurfaceInterface *surface);
69
73 std::chrono::milliseconds pingTimeoutInterval() const;
74
78 void setPingTimeoutInterval(std::chrono::milliseconds pingTimeout);
79
80Q_SIGNALS:
85
90
94 void pongReceived(quint32 serial);
95
102 void pingTimeout(quint32 serial);
103
108 void pingDelayed(quint32 serial);
109
110private:
111 std::unique_ptr<XdgShellInterfacePrivate> d;
113};
114
121class KWIN_EXPORT XdgSurfaceInterface : public QObject
122{
123 Q_OBJECT
124
125public:
129 XdgSurfaceInterface(XdgShellInterface *shell, SurfaceInterface *surface, ::wl_resource *resource);
133 ~XdgSurfaceInterface() override;
134
140 XdgToplevelInterface *toplevel() const;
141
147 XdgPopupInterface *popup() const;
148
152 XdgShellInterface *shell() const;
153
157 SurfaceInterface *surface() const;
158
162 bool isConfigured() const;
163
169 QRect windowGeometry() const;
170
174 static XdgSurfaceInterface *get(::wl_resource *resource);
175
176Q_SIGNALS:
181
185 void configureAcknowledged(quint32 serial);
186
190 void windowGeometryChanged(const QRect &rect);
191
196
197private:
198 std::unique_ptr<XdgSurfaceInterfacePrivate> d;
200};
201
208class KWIN_EXPORT XdgToplevelInterface : public QObject
209{
210 Q_OBJECT
211
212public:
213 enum State {
214 MaximizedHorizontal = 0x1,
215 MaximizedVertical = 0x2,
216 FullScreen = 0x4,
217 Resizing = 0x8,
218 Activated = 0x10,
219 TiledLeft = 0x20,
220 TiledTop = 0x40,
221 TiledRight = 0x80,
222 TiledBottom = 0x100,
223 Suspended = 0x200,
224 Maximized = MaximizedHorizontal | MaximizedVertical,
225 };
226 Q_DECLARE_FLAGS(States, State)
227
228 enum class ResizeAnchor {
229 None = 0,
230 Top = 1,
231 Bottom = 2,
232 Left = 4,
233 TopLeft = 5,
234 BottomLeft = 6,
235 Right = 8,
236 TopRight = 9,
237 BottomRight = 10,
238 };
239 Q_ENUM(ResizeAnchor)
240
241 enum class Capability {
242 WindowMenu = 0x1,
243 Maximize = 0x2,
244 FullScreen = 0x4,
245 Minimize = 0x8,
246 };
247 Q_DECLARE_FLAGS(Capabilities, Capability)
248
249
252 XdgToplevelInterface(XdgSurfaceInterface *surface, ::wl_resource *resource);
256 ~XdgToplevelInterface() override;
257
258 static SurfaceRole *role();
259
265 XdgShellInterface *shell() const;
266
270 XdgSurfaceInterface *xdgSurface() const;
271
275 SurfaceInterface *surface() const;
276
280 XdgToplevelInterface *parentXdgToplevel() const;
281
285 bool isConfigured() const;
286
290 QString windowTitle() const;
291
295 QString windowClass() const;
296
300 QSize minimumSize() const;
301
305 QSize maximumSize() const;
306
311 quint32 sendConfigure(const QSize &size, const States &states);
312
316 void sendClose();
317
322 void sendConfigureBounds(const QSize &size);
323
327 void sendWmCapabilities(Capabilities capabilities);
328
332 static XdgToplevelInterface *get(::wl_resource *resource);
333
334Q_SIGNALS:
339
345
350
354 void windowTitleChanged(const QString &windowTitle);
355
359 void windowClassChanged(const QString &windowClass);
360
365 void windowMenuRequested(KWin::SeatInterface *seat, const QPoint &pos, quint32 serial);
366
370 void minimumSizeChanged(const QSize &size);
371
375 void maximumSizeChanged(const QSize &size);
376
381 void moveRequested(KWin::SeatInterface *seat, quint32 serial);
382
389
394
399
404
409
414
419
420private:
421 std::unique_ptr<XdgToplevelInterfacePrivate> d;
423};
424
430class KWIN_EXPORT XdgPositioner
431{
432public:
440 XdgPositioner(const XdgPositioner &other);
445
449 XdgPositioner &operator=(const XdgPositioner &other);
450
456 bool isComplete() const;
457
461 QSize size() const;
462
466 bool isReactive() const;
467
472 QRectF placement(const QRectF &bounds) const;
473
477 static XdgPositioner get(::wl_resource *resource);
478
479private:
480 XdgPositioner(const QSharedDataPointer<XdgPositionerData> &data);
481 QSharedDataPointer<XdgPositionerData> d;
482};
483
490class KWIN_EXPORT XdgPopupInterface : public QObject
491{
492 Q_OBJECT
493
494public:
495 XdgPopupInterface(XdgSurfaceInterface *surface, SurfaceInterface *parentSurface, const XdgPositioner &positioner, ::wl_resource *resource);
499 ~XdgPopupInterface() override;
500
501 static SurfaceRole *role();
502
504
509 SurfaceInterface *parentSurface() const;
510
514 XdgSurfaceInterface *xdgSurface() const;
515
519 SurfaceInterface *surface() const;
520
524 XdgPositioner positioner() const;
525
529 bool isConfigured() const;
530
534 quint32 sendConfigure(const QRect &rect);
535
539 void sendPopupDone();
540
544 void sendRepositioned(quint32 token);
545
549 static XdgPopupInterface *get(::wl_resource *resource);
550
551Q_SIGNALS:
556
562 void grabRequested(SeatInterface *seat, quint32 serial);
563 void repositionRequested(quint32 token);
564
565private:
566 std::unique_ptr<XdgPopupInterfacePrivate> d;
568};
569
570} // namespace KWin
571
572Q_DECLARE_OPERATORS_FOR_FLAGS(KWin::XdgToplevelInterface::States)
573Q_DECLARE_OPERATORS_FOR_FLAGS(KWin::XdgToplevelInterface::Capabilities)
575Q_DECLARE_METATYPE(KWin::XdgToplevelInterface::States)
Class holding the Wayland server display loop.
Definition display.h:34
Represents a Seat on the Wayland Display.
Definition seat.h:134
Resource representing a wl_surface.
Definition surface.h:80
void repositionRequested(quint32 token)
void grabRequested(SeatInterface *seat, quint32 serial)
XdgShellInterface * shell() const
void toplevelCreated(XdgToplevelInterface *toplevel)
void popupCreated(XdgPopupInterface *popup)
void pingTimeout(quint32 serial)
void pingDelayed(quint32 serial)
void pongReceived(quint32 serial)
void windowGeometryChanged(const QRect &rect)
void configureAcknowledged(quint32 serial)
void windowClassChanged(const QString &windowClass)
void windowMenuRequested(KWin::SeatInterface *seat, const QPoint &pos, quint32 serial)
void minimumSizeChanged(const QSize &size)
void windowTitleChanged(const QString &windowTitle)
void fullscreenRequested(KWin::OutputInterface *output)
void maximumSizeChanged(const QSize &size)
void moveRequested(KWin::SeatInterface *seat, quint32 serial)
void resizeRequested(KWin::SeatInterface *seat, KWin::XdgToplevelInterface::ResizeAnchor anchor, quint32 serial)
Q_DECLARE_METATYPE(KWin::SwitchEvent::State)
struct _XDisplay Display