diff options
Diffstat (limited to 'src/compositor/global')
-rw-r--r-- | src/compositor/global/global.pri | 1 | ||||
-rw-r--r-- | src/compositor/global/qtwaylandcompositorglobal.h | 66 | ||||
-rw-r--r-- | src/compositor/global/qtwaylandcompositorglobal_p.h | 49 | ||||
-rw-r--r-- | src/compositor/global/qtwaylandqmlinclude.h | 31 | ||||
-rw-r--r-- | src/compositor/global/qwaylandcompositorextension.cpp | 180 | ||||
-rw-r--r-- | src/compositor/global/qwaylandcompositorextension.h | 51 | ||||
-rw-r--r-- | src/compositor/global/qwaylandcompositorextension_p.h | 42 | ||||
-rw-r--r-- | src/compositor/global/qwaylandquickextension.cpp | 12 | ||||
-rw-r--r-- | src/compositor/global/qwaylandquickextension.h | 114 | ||||
-rw-r--r-- | src/compositor/global/qwaylandquickextension.qdoc | 85 | ||||
-rw-r--r-- | src/compositor/global/qwaylandutils_p.h | 42 |
11 files changed, 370 insertions, 303 deletions
diff --git a/src/compositor/global/global.pri b/src/compositor/global/global.pri index 172f916bf..e12df2dd1 100644 --- a/src/compositor/global/global.pri +++ b/src/compositor/global/global.pri @@ -2,6 +2,7 @@ INCLUDEPATH += global/ HEADERS += \ global/qtwaylandcompositorglobal.h \ + global/qtwaylandqmlinclude.h \ global/qwaylandcompositorextension.h \ global/qwaylandcompositorextension_p.h \ global/qwaylandutils_p.h \ diff --git a/src/compositor/global/qtwaylandcompositorglobal.h b/src/compositor/global/qtwaylandcompositorglobal.h index 403f1962a..49b7dc63f 100644 --- a/src/compositor/global/qtwaylandcompositorglobal.h +++ b/src/compositor/global/qtwaylandcompositorglobal.h @@ -1,72 +1,12 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDCOMPOSITORGLOBAL_H #define QWAYLANDCOMPOSITORGLOBAL_H -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - #include <QtGui/qtguiglobal.h> #include <QtWaylandCompositor/qtwaylandcompositor-config.h> - -QT_BEGIN_NAMESPACE - -#if !defined(Q_WAYLAND_COMPOSITOR_EXPORT) -# if defined(QT_SHARED) && defined(QT_BUILD_COMPOSITOR_LIB) -# define Q_WAYLAND_COMPOSITOR_EXPORT Q_DECL_EXPORT -# elif defined(QT_SHARED) -# define Q_WAYLAND_COMPOSITOR_EXPORT Q_DECL_IMPORT -# else -# define Q_WAYLAND_COMPOSITOR_EXPORT -# endif -#endif - -QT_END_NAMESPACE +#include <QtWaylandCompositor/qtwaylandcompositorexports.h> #endif // QWAYLANDCOMPOSITORGLOBAL_H diff --git a/src/compositor/global/qtwaylandcompositorglobal_p.h b/src/compositor/global/qtwaylandcompositorglobal_p.h index 629d58292..4d53a5076 100644 --- a/src/compositor/global/qtwaylandcompositorglobal_p.h +++ b/src/compositor/global/qtwaylandcompositorglobal_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDCOMPOSITORGLOBAL_P_H #define QWAYLANDCOMPOSITORGLOBAL_P_H @@ -51,9 +15,18 @@ // We mean it. // +#include <QtWaylandGlobal/private/qtwaylandglobal-config_p.h> #include <QtWaylandCompositor/qtwaylandcompositorglobal.h> #include <QtGui/private/qtguiglobal_p.h> #include <QtWaylandCompositor/private/qtwaylandcompositor-config_p.h> +QT_BEGIN_NAMESPACE + +#if QT_CONFIG(wayland_compositor_quick) +void Q_WAYLANDCOMPOSITOR_EXPORT qml_register_types_QtWayland_Compositor(); +#endif + +QT_END_NAMESPACE + #endif // QWAYLANDCOMPOSITORGLOBAL_P_H diff --git a/src/compositor/global/qtwaylandqmlinclude.h b/src/compositor/global/qtwaylandqmlinclude.h new file mode 100644 index 000000000..b008a8c7f --- /dev/null +++ b/src/compositor/global/qtwaylandqmlinclude.h @@ -0,0 +1,31 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#ifndef QTWAYLANDQMLINCLUDE_H +#define QTWAYLANDQMLINCLUDE_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// +#include <QtCore/qglobal.h> +#include <QtWaylandCompositor/qtwaylandcompositor-config.h> + +#if QT_CONFIG(wayland_compositor_quick) +#include <QtQml/qqml.h> +#else +#define QML_NAMED_ELEMENT(x) +#define QML_UNCREATABLE(x) +#define QML_ADDED_IN_VERSION(x, y) +#endif + +QT_BEGIN_NAMESPACE +QT_END_NAMESPACE + +#endif // QTWAYLANDQMLINCLUDE_H diff --git a/src/compositor/global/qwaylandcompositorextension.cpp b/src/compositor/global/qwaylandcompositorextension.cpp index 36daebce7..3a10d177a 100644 --- a/src/compositor/global/qwaylandcompositorextension.cpp +++ b/src/compositor/global/qwaylandcompositorextension.cpp @@ -1,42 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "qwaylandcompositorextension.h" #include "qwaylandcompositorextension_p.h" @@ -48,11 +11,85 @@ QT_BEGIN_NAMESPACE +/*! + * \class QWaylandCompositorExtensionTemplate + * \inmodule QtWaylandCompositor + * \since 5.8 + * \brief QWaylandCompositorExtensionTemplate is a convenience class for subclassing + * QWaylandCompositorExtension. + * + * QWaylandCompositorExtensionTemplate is a template class which inherits + * QWaylandCompositorExtension and is convenience for building custom Wayland extensions with Qt. + * + * It provides the connection between Qt Wayland Compositor and the class generated by + * \c qtwaylandscanner, based on the XML description of the extension protocol. + * + * It provides two specific pieces of convenience: + * \list + * \li A reimplementation of \l{QWaylandCompositorExtension::extensionInterface()} which returns + * the \c wl_interface pointer for the qtwaylandscanner-generated base class. + * \li A static \l{findIn()} function which searches for an instance of the extension in a + * provided container, and returns this if it is found. + * \endlist + * + * Typically, a new extension will dual-inherit QWaylandCompositorExtensionTemplate and the class + * generated by \c qtwaylandscanner. + * + * QWaylandCompositorExtensionTemplate should be parameterized with the subclass itself: + * \code + * class MyExtension + * : public QWaylandCompositorExtensionTemplate<MyExtension> + * , QtWaylandServer::my_extension + * \endcode + * + * In this example, \c MyExtension is an implementation of the generated interface \c my_extension. + * + * \sa {Custom Shell} + */ + +/*! + * \fn template <typename T> T *QWaylandCompositorExtensionTemplate<T>::findIn(QWaylandObject *container) + * + * If any instance of the interface has been registered with \a container, this is returned. + * Otherwise null is returned. The look-up is based on the generated \c interfaceName() which + * matches the interface name in the protocol description. + */ + +/*! + * \class QWaylandCompositorExtension + * \inmodule QtWaylandCompositor + * \since 5.8 + * \brief QWaylandCompositorExtension is the base class for compositor extensions. + * + * QWaylandCompositorExtension is the base class for implementing Wayland extensions on the + * compositor-side of the connection. If no other extension container is explicitly set, it will + * automatically add itself to its parent object, granted that this inherits from QWaylandObject. + * + * For example, for registering global extensions, you can inherit from QWaylandCompositorExtension + * and pass the QWaylandCompositor object as extension container. + * + * \sa QWaylandCompositorExtensionTemplate, {Custom Shell} + */ + +/*! + * Creates a QWaylandCompositorExtension with no container. + * + * \sa setExtensionContainer() + */ QWaylandCompositorExtension::QWaylandCompositorExtension() : QWaylandObject(*new QWaylandCompositorExtensionPrivate()) { } +/*! + * Creates a QWaylandCompositorExtension and adds it to the extension \a container. The \a container + * does not become the parent of the QWaylandCompositorExtension. + * + * The extension adds itself to \a container later, when \l{initialize()} is called. For this to + * happen automatically, an event loop must be running in the current thread. + * + * The QWaylandCompositorExtension will remove itself again when it is destroyed. + */ QWaylandCompositorExtension::QWaylandCompositorExtension(QWaylandObject *container) : QWaylandObject(*new QWaylandCompositorExtensionPrivate()) { @@ -79,18 +116,42 @@ QWaylandCompositorExtension::~QWaylandCompositorExtension() d->extension_container->removeExtension(this); } +/*! + * \fn const wl_interface *QWaylandCompositorExtension::extensionInterface() const + * + * A pure virtual function which should be reimplemented to return the \c wl_interface which + * corresponds to this QWaylandCompositorExtension. + */ + +/*! + * \return the extension container for this QWaylandCompositorExtension or null if none has been + * set. + */ QWaylandObject *QWaylandCompositorExtension::extensionContainer() const { Q_D(const QWaylandCompositorExtension); return d->extension_container; } +/*! + * Sets the extension container for this QWaylandCompositorExtension to \a container. This must be + * called before \l{initialize()} and cannot be changed once the QWaylandCompositorExtension has + * been initialized. + */ void QWaylandCompositorExtension::setExtensionContainer(QWaylandObject *container) { Q_D(QWaylandCompositorExtension); d->extension_container = container; } +/*! + * Initializes the QWaylandCompositorExtension. The default implementation adopts the parent object + * as extension container if none has been set, and if the parent inherits from QWaylandObject. The + * default implementation also adds the QWaylandCompositorExtension to the list of extensions + * managed by the extension container. + * + * Override this function in subclasses to provide custom initialization code. + */ void QWaylandCompositorExtension::initialize() { Q_D(QWaylandCompositorExtension); @@ -133,6 +194,21 @@ bool QWaylandCompositorExtension::event(QEvent *event) return QWaylandObject::event(event); } +/*! + * \class QWaylandObject + * \inmodule QtWaylandCompositor + * \since 5.8 + * \brief QWaylandObject is the base class for objects that can contain Wayland extensions. + * + * The QWaylandObject encapsulate extension container functionality. Any QWaylandObject object + * will automatically be an extension container and QWaylandCompositorExtension object which is + * a child of this will automatically add itself to its extension list, and remove itself when + * the extension object is destroyed. + */ + +/*! + * Creates a QWaylandObject as a child of \a parent. + */ QWaylandObject::QWaylandObject(QObject *parent) :QObject(parent) { @@ -146,10 +222,15 @@ QWaylandObject::QWaylandObject(QObjectPrivate &d, QObject *parent) QWaylandObject::~QWaylandObject() { - for (QWaylandCompositorExtension *extension : qAsConst(extension_vector)) + for (QWaylandCompositorExtension *extension : std::as_const(extension_vector)) QWaylandCompositorExtensionPrivate::get(extension)->extension_container = nullptr; } +/*! + * Returns the compositor extension which matches \a name if one has been registered with the + * QWaylandObject. If no extension matching the name has been registered, this function returns + * null. + */ QWaylandCompositorExtension *QWaylandObject::extension(const QByteArray &name) { for (int i = 0; i < extension_vector.size(); i++) { @@ -159,6 +240,11 @@ QWaylandCompositorExtension *QWaylandObject::extension(const QByteArray &name) return nullptr; } +/*! + * Returns the compositor extension which matches \a interface if one has been registered with the + * QWaylandObject. If no extension matching the interface has been registered, this function + * returns null. + */ QWaylandCompositorExtension *QWaylandObject::extension(const wl_interface *interface) { for (int i = 0; i < extension_vector.size(); i++) { @@ -168,21 +254,35 @@ QWaylandCompositorExtension *QWaylandObject::extension(const wl_interface *inter return nullptr; } +/*! + * Returns the list of compositor extensions that have been registered with this QWaylandObject. + */ QList<QWaylandCompositorExtension *> QWaylandObject::extensions() const { return extension_vector; } +/*! + * Registers \a extension with this QWaylandObject. + */ void QWaylandObject::addExtension(QWaylandCompositorExtension *extension) { Q_ASSERT(!extension_vector.contains(extension)); extension_vector.append(extension); } +/*! + * Removes \a extension from the list of registered extensions in this QWaylandObject, if it has + * previously been registered using \l{addExtension()}. + */ void QWaylandObject::removeExtension(QWaylandCompositorExtension *extension) { + if (!extension->isInitialized()) + return; Q_ASSERT(extension_vector.contains(extension)); extension_vector.removeOne(extension); } QT_END_NAMESPACE + +#include "moc_qwaylandcompositorextension.cpp" diff --git a/src/compositor/global/qwaylandcompositorextension.h b/src/compositor/global/qwaylandcompositorextension.h index 4f0014b81..cea7c7de0 100644 --- a/src/compositor/global/qwaylandcompositorextension.h +++ b/src/compositor/global/qwaylandcompositorextension.h @@ -1,49 +1,13 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDEXTENSION_H #define QWAYLANDEXTENSION_H #include <QtWaylandCompositor/qtwaylandcompositorglobal.h> +#include <QtWaylandCompositor/qtwaylandqmlinclude.h> #include <QtCore/QObject> -#include <QtCore/QVector> struct wl_interface; @@ -53,7 +17,7 @@ class QWaylandCompositor; class QWaylandCompositorExtension; class QWaylandCompositorExtensionPrivate; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandObject : public QObject +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandObject : public QObject { Q_OBJECT public: @@ -71,10 +35,13 @@ protected: QList<QWaylandCompositorExtension *> extension_vector; }; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandCompositorExtension : public QWaylandObject +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandCompositorExtension : public QWaylandObject { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandCompositorExtension) + QML_NAMED_ELEMENT(WaylandExtension) + QML_ADDED_IN_VERSION(1, 0) + QML_UNCREATABLE("") public: QWaylandCompositorExtension(); QWaylandCompositorExtension(QWaylandObject *container); @@ -96,7 +63,7 @@ protected: }; template <typename T> -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandCompositorExtensionTemplate : public QWaylandCompositorExtension +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandCompositorExtensionTemplate : public QWaylandCompositorExtension { public: QWaylandCompositorExtensionTemplate() diff --git a/src/compositor/global/qwaylandcompositorextension_p.h b/src/compositor/global/qwaylandcompositorextension_p.h index 6ec810988..7af7a6e05 100644 --- a/src/compositor/global/qwaylandcompositorextension_p.h +++ b/src/compositor/global/qwaylandcompositorextension_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDEXTENSION_P_H #define QWAYLANDEXTENSION_P_H @@ -57,7 +21,7 @@ QT_BEGIN_NAMESPACE -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandCompositorExtensionPrivate : public QObjectPrivate +class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandCompositorExtensionPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QWaylandCompositorExtension) diff --git a/src/compositor/global/qwaylandquickextension.cpp b/src/compositor/global/qwaylandquickextension.cpp new file mode 100644 index 000000000..bd594eba2 --- /dev/null +++ b/src/compositor/global/qwaylandquickextension.cpp @@ -0,0 +1,12 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include "qwaylandquickextension.h" + +QT_REQUIRE_CONFIG(wayland_compositor_quick); + +QT_BEGIN_NAMESPACE + +QT_END_NAMESPACE + +#include "moc_qwaylandquickextension.cpp" diff --git a/src/compositor/global/qwaylandquickextension.h b/src/compositor/global/qwaylandquickextension.h index c721bcb97..5286f120a 100644 --- a/src/compositor/global/qwaylandquickextension.h +++ b/src/compositor/global/qwaylandquickextension.h @@ -1,53 +1,23 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDQUICKEXTENSION_H #define QWAYLANDQUICKEXTENSION_H +#if 0 +#pragma qt_class(QWaylandQuickExtension) +#endif + #include <QtWaylandCompositor/QWaylandCompositorExtension> #include <QtQml/QQmlParserStatus> #include <QtQml/QQmlListProperty> +QT_REQUIRE_CONFIG(wayland_compositor_quick); + QT_BEGIN_NAMESPACE #define Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CLASS(className) \ - class Q_WAYLAND_COMPOSITOR_EXPORT className##QuickExtension : public className, public QQmlParserStatus \ + class Q_WAYLANDCOMPOSITOR_EXPORT className##QuickExtension : public className, public QQmlParserStatus \ { \ /* qmake ignore Q_OBJECT */ \ Q_OBJECT \ @@ -57,7 +27,7 @@ QT_BEGIN_NAMESPACE public: \ QQmlListProperty<QObject> data() \ { \ - return QQmlListProperty<QObject>(this, m_objects); \ + return QQmlListProperty<QObject>(this, &m_objects); \ } \ void classBegin() override {} \ void componentComplete() override { if (!isInitialized()) initialize(); } \ @@ -66,7 +36,7 @@ QT_BEGIN_NAMESPACE }; #define Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CONTAINER_CLASS(className) \ - class Q_WAYLAND_COMPOSITOR_EXPORT className##QuickExtensionContainer : public className \ + class Q_WAYLANDCOMPOSITOR_EXPORT className##QuickExtensionContainer : public className \ { \ /* qmake ignore Q_OBJECT */ \ Q_OBJECT \ @@ -76,7 +46,7 @@ QT_BEGIN_NAMESPACE public: \ QQmlListProperty<QObject> data() \ { \ - return QQmlListProperty<QObject>(this, m_objects); \ + return QQmlListProperty<QObject>(this, &m_objects); \ } \ QQmlListProperty<QWaylandCompositorExtension> extensions() \ { \ @@ -107,6 +77,66 @@ QT_BEGIN_NAMESPACE QList<QObject *> m_objects; \ }; +#define Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_NAMED_CLASS(className, QmlType) \ + Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_NAMED_ELEMENT(className, QmlType, 1, 0) + +#define Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_NAMED_ELEMENT(...) \ + QT_OVERLOADED_MACRO(Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_NAMED_ELEMENT, __VA_ARGS__) + +#define Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_NAMED_ELEMENT_4(className, QmlType, versionMajor, \ + versionMinor) \ + class Q_WAYLANDCOMPOSITOR_EXPORT className##QuickExtension : public className, \ + public QQmlParserStatus \ + { \ + /* qmake ignore Q_OBJECT */ \ + Q_OBJECT \ + Q_PROPERTY(QQmlListProperty<QObject> data READ data DESIGNABLE false) \ + Q_CLASSINFO("DefaultProperty", "data") \ + Q_INTERFACES(QQmlParserStatus) \ + QML_NAMED_ELEMENT(QmlType) \ + QML_ADDED_IN_VERSION(versionMajor, versionMinor) \ + public: \ + QQmlListProperty<QObject> data() \ + { \ + return QQmlListProperty<QObject>(this, &m_objects); \ + } \ + void classBegin() override { } \ + void componentComplete() override \ + { \ + if (!isInitialized()) \ + initialize(); \ + } \ + \ + private: \ + QList<QObject *> m_objects; \ + }; + +#define Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_NAMED_ELEMENT_2(className, QmlType) \ + class Q_WAYLANDCOMPOSITOR_EXPORT className##QuickExtension : public className, \ + public QQmlParserStatus \ + { \ + /* qmake ignore Q_OBJECT */ \ + Q_OBJECT \ + Q_PROPERTY(QQmlListProperty<QObject> data READ data DESIGNABLE false) \ + Q_CLASSINFO("DefaultProperty", "data") \ + Q_INTERFACES(QQmlParserStatus) \ + QML_NAMED_ELEMENT(QmlType) \ + public: \ + QQmlListProperty<QObject> data() \ + { \ + return QQmlListProperty<QObject>(this, &m_objects); \ + } \ + void classBegin() override { } \ + void componentComplete() override \ + { \ + if (!isInitialized()) \ + initialize(); \ + } \ + \ + private: \ + QList<QObject *> m_objects; \ + }; + QT_END_NAMESPACE #endif /*QWAYLANDQUICKEXTENSION_H*/ diff --git a/src/compositor/global/qwaylandquickextension.qdoc b/src/compositor/global/qwaylandquickextension.qdoc new file mode 100644 index 000000000..f3a213a11 --- /dev/null +++ b/src/compositor/global/qwaylandquickextension.qdoc @@ -0,0 +1,85 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only + +/*! + * \headerfile <QWaylandQuickExtension> + * \title Qt Wayland Compositor Qt Quick Extension Macro Declarations + * \inmodule QtWaylandCompositor + * \ingroup funclists + * + * \brief The <QWaylandQuickExtension> header file includes macros for creating Qt Quick types + * that correspond to subclasses of QWaylandCompositorExtension and QWaylandObject. + * + * If you are creating extensions to Qt Wayland Compositor, the macros in the QWaylandQuickExtension + * header may be a useful alternative to manually implementing the required parts for each class. + * + * \sa {Custom Shell} + */ + +/*! + * \macro Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CLASS(className) + * \relates <QWaylandQuickExtension> + * + * This macro can be used to define a Qt Quick class based on a Wayland extension. It defines + * a new class which inherits from \a className and which suffixes the name with "QuickExtension". + * + * The class should be a subclass of QWaylandCompositorExtension, and + * \l{QWaylandCompositorExtension::initialize()} will be called automatically. The type must be + * manually registered in Qt Quick using \l{qmlRegisterType()}. + * + * \sa Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_NAMED_ELEMENT + */ + +/*! + * \macro Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CONTAINER_CLASS(className) + * \relates <QWaylandQuickExtension> + * + * This macro can be used to define a Qt Quick class intended to contain Wayland extensions. It + * + * It defines a new class which inherits from \a className and which suffixes the name with + * "QuickExtensionContainer". The class given by \a className should inherit from QWaylandObject, + * and the new class will have an \c extensions property which manages the extensions by calling + * \l{QWaylandObject::addExtension()}{addExtension()} and + * \l{QWaylandObject::removeExtension()}{removeExtension()} in the base class. + * + * The type must be manually registered in Qt Quick using \l{qmlRegisterType()}. + */ + +/*! + * \macro Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_NAMED_CLASS(className, QmlType) + * \relates <QWaylandQuickExtension> + * \deprecated [6.8] Use Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_NAMED_ELEMENT instead. + * + * This macro can be used to define a Qt Quick class based on a Wayland extension. It defines + * a new class which inherits from \a className and which suffixes the name with "QuickExtension". + * + * The macro works the same as \l{Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CLASS}, but will also + * automatically register the new type as \a QmlType in the current QML module with \l + * QML_ADDED_IN_VERSION set to 1.0. + */ + +/*! +\macro Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_NAMED_ELEMENT(className, QmlType) +\relates <QWaylandQuickExtension> +\since 6.8 + +This macro can be used to define a Qt Quick class based on a Wayland extension. It defines +a new class which inherits from \a className and which suffixes the name with "QuickExtension". + +The macro works the same as \l{Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CLASS}, but will also +automatically register the new type as \a QmlType in the current QML module. +*/ + +/*! +\macro Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_NAMED_ELEMENT(className, QmlType, versionMajor, versionMinor) +\relates <QWaylandQuickExtension> +\internal +\since 6.8 + +This macro can be used to define a Qt Quick class based on a Wayland extension. It defines +a new class which inherits from \a className and which suffixes the name with "QuickExtension". + +The macro works the same as \l{Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CLASS}, but will also +automatically register the new type as \a QmlType in the current QML module with +\l QML_ADDED_IN_VERSION set to the version passed via \a versionMajor and \a versionMinor. + */ diff --git a/src/compositor/global/qwaylandutils_p.h b/src/compositor/global/qwaylandutils_p.h index 934e27617..5c07163bd 100644 --- a/src/compositor/global/qwaylandutils_p.h +++ b/src/compositor/global/qwaylandutils_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QWAYLANDUTILS_P_H #define QWAYLANDUTILS_P_H @@ -51,7 +15,7 @@ // We mean it. // -#include <QtCore/qglobal.h> +#include <QtCore/private/qglobal_p.h> struct wl_resource; |