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 | |
15 | class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandShellSurface : public QWaylandCompositorExtension |
16 | { |
17 | Q_OBJECT |
18 | Q_PROPERTY(Qt::WindowType windowType READ windowType NOTIFY windowTypeChanged) |
19 | QML_NAMED_ELEMENT(ShellSurface) |
20 | QML_UNCREATABLE("") |
21 | QML_ADDED_IN_VERSION(1, 0) |
22 | public: |
23 | #if QT_CONFIG(wayland_compositor_quick) |
24 | virtual QWaylandQuickShellIntegration *createIntegration(QWaylandQuickShellSurfaceItem *item) = 0; |
25 | #endif |
26 | QWaylandShellSurface(QWaylandObject *waylandObject) : QWaylandCompositorExtension(waylandObject) {} |
27 | virtual Qt::WindowType windowType() const { return Qt::WindowType::Window; } |
28 | |
29 | protected: |
30 | QWaylandShellSurface(QWaylandCompositorExtensionPrivate &dd) : QWaylandCompositorExtension(dd){} |
31 | QWaylandShellSurface(QWaylandObject *container, QWaylandCompositorExtensionPrivate &dd) : QWaylandCompositorExtension(container, dd) {} |
32 | |
33 | Q_SIGNALS: |
34 | void windowTypeChanged(); |
35 | }; |
36 | |
37 | template <typename T> |
38 | class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandShellSurfaceTemplate : public QWaylandShellSurface |
39 | { |
40 | public: |
41 | QWaylandShellSurfaceTemplate(QWaylandObject *container = nullptr) |
42 | : QWaylandShellSurface(container) |
43 | { } |
44 | |
45 | const struct wl_interface *extensionInterface() const override |
46 | { |
47 | return T::interface(); |
48 | } |
49 | |
50 | static T *findIn(QWaylandObject *container) |
51 | { |
52 | if (!container) return nullptr; |
53 | return qobject_cast<T *>(container->extension(T::interfaceName())); |
54 | } |
55 | |
56 | protected: |
57 | QWaylandShellSurfaceTemplate(QWaylandCompositorExtensionPrivate &dd) |
58 | : QWaylandShellSurface(dd) |
59 | { } |
60 | |
61 | QWaylandShellSurfaceTemplate(QWaylandObject *container, QWaylandCompositorExtensionPrivate &dd) |
62 | : QWaylandShellSurface(container,dd) |
63 | { } |
64 | }; |
65 | |
66 | QT_END_NAMESPACE |
67 | |
68 | #endif // QWAYLANDSHELLSURFACE_H |
69 |