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
16struct wl_resource;
17struct wl_interface;
18
19QT_BEGIN_NAMESPACE
20
21class QWaylandQtShellPrivate;
22class QWaylandQtShellSurface;
23class QWaylandQtShellChrome;
24
25class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandQtShell : public QWaylandCompositorExtensionTemplate<QWaylandQtShell>
26{
27 Q_OBJECT
28 Q_DECLARE_PRIVATE(QWaylandQtShell)
29
30public:
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
42private Q_SLOTS:
43 void chromeActivated();
44 void chromeDeactivated();
45
46Q_SIGNALS:
47 void qtShellSurfaceRequested(QWaylandSurface *surface, const QWaylandResource &resource);
48 void qtShellSurfaceCreated(QWaylandQtShellSurface *qtShellSurface);
49
50private:
51 bool moveChromeToFront(QWaylandQtShellChrome *chrome);
52};
53
54Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_NAMED_ELEMENT(QWaylandQtShell, QtShell, 1, 0)
55
56
57class QWaylandQtShellSurfacePrivate;
58class QWaylandSurfaceRole;
59class QWaylandResource;
60
61class 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
85public:
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
151Q_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
168private Q_SLOTS:
169 void surfaceCommitted();
170
171private:
172 friend class QWaylandQtShellChrome;
173
174 void initialize() override;
175
176 QWaylandQtShell *shell() const;
177};
178
179QT_END_NAMESPACE
180
181#endif // QWAYLANDQTSHELL_H
182

Provided by KDAB

Privacy Policy
Learn to use CMake with our Intro Training
Find out more

source code of qtwayland/src/imports/compositor-extensions/qtshell/qwaylandqtshell.h