| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2017 The Qt Company Ltd. |
| 4 | ** Contact: https://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the QtWaylandCompositor module of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:GPL$ |
| 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 https://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at https://www.qt.io/contact-us. |
| 16 | ** |
| 17 | ** GNU General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU |
| 19 | ** General Public License version 3 or (at your option) any later version |
| 20 | ** approved by the KDE Free Qt Foundation. The licenses are as published by |
| 21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 |
| 22 | ** included in the packaging of this file. Please review the following |
| 23 | ** information to ensure the GNU General Public License requirements will |
| 24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
| 25 | ** |
| 26 | ** $QT_END_LICENSE$ |
| 27 | ** |
| 28 | ****************************************************************************/ |
| 29 | |
| 30 | #ifndef QWAYLANDWLSHELL_H |
| 31 | #define QWAYLANDWLSHELL_H |
| 32 | |
| 33 | #include <QtWaylandCompositor/QWaylandCompositorExtension> |
| 34 | #include <QtWaylandCompositor/QWaylandResource> |
| 35 | #include <QtWaylandCompositor/QWaylandShell> |
| 36 | #include <QtWaylandCompositor/QWaylandShellSurface> |
| 37 | #include <QtWaylandCompositor/qwaylandquickchildren.h> |
| 38 | |
| 39 | #include <QtCore/QSize> |
| 40 | |
| 41 | QT_BEGIN_NAMESPACE |
| 42 | |
| 43 | class QWaylandWlShellPrivate; |
| 44 | class QWaylandWlShellSurfacePrivate; |
| 45 | class QWaylandSurface; |
| 46 | class QWaylandClient; |
| 47 | class QWaylandSeat; |
| 48 | class QWaylandOutput; |
| 49 | class QWaylandSurfaceRole; |
| 50 | class QWaylandWlShellSurface; |
| 51 | |
| 52 | class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandWlShell : public QWaylandShellTemplate<QWaylandWlShell> |
| 53 | { |
| 54 | Q_OBJECT |
| 55 | Q_DECLARE_PRIVATE(QWaylandWlShell) |
| 56 | public: |
| 57 | QWaylandWlShell(); |
| 58 | QWaylandWlShell(QWaylandCompositor *compositor); |
| 59 | |
| 60 | void initialize() override; |
| 61 | QList<QWaylandWlShellSurface *> shellSurfaces() const; |
| 62 | QList<QWaylandWlShellSurface *> shellSurfacesForClient(QWaylandClient* client) const; |
| 63 | QList<QWaylandWlShellSurface *> mappedPopups() const; |
| 64 | QWaylandClient *popupClient() const; |
| 65 | |
| 66 | static const struct wl_interface *interface(); |
| 67 | static QByteArray interfaceName(); |
| 68 | |
| 69 | public Q_SLOTS: |
| 70 | void closeAllPopups(); |
| 71 | |
| 72 | Q_SIGNALS: |
| 73 | void wlShellSurfaceRequested(QWaylandSurface *surface, const QWaylandResource &resource); |
| 74 | void wlShellSurfaceCreated(QWaylandWlShellSurface *shellSurface); |
| 75 | }; |
| 76 | |
| 77 | class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandWlShellSurface : public QWaylandShellSurfaceTemplate<QWaylandWlShellSurface> |
| 78 | { |
| 79 | Q_OBJECT |
| 80 | Q_DECLARE_PRIVATE(QWaylandWlShellSurface) |
| 81 | Q_WAYLAND_COMPOSITOR_DECLARE_QUICK_CHILDREN(QWaylandWlShellSurface) |
| 82 | Q_PROPERTY(QWaylandSurface *surface READ surface NOTIFY surfaceChanged) |
| 83 | Q_PROPERTY(QWaylandWlShell *shell READ shell NOTIFY shellChanged) |
| 84 | Q_PROPERTY(QString title READ title NOTIFY titleChanged) |
| 85 | Q_PROPERTY(QString className READ className NOTIFY classNameChanged) |
| 86 | |
| 87 | public: |
| 88 | enum FullScreenMethod { |
| 89 | DefaultFullScreen, |
| 90 | ScaleFullScreen, |
| 91 | DriverFullScreen, |
| 92 | FillFullScreen |
| 93 | }; |
| 94 | Q_ENUM(FullScreenMethod); |
| 95 | |
| 96 | enum ResizeEdge { |
| 97 | NoneEdge = 0, |
| 98 | TopEdge = 1, |
| 99 | BottomEdge = 2, |
| 100 | LeftEdge = 4, |
| 101 | TopLeftEdge = 5, |
| 102 | BottomLeftEdge = 6, |
| 103 | RightEdge = 8, |
| 104 | TopRightEdge = 9, |
| 105 | BottomRightEdge = 10 |
| 106 | }; |
| 107 | Q_ENUM(ResizeEdge); |
| 108 | |
| 109 | QWaylandWlShellSurface(); |
| 110 | QWaylandWlShellSurface(QWaylandWlShell *shell, QWaylandSurface *surface, const QWaylandResource &resource); |
| 111 | ~QWaylandWlShellSurface() override; |
| 112 | |
| 113 | Q_INVOKABLE void initialize(QWaylandWlShell *shell, QWaylandSurface *surface, const QWaylandResource &resource); |
| 114 | |
| 115 | QString title() const; |
| 116 | QString className() const; |
| 117 | |
| 118 | QWaylandSurface *surface() const; |
| 119 | QWaylandWlShell *shell() const; |
| 120 | |
| 121 | Qt::WindowType windowType() const override; |
| 122 | |
| 123 | static const struct wl_interface *interface(); |
| 124 | static QByteArray interfaceName(); |
| 125 | static QWaylandSurfaceRole *role(); |
| 126 | |
| 127 | static QWaylandWlShellSurface *fromResource(wl_resource *res); |
| 128 | |
| 129 | Q_INVOKABLE QSize sizeForResize(const QSizeF &size, const QPointF &delta, ResizeEdge edges); |
| 130 | Q_INVOKABLE void sendConfigure(const QSize &size, ResizeEdge edges); |
| 131 | Q_INVOKABLE void sendPopupDone(); |
| 132 | |
| 133 | #if QT_CONFIG(wayland_compositor_quick) |
| 134 | QWaylandQuickShellIntegration *createIntegration(QWaylandQuickShellSurfaceItem *item) override; |
| 135 | #endif |
| 136 | |
| 137 | public Q_SLOTS: |
| 138 | void ping(); |
| 139 | |
| 140 | Q_SIGNALS: |
| 141 | void surfaceChanged(); |
| 142 | void shellChanged(); |
| 143 | void titleChanged(); |
| 144 | void classNameChanged(); |
| 145 | void pong(); |
| 146 | void startMove(QWaylandSeat *seat); |
| 147 | void startResize(QWaylandSeat *seat, ResizeEdge edges); |
| 148 | |
| 149 | void setDefaultToplevel(); |
| 150 | void setTransient(QWaylandSurface *parentSurface, const QPoint &relativeToParent, bool inactive); |
| 151 | void setFullScreen(FullScreenMethod method, uint framerate, QWaylandOutput *output); |
| 152 | void setPopup(QWaylandSeat *seat, QWaylandSurface *parentSurface, const QPoint &relativeToParent); |
| 153 | void setMaximized(QWaylandOutput *output); |
| 154 | |
| 155 | private: |
| 156 | void initialize() override; |
| 157 | }; |
| 158 | |
| 159 | QT_END_NAMESPACE |
| 160 | |
| 161 | #endif /*QWAYLANDWLSHELL_H*/ |
| 162 | |