1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QWAYLANDCOMPOSITORQUICKEXTENSIONS_P_H
5#define QWAYLANDCOMPOSITORQUICKEXTENSIONS_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtQml/qqml.h>
19#include <QtWaylandCompositor/qtwaylandcompositorglobal.h>
20#include <QtWaylandCompositor/qwaylandquickextension.h>
21
22#include <QtWaylandCompositor/qwaylandcompositor.h>
23#include <QtWaylandCompositor/qwaylandquickcompositor.h>
24#include <QtWaylandCompositor/qwaylandqtwindowmanager.h>
25#include <QtWaylandCompositor/qwaylandtextinputmanager.h>
26#include <QtCore/private/qglobal_p.h>
27#if QT_WAYLAND_TEXT_INPUT_V4_WIP
28#include <QtWaylandCompositor/qwaylandtextinputmanagerv4.h>
29#endif // QT_WAYLAND_TEXT_INPUT_V4_WIP
30#include <QtWaylandCompositor/qwaylandqttextinputmethodmanager.h>
31#include <QtWaylandCompositor/qwaylandidleinhibitv1.h>
32
33QT_BEGIN_NAMESPACE
34
35class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandQuickCompositorQuickExtensionContainer : public QWaylandQuickCompositor
36{
37 Q_OBJECT
38 Q_PROPERTY(QQmlListProperty<QWaylandCompositorExtension> extensions READ extensions)
39 Q_PROPERTY(QQmlListProperty<QObject> data READ data DESIGNABLE false)
40 Q_CLASSINFO("DefaultProperty", "data")
41 QML_NAMED_ELEMENT(WaylandCompositor)
42 QML_ADDED_IN_VERSION(1, 0)
43public:
44 QQmlListProperty<QObject> data()
45 {
46 return QQmlListProperty<QObject>(this, &m_objects);
47 }
48
49 QQmlListProperty<QWaylandCompositorExtension> extensions()
50 {
51 return QQmlListProperty<QWaylandCompositorExtension>(this, this,
52 &append_extension,
53 &countFunction,
54 &atFunction,
55 &clearFunction);
56 }
57
58 static qsizetype countFunction(QQmlListProperty<QWaylandCompositorExtension> *list)
59 {
60 return static_cast<QWaylandQuickCompositorQuickExtensionContainer *>(list->data)->extension_vector.size();
61 }
62
63 static QWaylandCompositorExtension *atFunction(QQmlListProperty<QWaylandCompositorExtension> *list, qsizetype index)
64 {
65 return static_cast<QWaylandQuickCompositorQuickExtensionContainer *>(list->data)->extension_vector.at(i: index);
66 }
67
68 static void append_extension(QQmlListProperty<QWaylandCompositorExtension> *list, QWaylandCompositorExtension *extension)
69 {
70 QWaylandQuickCompositorQuickExtensionContainer *quickExtObj = static_cast<QWaylandQuickCompositorQuickExtensionContainer *>(list->data);
71 extension->setExtensionContainer(quickExtObj);
72 }
73
74 static void clearFunction(QQmlListProperty<QWaylandCompositorExtension> *list)
75 {
76 static_cast<QWaylandQuickCompositorQuickExtensionContainer *>(list->data)->extension_vector.clear();
77 }
78
79private:
80 QList<QObject *> m_objects;
81};
82
83
84// Note: These have to be in a header with a Q_OBJECT macro, otherwise we won't run moc on it
85Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_NAMED_CLASS(QWaylandQtWindowManager, QtWindowManager)
86Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_NAMED_CLASS(QWaylandIdleInhibitManagerV1, IdleInhibitManagerV1)
87Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_NAMED_CLASS(QWaylandTextInputManager, TextInputManager)
88#if QT_WAYLAND_TEXT_INPUT_V4_WIP
89Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_NAMED_CLASS(QWaylandTextInputManagerV4, TextInputManagerV4)
90#endif // QT_WAYLAND_TEXT_INPUT_V4_WIP
91Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_NAMED_CLASS(QWaylandQtTextInputMethodManager, QtTextInputMethodManager)
92
93QT_END_NAMESPACE
94
95#endif // QWAYLANDCOMPOSITORQUICKEXTENSIONS_P_H
96

source code of qtwayland/src/compositor/compositor_api/qwaylandcompositorquickextensions_p.h