1 | // Copyright (C) 2021 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | #ifndef QWAYLANDQTSHELL_H |
5 | #define QWAYLANDQTSHELL_H |
6 | |
7 | #include <QtWaylandCompositor/QWaylandCompositorExtension> |
8 | #include <QtWaylandCompositor/QWaylandSurface> |
9 | #include <QtWaylandCompositor/QWaylandResource> |
10 | #include <QtCore/QSize> |
11 | |
12 | #include <QtWaylandCompositor/QWaylandShellSurface> |
13 | #include <QtWaylandCompositor/qwaylandquickchildren.h> |
14 | #include <QtWaylandCompositor/qwaylandquickextension.h> |
15 | |
16 | struct wl_resource; |
17 | struct wl_interface; |
18 | |
19 | QT_BEGIN_NAMESPACE |
20 | |
21 | class QWaylandQtShellPrivate; |
22 | class QWaylandQtShellSurface; |
23 | class QWaylandQtShellChrome; |
24 | |
25 | class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandQtShell : public QWaylandCompositorExtensionTemplate<QWaylandQtShell> |
26 | { |
27 | Q_OBJECT |
28 | Q_DECLARE_PRIVATE(QWaylandQtShell) |
29 | |
30 | public: |
31 | QWaylandQtShell(); |
32 | QWaylandQtShell(QWaylandCompositor *compositor); |
33 | |
34 | void initialize() override; |
35 | |
36 | static const struct wl_interface *interface(); |
37 | static QByteArray interfaceName(); |
38 | |
39 | void registerChrome(QWaylandQtShellChrome *chrome); |
40 | void unregisterChrome(QWaylandQtShellChrome *chrome); |
41 | |
42 | private Q_SLOTS: |
43 | void chromeActivated(); |
44 | void chromeDeactivated(); |
45 | |
46 | Q_SIGNALS: |
47 | void qtShellSurfaceRequested(QWaylandSurface *surface, const QWaylandResource &resource); |
48 | void qtShellSurfaceCreated(QWaylandQtShellSurface *qtShellSurface); |
49 | |
50 | private: |
51 | bool moveChromeToFront(QWaylandQtShellChrome *chrome); |
52 | }; |
53 | |
54 | Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_NAMED_ELEMENT(QWaylandQtShell, QtShell, 1, 0) |
55 | |
56 | |
57 | class QWaylandQtShellSurfacePrivate; |
58 | class QWaylandSurfaceRole; |
59 | class QWaylandResource; |
60 | |
61 | class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandQtShellSurface : public QWaylandShellSurfaceTemplate<QWaylandQtShellSurface> |
62 | { |
63 | Q_OBJECT |
64 | QML_NAMED_ELEMENT(QtShellSurface) |
65 | QML_ADDED_IN_VERSION(1, 0) |
66 | Q_DECLARE_PRIVATE(QWaylandQtShellSurface) |
67 | Q_WAYLAND_COMPOSITOR_DECLARE_QUICK_CHILDREN(QWaylandQtShellSurface) |
68 | Q_PROPERTY(QWaylandSurface *surface READ surface NOTIFY surfaceChanged) |
69 | Q_PROPERTY(uint windowFlags READ windowFlags NOTIFY windowFlagsChanged) |
70 | Q_PROPERTY(uint windowState READ windowState NOTIFY windowStateChanged) |
71 | Q_PROPERTY(QString windowTitle READ windowTitle READ windowTitle NOTIFY windowTitleChanged) |
72 | Q_PROPERTY(QRect windowGeometry READ windowGeometry NOTIFY windowGeometryChanged) |
73 | Q_PROPERTY(QPoint windowPosition READ windowPosition WRITE setWindowPosition NOTIFY windowGeometryChanged) |
74 | Q_PROPERTY(bool positionAutomatic READ positionAutomatic NOTIFY positionAutomaticChanged) |
75 | Q_PROPERTY(QSize minimumSize READ minimumSize NOTIFY minimumSizeChanged) |
76 | Q_PROPERTY(QSize maximumSize READ maximumSize NOTIFY maximumSizeChanged) |
77 | Q_PROPERTY(int frameMarginLeft READ frameMarginLeft WRITE setFrameMarginLeft NOTIFY frameMarginChanged) |
78 | Q_PROPERTY(int frameMarginRight READ frameMarginRight WRITE setFrameMarginRight NOTIFY frameMarginChanged) |
79 | Q_PROPERTY(int frameMarginTop READ frameMarginTop WRITE setFrameMarginTop NOTIFY frameMarginChanged) |
80 | Q_PROPERTY(int frameMarginBottom READ frameMarginBottom WRITE setFrameMarginBottom NOTIFY frameMarginChanged) |
81 | Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged) |
82 | Q_PROPERTY(CapabilityFlags capabilities READ capabilities WRITE setCapabilities NOTIFY capabilitiesChanged) |
83 | Q_MOC_INCLUDE("qwaylandsurface.h" ) |
84 | |
85 | public: |
86 | // Matches the "capabilities" enum in the protocol xml |
87 | enum CapabilityFlag { |
88 | InteractiveMove = 1, |
89 | InteractiveResize = 2 |
90 | }; |
91 | Q_DECLARE_FLAGS(CapabilityFlags, CapabilityFlag) |
92 | Q_ENUM(CapabilityFlag) |
93 | |
94 | QWaylandQtShellSurface(); |
95 | QWaylandQtShellSurface(QWaylandQtShell *application, QWaylandSurface *surface, const QWaylandResource &resource); |
96 | |
97 | void initialize(QWaylandQtShell *qtShell, QWaylandSurface *surface, |
98 | const QWaylandResource &resource); |
99 | |
100 | QWaylandSurface *surface() const; |
101 | |
102 | static const wl_interface *interface(); |
103 | static QByteArray interfaceName(); |
104 | static QWaylandSurfaceRole *role(); |
105 | static QWaylandQtShellSurface *fromResource(::wl_resource *resource); |
106 | |
107 | QRect windowGeometry() const; |
108 | |
109 | void setWindowPosition(const QPoint &position); |
110 | QPoint windowPosition() const; |
111 | |
112 | Q_INVOKABLE void requestWindowGeometry(uint windowState, const QRect &windowGeometry); |
113 | |
114 | QSize minimumSize() const; |
115 | QSize maximumSize() const; |
116 | |
117 | void setFrameMargins(const QMargins &margins); |
118 | |
119 | int frameMarginLeft() const; |
120 | void setFrameMarginLeft(int left); |
121 | |
122 | int frameMarginRight() const; |
123 | void setFrameMarginRight(int right); |
124 | |
125 | int frameMarginTop() const; |
126 | void setFrameMarginTop(int top); |
127 | |
128 | int frameMarginBottom() const; |
129 | void setFrameMarginBottom(int bottom); |
130 | |
131 | bool positionAutomatic() const; |
132 | |
133 | bool active() const; |
134 | void setActive(bool active); |
135 | |
136 | QString windowTitle() const; |
137 | |
138 | uint windowFlags() const; |
139 | |
140 | Q_INVOKABLE void sendClose(); |
141 | |
142 | uint windowState() const; |
143 | void setWindowState(uint windowState); |
144 | #if QT_CONFIG(wayland_compositor_quick) |
145 | QWaylandQuickShellIntegration *createIntegration(QWaylandQuickShellSurfaceItem *item) override; |
146 | #endif |
147 | |
148 | CapabilityFlags capabilities() const; |
149 | void setCapabilities(CapabilityFlags capabilities); |
150 | |
151 | Q_SIGNALS: |
152 | void surfaceChanged(); |
153 | void windowFlagsChanged(); |
154 | void windowStateChanged(); |
155 | void windowGeometryChanged(); |
156 | void minimumSizeChanged(); |
157 | void maximumSizeChanged(); |
158 | void positionAutomaticChanged(); |
159 | void startMove(); |
160 | void startResize(Qt::Edges edges); |
161 | void windowTitleChanged(); |
162 | void frameMarginChanged(); |
163 | void raiseRequested(); |
164 | void lowerRequested(); |
165 | void activeChanged(); |
166 | void capabilitiesChanged(); |
167 | |
168 | private Q_SLOTS: |
169 | void surfaceCommitted(); |
170 | |
171 | private: |
172 | friend class QWaylandQtShellChrome; |
173 | |
174 | void initialize() override; |
175 | |
176 | QWaylandQtShell *shell() const; |
177 | }; |
178 | |
179 | QT_END_NAMESPACE |
180 | |
181 | #endif // QWAYLANDQTSHELL_H |
182 | |