| 1 | // Copyright (C) 2017 The Qt Company Ltd. |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QWAYLANDSHELLSURFACE_H |
| 5 | #define QWAYLANDSHELLSURFACE_H |
| 6 | |
| 7 | #include <QtWaylandCompositor/qtwaylandqmlinclude.h> |
| 8 | #include <QtWaylandCompositor/qwaylandcompositorextension.h> |
| 9 | |
| 10 | QT_BEGIN_NAMESPACE |
| 11 | |
| 12 | class QWaylandQuickShellIntegration; |
| 13 | class QWaylandQuickShellSurfaceItem; |
| 14 | class QWaylandShellSurfacePrivate; |
| 15 | |
| 16 | class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandShellSurface : public QWaylandCompositorExtension |
| 17 | { |
| 18 | Q_OBJECT |
| 19 | Q_DECLARE_PRIVATE(QWaylandShellSurface) |
| 20 | |
| 21 | Q_PROPERTY(Qt::WindowType windowType READ windowType NOTIFY windowTypeChanged) |
| 22 | Q_PROPERTY(bool modal READ isModal NOTIFY modalChanged FINAL REVISION(6, 8)) |
| 23 | QML_NAMED_ELEMENT(ShellSurface) |
| 24 | QML_UNCREATABLE("") |
| 25 | QML_ADDED_IN_VERSION(1, 0) |
| 26 | public: |
| 27 | #if QT_CONFIG(wayland_compositor_quick) |
| 28 | virtual QWaylandQuickShellIntegration *createIntegration(QWaylandQuickShellSurfaceItem *item) = 0; |
| 29 | #endif |
| 30 | QWaylandShellSurface(QWaylandObject *waylandObject); |
| 31 | virtual Qt::WindowType windowType() const { return Qt::WindowType::Window; } |
| 32 | |
| 33 | bool isModal() const; |
| 34 | |
| 35 | protected: |
| 36 | QWaylandShellSurface(QWaylandShellSurfacePrivate &dd); |
| 37 | QWaylandShellSurface(QWaylandObject *container, QWaylandShellSurfacePrivate &dd); |
| 38 | void setModal(bool newModal); |
| 39 | |
| 40 | Q_SIGNALS: |
| 41 | void windowTypeChanged(); |
| 42 | Q_REVISION(6, 8) void modalChanged(); |
| 43 | }; |
| 44 | |
| 45 | template <typename T> |
| 46 | class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandShellSurfaceTemplate : public QWaylandShellSurface |
| 47 | { |
| 48 | public: |
| 49 | QWaylandShellSurfaceTemplate(QWaylandObject *container = nullptr) |
| 50 | : QWaylandShellSurface(container) |
| 51 | { } |
| 52 | |
| 53 | const struct wl_interface *extensionInterface() const override |
| 54 | { |
| 55 | return T::interface(); |
| 56 | } |
| 57 | |
| 58 | static T *findIn(QWaylandObject *container) |
| 59 | { |
| 60 | if (!container) return nullptr; |
| 61 | return qobject_cast<T *>(container->extension(T::interfaceName())); |
| 62 | } |
| 63 | |
| 64 | protected: |
| 65 | QWaylandShellSurfaceTemplate(QWaylandShellSurfacePrivate &dd) |
| 66 | : QWaylandShellSurface(dd) |
| 67 | { } |
| 68 | |
| 69 | QWaylandShellSurfaceTemplate(QWaylandObject *container, QWaylandShellSurfacePrivate &dd) |
| 70 | : QWaylandShellSurface(container,dd) |
| 71 | { } |
| 72 | }; |
| 73 | |
| 74 | QT_END_NAMESPACE |
| 75 | |
| 76 | #endif // QWAYLANDSHELLSURFACE_H |
| 77 |
