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