| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2017 The Qt Company Ltd. |
| 4 | ** Contact: http://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the QtWaylandCompositor module of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:LGPL3$ |
| 9 | ** Commercial License Usage |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in |
| 11 | ** accordance with the commercial license agreement provided with the |
| 12 | ** Software or, alternatively, in accordance with the terms contained in |
| 13 | ** a written agreement between you and The Qt Company. For licensing terms |
| 14 | ** and conditions see http://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at http://www.qt.io/contact-us. |
| 16 | ** |
| 17 | ** GNU Lesser General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
| 19 | ** General Public License version 3 as published by the Free Software |
| 20 | ** Foundation and appearing in the file LICENSE.LGPLv3 included in the |
| 21 | ** packaging of this file. Please review the following information to |
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements |
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl.html. |
| 24 | ** |
| 25 | ** GNU General Public License Usage |
| 26 | ** Alternatively, this file may be used under the terms of the GNU |
| 27 | ** General Public License version 2.0 or later as published by the Free |
| 28 | ** Software Foundation and appearing in the file LICENSE.GPL included in |
| 29 | ** the packaging of this file. Please review the following information to |
| 30 | ** ensure the GNU General Public License version 2.0 requirements will be |
| 31 | ** met: http://www.gnu.org/licenses/gpl-2.0.html. |
| 32 | ** |
| 33 | ** $QT_END_LICENSE$ |
| 34 | ** |
| 35 | ****************************************************************************/ |
| 36 | |
| 37 | #ifndef QWAYLANDXDGSHELLV6_H |
| 38 | #define QWAYLANDXDGSHELLV6_H |
| 39 | |
| 40 | #include <QtWaylandCompositor/QWaylandCompositorExtension> |
| 41 | #include <QtWaylandCompositor/QWaylandResource> |
| 42 | #include <QtWaylandCompositor/QWaylandShell> |
| 43 | #include <QtWaylandCompositor/QWaylandShellSurface> |
| 44 | #include <QtWaylandCompositor/qwaylandquickchildren.h> |
| 45 | |
| 46 | #include <QtCore/QRect> |
| 47 | |
| 48 | struct wl_resource; |
| 49 | |
| 50 | QT_BEGIN_NAMESPACE |
| 51 | |
| 52 | #if QT_DEPRECATED_SINCE(5, 15) |
| 53 | |
| 54 | class QWaylandClient; |
| 55 | class QWaylandOutput; |
| 56 | class QWaylandSeat; |
| 57 | class QWaylandSurface; |
| 58 | class QWaylandSurfaceRole; |
| 59 | class QWaylandXdgShellV6Private; |
| 60 | class QWaylandXdgSurfaceV6; |
| 61 | class QWaylandXdgSurfaceV6Private; |
| 62 | class QWaylandXdgToplevelV6; |
| 63 | class QWaylandXdgToplevelV6Private; |
| 64 | class QWaylandXdgPopupV6; |
| 65 | class QWaylandXdgPopupV6Private; |
| 66 | class QWaylandXdgPositionerV6; |
| 67 | |
| 68 | class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgShellV6 : public QWaylandShellTemplate<QWaylandXdgShellV6> |
| 69 | { |
| 70 | Q_OBJECT |
| 71 | Q_DECLARE_PRIVATE(QWaylandXdgShellV6) |
| 72 | public: |
| 73 | QWaylandXdgShellV6(); |
| 74 | QWaylandXdgShellV6(QWaylandCompositor *compositor); |
| 75 | |
| 76 | void initialize() override; |
| 77 | |
| 78 | static const struct wl_interface *interface(); |
| 79 | static QByteArray interfaceName(); |
| 80 | |
| 81 | public Q_SLOTS: |
| 82 | uint ping(QWaylandClient *client); |
| 83 | |
| 84 | Q_SIGNALS: |
| 85 | void xdgSurfaceCreated(QWaylandXdgSurfaceV6 *xdgSurface); |
| 86 | void toplevelCreated(QWaylandXdgToplevelV6 *toplevel, QWaylandXdgSurfaceV6 *xdgSurface); |
| 87 | void popupCreated(QWaylandXdgPopupV6 *, QWaylandXdgSurfaceV6 *xdgSurface); |
| 88 | void pong(uint serial); |
| 89 | |
| 90 | private Q_SLOTS: |
| 91 | void handleSeatChanged(QWaylandSeat *newSeat, QWaylandSeat *oldSeat); |
| 92 | void handleFocusChanged(QWaylandSurface *newSurface, QWaylandSurface *oldSurface); |
| 93 | }; |
| 94 | |
| 95 | class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgSurfaceV6 : public QWaylandShellSurfaceTemplate<QWaylandXdgSurfaceV6> |
| 96 | { |
| 97 | Q_OBJECT |
| 98 | Q_DECLARE_PRIVATE(QWaylandXdgSurfaceV6) |
| 99 | Q_WAYLAND_COMPOSITOR_DECLARE_QUICK_CHILDREN(QWaylandXdgSurfaceV6) |
| 100 | Q_PROPERTY(QWaylandXdgShellV6 *shell READ shell NOTIFY shellChanged) |
| 101 | Q_PROPERTY(QWaylandSurface *surface READ surface NOTIFY surfaceChanged) |
| 102 | Q_PROPERTY(QWaylandXdgToplevelV6 *toplevel READ toplevel NOTIFY toplevelCreated) |
| 103 | Q_PROPERTY(QWaylandXdgPopupV6 *popup READ popup NOTIFY popupCreated) |
| 104 | Q_PROPERTY(QRect windowGeometry READ windowGeometry NOTIFY windowGeometryChanged) |
| 105 | |
| 106 | public: |
| 107 | QWaylandXdgSurfaceV6(); |
| 108 | QWaylandXdgSurfaceV6(QWaylandXdgShellV6* xdgShell, QWaylandSurface *surface, const QWaylandResource &resource); |
| 109 | |
| 110 | Q_INVOKABLE void initialize(QWaylandXdgShellV6* xdgShell, QWaylandSurface *surface, const QWaylandResource &resource); |
| 111 | |
| 112 | Qt::WindowType windowType() const override; |
| 113 | |
| 114 | QWaylandXdgShellV6 *shell() const; |
| 115 | QWaylandSurface *surface() const; |
| 116 | QWaylandXdgToplevelV6 *toplevel() const; |
| 117 | QWaylandXdgPopupV6 *popup() const; |
| 118 | QRect windowGeometry() const; |
| 119 | |
| 120 | static const struct wl_interface *interface(); |
| 121 | static QByteArray interfaceName(); |
| 122 | static QWaylandXdgSurfaceV6 *fromResource(::wl_resource *resource); |
| 123 | |
| 124 | #if QT_CONFIG(wayland_compositor_quick) |
| 125 | QWaylandQuickShellIntegration *createIntegration(QWaylandQuickShellSurfaceItem *item) override; |
| 126 | #endif |
| 127 | |
| 128 | Q_SIGNALS: |
| 129 | void shellChanged(); |
| 130 | void surfaceChanged(); |
| 131 | void toplevelCreated(); |
| 132 | void popupCreated(); |
| 133 | void windowGeometryChanged(); |
| 134 | |
| 135 | private: |
| 136 | void initialize() override; |
| 137 | |
| 138 | private Q_SLOTS: |
| 139 | void handleSurfaceSizeChanged(); |
| 140 | void handleBufferScaleChanged(); |
| 141 | }; |
| 142 | |
| 143 | class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgToplevelV6 : public QObject |
| 144 | { |
| 145 | Q_OBJECT |
| 146 | Q_DECLARE_PRIVATE(QWaylandXdgToplevelV6) |
| 147 | Q_PROPERTY(QWaylandXdgToplevelV6 *parentToplevel READ parentToplevel NOTIFY parentToplevelChanged) |
| 148 | Q_PROPERTY(QString title READ title NOTIFY titleChanged) |
| 149 | Q_PROPERTY(QString appId READ appId NOTIFY appIdChanged) |
| 150 | Q_PROPERTY(QSize maxSize READ maxSize NOTIFY maxSizeChanged) |
| 151 | Q_PROPERTY(QSize minSize READ minSize NOTIFY minSizeChanged) |
| 152 | Q_PROPERTY(QList<int> states READ statesAsInts NOTIFY statesChanged) |
| 153 | Q_PROPERTY(bool maximized READ maximized NOTIFY maximizedChanged) |
| 154 | Q_PROPERTY(bool fullscreen READ fullscreen NOTIFY fullscreenChanged) |
| 155 | Q_PROPERTY(bool resizing READ resizing NOTIFY resizingChanged) |
| 156 | Q_PROPERTY(bool activated READ activated NOTIFY activatedChanged) |
| 157 | public: |
| 158 | enum State : uint { |
| 159 | MaximizedState = 1, |
| 160 | FullscreenState = 2, |
| 161 | ResizingState = 3, |
| 162 | ActivatedState = 4 |
| 163 | }; |
| 164 | Q_ENUM(State) |
| 165 | |
| 166 | QWaylandXdgToplevelV6(QWaylandXdgSurfaceV6 *xdgSurface, QWaylandResource &resource); |
| 167 | |
| 168 | QWaylandXdgToplevelV6 *parentToplevel() const; |
| 169 | |
| 170 | QString title() const; |
| 171 | QString appId() const; |
| 172 | QSize maxSize() const; |
| 173 | QSize minSize() const; |
| 174 | QVector<QWaylandXdgToplevelV6::State> states() const; |
| 175 | bool maximized() const; |
| 176 | bool fullscreen() const; |
| 177 | bool resizing() const; |
| 178 | bool activated() const; |
| 179 | |
| 180 | Q_INVOKABLE QSize sizeForResize(const QSizeF &size, const QPointF &delta, Qt::Edges edges) const; |
| 181 | uint sendConfigure(const QSize &size, const QVector<State> &states); |
| 182 | Q_INVOKABLE uint sendConfigure(const QSize &size, const QVector<int> &states); |
| 183 | Q_INVOKABLE void sendClose(); |
| 184 | Q_INVOKABLE uint sendMaximized(const QSize &size); |
| 185 | Q_INVOKABLE uint sendUnmaximized(const QSize &size = QSize(0, 0)); |
| 186 | Q_INVOKABLE uint sendFullscreen(const QSize &size); |
| 187 | Q_INVOKABLE uint sendResizing(const QSize &maxSize); |
| 188 | |
| 189 | static QWaylandSurfaceRole *role(); |
| 190 | |
| 191 | Q_SIGNALS: |
| 192 | void parentToplevelChanged(); |
| 193 | void titleChanged(); |
| 194 | void appIdChanged(); |
| 195 | void maxSizeChanged(); |
| 196 | void minSizeChanged(); |
| 197 | void startMove(QWaylandSeat *seat); |
| 198 | void startResize(QWaylandSeat *seat, Qt::Edges edges); |
| 199 | void statesChanged(); |
| 200 | void maximizedChanged(); |
| 201 | void fullscreenChanged(); |
| 202 | void resizingChanged(); |
| 203 | void activatedChanged(); |
| 204 | |
| 205 | void showWindowMenu(QWaylandSeat *seat, const QPoint &localSurfacePosition); |
| 206 | void setMaximized(); |
| 207 | void unsetMaximized(); |
| 208 | void setFullscreen(QWaylandOutput *output); |
| 209 | void unsetFullscreen(); |
| 210 | void setMinimized(); |
| 211 | |
| 212 | private: |
| 213 | QList<int> statesAsInts() const; |
| 214 | }; |
| 215 | |
| 216 | class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgPopupV6 : public QObject |
| 217 | { |
| 218 | Q_OBJECT |
| 219 | Q_DECLARE_PRIVATE(QWaylandXdgPopupV6) |
| 220 | Q_PROPERTY(QWaylandXdgSurfaceV6 *xdgSurface READ xdgSurface CONSTANT) |
| 221 | Q_PROPERTY(QWaylandXdgSurfaceV6 *parentXdgSurface READ parentXdgSurface CONSTANT) |
| 222 | Q_PROPERTY(QRect configuredGeometry READ configuredGeometry NOTIFY configuredGeometryChanged) |
| 223 | |
| 224 | // Positioner properties |
| 225 | Q_PROPERTY(QRect anchorRect READ anchorRect CONSTANT) |
| 226 | Q_PROPERTY(Qt::Edges anchorEdges READ anchorEdges CONSTANT) |
| 227 | Q_PROPERTY(Qt::Edges gravityEdges READ gravityEdges CONSTANT) |
| 228 | Q_PROPERTY(Qt::Orientations slideConstraints READ slideConstraints CONSTANT) |
| 229 | Q_PROPERTY(Qt::Orientations flipConstraints READ flipConstraints CONSTANT) |
| 230 | Q_PROPERTY(Qt::Orientations resizeConstraints READ resizeConstraints CONSTANT) |
| 231 | Q_PROPERTY(QPoint offset READ offset CONSTANT) |
| 232 | Q_PROPERTY(QSize positionerSize READ positionerSize CONSTANT) |
| 233 | Q_PROPERTY(QPoint unconstrainedPosition READ unconstrainedPosition CONSTANT) |
| 234 | public: |
| 235 | QWaylandXdgSurfaceV6 *xdgSurface() const; |
| 236 | QWaylandXdgSurfaceV6 *parentXdgSurface() const; |
| 237 | QRect configuredGeometry() const; |
| 238 | |
| 239 | // Positioner properties |
| 240 | QRect anchorRect() const; |
| 241 | Qt::Edges anchorEdges() const ; |
| 242 | Qt::Edges gravityEdges() const ; |
| 243 | Qt::Orientations slideConstraints() const; |
| 244 | Qt::Orientations flipConstraints() const; |
| 245 | Qt::Orientations resizeConstraints() const; |
| 246 | QPoint offset() const; |
| 247 | QSize positionerSize() const; |
| 248 | QPoint unconstrainedPosition() const; |
| 249 | |
| 250 | Q_INVOKABLE uint sendConfigure(const QRect &geometry); |
| 251 | Q_REVISION(14) Q_INVOKABLE void sendPopupDone(); |
| 252 | |
| 253 | static QWaylandSurfaceRole *role(); |
| 254 | |
| 255 | Q_SIGNALS: |
| 256 | void configuredGeometryChanged(); |
| 257 | |
| 258 | private: |
| 259 | QWaylandXdgPopupV6(QWaylandXdgSurfaceV6 *xdgSurface, QWaylandXdgSurfaceV6 *parentXdgSurface, |
| 260 | QWaylandXdgPositionerV6 *positioner, QWaylandResource &resource); |
| 261 | friend class QWaylandXdgSurfaceV6Private; |
| 262 | }; |
| 263 | |
| 264 | #endif // QT_DEPRECATED_SINCE(5, 15) |
| 265 | |
| 266 | QT_END_NAMESPACE |
| 267 | |
| 268 | #endif // QWAYLANDXDGSHELLV6_H |
| 269 | |