| 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 QWAYLANDXDGSHELLV5_P_H |
| 31 | #define QWAYLANDXDGSHELLV5_P_H |
| 32 | |
| 33 | #include <QtWaylandCompositor/private/qwaylandcompositorextension_p.h> |
| 34 | #include <QtWaylandCompositor/private/qwaylandshell_p.h> |
| 35 | #include <QtWaylandCompositor/private/qwayland-server-xdg-shell-unstable-v5_p.h> |
| 36 | |
| 37 | #include <QtWaylandCompositor/QWaylandXdgShellV5> |
| 38 | |
| 39 | #include <QtCore/QSet> |
| 40 | |
| 41 | // |
| 42 | // W A R N I N G |
| 43 | // ------------- |
| 44 | // |
| 45 | // This file is not part of the Qt API. It exists purely as an |
| 46 | // implementation detail. This header file may change from version to |
| 47 | // version without notice, or even be removed. |
| 48 | // |
| 49 | // We mean it. |
| 50 | // |
| 51 | |
| 52 | QT_BEGIN_NAMESPACE |
| 53 | |
| 54 | #if QT_DEPRECATED_SINCE(5, 15) |
| 55 | |
| 56 | class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgShellV5Private |
| 57 | : public QWaylandShellPrivate |
| 58 | , public QtWaylandServer::xdg_shell_v5 |
| 59 | { |
| 60 | Q_DECLARE_PUBLIC(QWaylandXdgShellV5) |
| 61 | public: |
| 62 | QWaylandXdgShellV5Private(); |
| 63 | void ping(Resource *resource, uint32_t serial); |
| 64 | void registerSurface(QWaylandXdgSurfaceV5 *xdgSurface); |
| 65 | void unregisterXdgSurface(QWaylandXdgSurfaceV5 *xdgSurface); |
| 66 | void registerXdgPopup(QWaylandXdgPopupV5 *); |
| 67 | void unregisterXdgPopup(QWaylandXdgPopupV5 *); |
| 68 | static QWaylandXdgShellV5Private *get(QWaylandXdgShellV5 *xdgShell) { return xdgShell->d_func(); } |
| 69 | bool isValidPopupParent(QWaylandSurface *parentSurface) const; |
| 70 | QWaylandXdgPopupV5 *topmostPopupForClient(struct wl_client* client) const; |
| 71 | |
| 72 | QSet<uint32_t> m_pings; |
| 73 | QMultiMap<struct wl_client *, QWaylandXdgSurfaceV5 *> m_xdgSurfaces; |
| 74 | QMultiMap<struct wl_client *, QWaylandXdgPopupV5 *> m_xdgPopups; |
| 75 | |
| 76 | QWaylandXdgSurfaceV5 *xdgSurfaceFromSurface(QWaylandSurface *surface) const; |
| 77 | |
| 78 | protected: |
| 79 | void xdg_shell_destroy(Resource *resource) override; |
| 80 | void xdg_shell_get_xdg_surface(Resource *resource, uint32_t id, |
| 81 | struct ::wl_resource *surface) override; |
| 82 | void xdg_shell_use_unstable_version(Resource *resource, int32_t version) override; |
| 83 | void xdg_shell_get_xdg_popup(Resource *resource, uint32_t id, struct ::wl_resource *surface, |
| 84 | struct ::wl_resource *parent, struct ::wl_resource *seatResource, |
| 85 | uint32_t serial, int32_t x, int32_t y) override; |
| 86 | void xdg_shell_pong(Resource *resource, uint32_t serial) override; |
| 87 | }; |
| 88 | |
| 89 | class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgSurfaceV5Private |
| 90 | : public QWaylandCompositorExtensionPrivate |
| 91 | , public QtWaylandServer::xdg_surface_v5 |
| 92 | { |
| 93 | Q_DECLARE_PUBLIC(QWaylandXdgSurfaceV5) |
| 94 | public: |
| 95 | QWaylandXdgSurfaceV5Private(); |
| 96 | static QWaylandXdgSurfaceV5Private *get(QWaylandXdgSurfaceV5 *xdgSurface) { return xdgSurface->d_func(); } |
| 97 | |
| 98 | struct ConfigureEvent { |
| 99 | QVector<uint> states; |
| 100 | QSize size; |
| 101 | uint serial; |
| 102 | }; |
| 103 | |
| 104 | void handleFocusLost(); |
| 105 | void handleFocusReceived(); |
| 106 | QRect calculateFallbackWindowGeometry() const; |
| 107 | void updateFallbackWindowGeometry(); |
| 108 | |
| 109 | void setWindowType(Qt::WindowType windowType); |
| 110 | |
| 111 | private: |
| 112 | QWaylandXdgShellV5 *m_xdgShell = nullptr; |
| 113 | QWaylandSurface *m_surface = nullptr; |
| 114 | QWaylandXdgSurfaceV5 *m_parentSurface = nullptr; |
| 115 | |
| 116 | Qt::WindowType m_windowType = Qt::WindowType::Window; |
| 117 | |
| 118 | QString m_title; |
| 119 | QString m_appId; |
| 120 | QRect m_windowGeometry; |
| 121 | bool m_unsetWindowGeometry = true; |
| 122 | |
| 123 | QList<ConfigureEvent> m_pendingConfigures; |
| 124 | ConfigureEvent m_lastAckedConfigure; |
| 125 | ConfigureEvent lastSentConfigure() const { return m_pendingConfigures.empty() ? m_lastAckedConfigure : m_pendingConfigures.first(); } |
| 126 | |
| 127 | void xdg_surface_destroy_resource(Resource *resource) override; |
| 128 | |
| 129 | void xdg_surface_destroy(Resource *resource) override; |
| 130 | void xdg_surface_move(Resource *resource, struct ::wl_resource *seat, |
| 131 | uint32_t serial) override; |
| 132 | void xdg_surface_resize(Resource *resource, struct ::wl_resource *seat, uint32_t serial, |
| 133 | uint32_t edges) override; |
| 134 | void xdg_surface_set_maximized(Resource *resource) override; |
| 135 | void xdg_surface_unset_maximized(Resource *resource) override; |
| 136 | void xdg_surface_set_fullscreen(Resource *resource, |
| 137 | struct ::wl_resource *output) override; |
| 138 | void xdg_surface_unset_fullscreen(Resource *resource) override; |
| 139 | void xdg_surface_set_minimized(Resource *resource) override; |
| 140 | void xdg_surface_set_parent(Resource *resource, struct ::wl_resource *parent) override; |
| 141 | void xdg_surface_set_app_id(Resource *resource, const QString &app_id) override; |
| 142 | void xdg_surface_show_window_menu(Resource *resource, struct ::wl_resource *seatResource, |
| 143 | uint32_t serial, int32_t x, int32_t y) override; |
| 144 | void xdg_surface_ack_configure(Resource *resource, uint32_t serial) override; |
| 145 | void xdg_surface_set_title(Resource *resource, const QString &title) override; |
| 146 | void xdg_surface_set_window_geometry(Resource *resource, int32_t x, int32_t y, |
| 147 | int32_t width, int32_t height) override; |
| 148 | |
| 149 | static QWaylandSurfaceRole s_role; |
| 150 | }; |
| 151 | |
| 152 | class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgPopupV5Private |
| 153 | : public QWaylandCompositorExtensionPrivate |
| 154 | , public QtWaylandServer::xdg_popup_v5 |
| 155 | { |
| 156 | Q_DECLARE_PUBLIC(QWaylandXdgPopupV5) |
| 157 | |
| 158 | public: |
| 159 | QWaylandXdgPopupV5Private(); |
| 160 | static QWaylandXdgPopupV5Private *get(QWaylandXdgPopupV5 *) { return xdgPopup->d_func(); } |
| 161 | |
| 162 | QWaylandSurface *m_surface = nullptr; |
| 163 | QWaylandSurface *m_parentSurface = nullptr; |
| 164 | QWaylandXdgShellV5 *m_xdgShell = nullptr; |
| 165 | QPoint m_position; |
| 166 | |
| 167 | void xdg_popup_destroy_resource(Resource *resource) override; |
| 168 | void xdg_popup_destroy(xdg_popup_v5::Resource *resource) override; |
| 169 | |
| 170 | static QWaylandSurfaceRole s_role; |
| 171 | }; |
| 172 | |
| 173 | #endif // QT_DEPRECATED_SINCE(5, 15) |
| 174 | |
| 175 | QT_END_NAMESPACE |
| 176 | |
| 177 | #endif // QWAYLANDXDGSHELLV5_P_H |
| 178 | |