1// Copyright (C) 2017 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QWAYLANDWLSHELL_H
5#define QWAYLANDWLSHELL_H
6
7#include <QtWaylandCompositor/QWaylandCompositorExtension>
8#include <QtWaylandCompositor/QWaylandResource>
9#include <QtWaylandCompositor/QWaylandShell>
10#include <QtWaylandCompositor/QWaylandShellSurface>
11#if QT_CONFIG(wayland_compositor_quick)
12#include <QtWaylandCompositor/qwaylandquickchildren.h>
13#endif
14
15#include <QtCore/QSize>
16
17QT_BEGIN_NAMESPACE
18
19class QWaylandWlShellPrivate;
20class QWaylandWlShellSurfacePrivate;
21class QWaylandSurface;
22class QWaylandClient;
23class QWaylandSeat;
24class QWaylandOutput;
25class QWaylandSurfaceRole;
26class QWaylandWlShellSurface;
27
28class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandWlShell : public QWaylandShellTemplate<QWaylandWlShell>
29{
30 Q_OBJECT
31 Q_DECLARE_PRIVATE(QWaylandWlShell)
32public:
33 QWaylandWlShell();
34 QWaylandWlShell(QWaylandCompositor *compositor);
35
36 void initialize() override;
37 QList<QWaylandWlShellSurface *> shellSurfaces() const;
38 QList<QWaylandWlShellSurface *> shellSurfacesForClient(QWaylandClient* client) const;
39 QList<QWaylandWlShellSurface *> mappedPopups() const;
40 QWaylandClient *popupClient() const;
41
42 static const struct wl_interface *interface();
43 static QByteArray interfaceName();
44
45public Q_SLOTS:
46 void closeAllPopups();
47
48Q_SIGNALS:
49 void wlShellSurfaceRequested(QWaylandSurface *surface, const QWaylandResource &resource);
50 void wlShellSurfaceCreated(QWaylandWlShellSurface *shellSurface);
51};
52
53class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandWlShellSurface : public QWaylandShellSurfaceTemplate<QWaylandWlShellSurface>
54{
55 Q_OBJECT
56 Q_DECLARE_PRIVATE(QWaylandWlShellSurface)
57#if QT_CONFIG(wayland_compositor_quick)
58 Q_WAYLAND_COMPOSITOR_DECLARE_QUICK_CHILDREN(QWaylandWlShellSurface)
59#endif
60 Q_PROPERTY(QWaylandSurface *surface READ surface NOTIFY surfaceChanged)
61 Q_PROPERTY(QWaylandWlShell *shell READ shell NOTIFY shellChanged)
62 Q_PROPERTY(QString title READ title NOTIFY titleChanged)
63 Q_PROPERTY(QString className READ className NOTIFY classNameChanged)
64 Q_MOC_INCLUDE("qwaylandsurface.h")
65
66public:
67 enum FullScreenMethod {
68 DefaultFullScreen,
69 ScaleFullScreen,
70 DriverFullScreen,
71 FillFullScreen
72 };
73 Q_ENUM(FullScreenMethod);
74
75 enum ResizeEdge {
76 NoneEdge = 0,
77 TopEdge = 1,
78 BottomEdge = 2,
79 LeftEdge = 4,
80 TopLeftEdge = 5,
81 BottomLeftEdge = 6,
82 RightEdge = 8,
83 TopRightEdge = 9,
84 BottomRightEdge = 10
85 };
86 Q_ENUM(ResizeEdge);
87
88 QWaylandWlShellSurface();
89 QWaylandWlShellSurface(QWaylandWlShell *shell, QWaylandSurface *surface, const QWaylandResource &resource);
90 ~QWaylandWlShellSurface() override;
91
92 Q_INVOKABLE void initialize(QWaylandWlShell *shell, QWaylandSurface *surface, const QWaylandResource &resource);
93
94 QString title() const;
95 QString className() const;
96
97 QWaylandSurface *surface() const;
98 QWaylandWlShell *shell() const;
99
100 Qt::WindowType windowType() const override;
101
102 static const struct wl_interface *interface();
103 static QByteArray interfaceName();
104 static QWaylandSurfaceRole *role();
105
106 static QWaylandWlShellSurface *fromResource(wl_resource *res);
107
108 Q_INVOKABLE QSize sizeForResize(const QSizeF &size, const QPointF &delta, ResizeEdge edges);
109 Q_INVOKABLE void sendConfigure(const QSize &size, ResizeEdge edges);
110 Q_INVOKABLE void sendPopupDone();
111
112#if QT_CONFIG(wayland_compositor_quick)
113 QWaylandQuickShellIntegration *createIntegration(QWaylandQuickShellSurfaceItem *item) override;
114#endif
115
116public Q_SLOTS:
117 void ping();
118
119Q_SIGNALS:
120 void surfaceChanged();
121 void shellChanged();
122 void titleChanged();
123 void classNameChanged();
124 void pong();
125 void startMove(QWaylandSeat *seat);
126 void startResize(QWaylandSeat *seat, ResizeEdge edges);
127
128 void setDefaultToplevel();
129 void setTransient(QWaylandSurface *parentSurface, const QPoint &relativeToParent, bool inactive);
130 void setFullScreen(FullScreenMethod method, uint framerate, QWaylandOutput *output);
131 void setPopup(QWaylandSeat *seat, QWaylandSurface *parentSurface, const QPoint &relativeToParent);
132 void setMaximized(QWaylandOutput *output);
133
134private:
135 void initialize() override;
136};
137
138QT_END_NAMESPACE
139
140#endif /*QWAYLANDWLSHELL_H*/
141

source code of qtwayland/src/compositor/extensions/qwaylandwlshell.h