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