From d3afe18e88ba158b4eff13f6a0a359176d44c36d Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Thu, 1 Sep 2016 09:26:39 +0200 Subject: Add QML API and documentation for ivi-application Change-Id: I65504503f07477b05f7e645ee61544e62e728bdc Reviewed-by: Paul Olav Tvete --- src/compositor/extensions/extensions.pri | 2 + .../extensions/qwaylandiviapplication.cpp | 16 +++++ src/compositor/extensions/qwaylandivisurface.cpp | 29 +++++++- .../extensions/qwaylandivisurfaceintegration.cpp | 64 ++++++++++++++++++ .../extensions/qwaylandivisurfaceintegration_p.h | 77 ++++++++++++++++++++++ .../compositor/qwaylandquickcompositorplugin.cpp | 5 ++ 6 files changed, 192 insertions(+), 1 deletion(-) create mode 100644 src/compositor/extensions/qwaylandivisurfaceintegration.cpp create mode 100644 src/compositor/extensions/qwaylandivisurfaceintegration_p.h diff --git a/src/compositor/extensions/extensions.pri b/src/compositor/extensions/extensions.pri index eda13476b..9c5b37eac 100644 --- a/src/compositor/extensions/extensions.pri +++ b/src/compositor/extensions/extensions.pri @@ -49,11 +49,13 @@ qtHaveModule(quick):contains(QT_CONFIG, opengl) { HEADERS += \ extensions/qwaylandquickshellsurfaceitem.h \ extensions/qwaylandquickshellsurfaceitem_p.h \ + extensions/qwaylandivisurfaceintegration_p.h \ extensions/qwaylandwlshellintegration_p.h \ extensions/qwaylandxdgshellv5integration_p.h \ SOURCES += \ extensions/qwaylandquickshellsurfaceitem.cpp \ + extensions/qwaylandivisurfaceintegration.cpp \ extensions/qwaylandwlshellintegration.cpp \ extensions/qwaylandxdgshellv5integration.cpp \ diff --git a/src/compositor/extensions/qwaylandiviapplication.cpp b/src/compositor/extensions/qwaylandiviapplication.cpp index c3eea08d7..30784e4ec 100644 --- a/src/compositor/extensions/qwaylandiviapplication.cpp +++ b/src/compositor/extensions/qwaylandiviapplication.cpp @@ -90,6 +90,15 @@ QByteArray QWaylandIviApplication::interfaceName() return QWaylandIviApplicationPrivate::interfaceName(); } +/*! + * \qmlsignal void QtWaylandCompositor::IviApplication::iviSurfaceRequested(object surface, int iviId, object resource) + * + * This signal is emitted when the client has requested an \c ivi_surface to be associated + * with \a surface, which is identified by \a id. The handler for this signal is + * expected to create the ivi surface and initialize it within the scope of the + * signal emission. If no ivi surface is created, a default one will be created instead. + */ + /*! * \fn void QWaylandWlShell::iviSurfaceRequested(QWaylandSurface *surface, uint iviId, const QWaylandResource &resource) * @@ -99,6 +108,13 @@ QByteArray QWaylandIviApplication::interfaceName() * signal emission. If no ivi surface is created, a default one will be created instead. */ +/*! + * \qmlsignal void QtWaylandCompositor::IviApplication::iviSurfaceCreated(object *iviSurface) + * + * This signal is emitted when an IviSurface has been created. The supplied \a iviSurface is + * most commonly used to instantiate a ShellSurfaceItem. + */ + /*! * \fn void QtWaylandCompositor::IviApplication::iviSurfaceCreated(QWaylandIviSurface *iviSurface) * diff --git a/src/compositor/extensions/qwaylandivisurface.cpp b/src/compositor/extensions/qwaylandivisurface.cpp index 4708243a6..bed3eb057 100644 --- a/src/compositor/extensions/qwaylandivisurface.cpp +++ b/src/compositor/extensions/qwaylandivisurface.cpp @@ -37,6 +37,7 @@ #include "qwaylandivisurface.h" #include "qwaylandivisurface_p.h" #include "qwaylandiviapplication_p.h" +#include "qwaylandivisurfaceintegration_p.h" #include @@ -67,6 +68,13 @@ QWaylandIviSurface::QWaylandIviSurface(QWaylandIviApplication *application, QWay initialize(application, surface, iviId, resource); } +/*! + * \qmlmethod void QtWaylandCompositor::IviSurface::initialize(object iviApplication, object surface, int iviId, object resource) + * + * Initializes the IviSurface, associating it with the given \a iviApplication, \a surface, + * \a client, \a iviId, and \a resource. + */ + /*! * Initializes the QWaylandIviSurface, associating it with the given \a iviApplication, \a surface, * \a iviId, and \a resource. @@ -88,6 +96,12 @@ void QWaylandIviSurface::initialize(QWaylandIviApplication *iviApplication, QWay QWaylandCompositorExtension::initialize(); } +/*! + * \qmlproperty object QtWaylandCompositor::IviSurface::surface + * + * This property holds the surface associated with this IviSurface. + */ + /*! * \property QWaylandIviSurface::surface * @@ -99,6 +113,13 @@ QWaylandSurface *QWaylandIviSurface::surface() const return d->m_surface; } +/*! + * \qmlproperty int QtWaylandCompositor::IviSurface::iviId + * \readonly + * + * This property holds the ivi id id of this IviSurface. + */ + /*! * \property QWaylandClient::iviId * @@ -142,6 +163,12 @@ QWaylandIviSurface *QWaylandIviSurface::fromResource(wl_resource *resource) return static_cast(iviSurfaceResource->ivi_surface_object)->q_func(); } +/*! + * \qmlmethod int QtWaylandCompositor::IviSurface::sendConfigure(size size) + * + * Sends a configure event to the client, telling it to resize the surface to the given \a size. + */ + /*! * Sends a configure event to the client, telling it to resize the surface to the given \a size. */ @@ -154,7 +181,7 @@ void QWaylandIviSurface::sendConfigure(const QSize &size) #ifdef QT_WAYLAND_COMPOSITOR_QUICK QWaylandQuickShellIntegration *QWaylandIviSurface::createIntegration(QWaylandQuickShellSurfaceItem *item) { - return nullptr; // TODO + return new QtWayland::IviSurfaceIntegration(item); } #endif diff --git a/src/compositor/extensions/qwaylandivisurfaceintegration.cpp b/src/compositor/extensions/qwaylandivisurfaceintegration.cpp new file mode 100644 index 000000000..3a3d9c1c9 --- /dev/null +++ b/src/compositor/extensions/qwaylandivisurfaceintegration.cpp @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtWaylandCompositor module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwaylandivisurfaceintegration_p.h" + +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +namespace QtWayland { + +IviSurfaceIntegration::IviSurfaceIntegration(QWaylandQuickShellSurfaceItem *item) + : QWaylandQuickShellIntegration(item) + , m_item(item) + , m_shellSurface(qobject_cast(item->shellSurface())) +{ + m_item->setSurface(m_shellSurface->surface()); + connect(m_shellSurface, &QWaylandIviSurface::destroyed, this, &IviSurfaceIntegration::handleIviSurfaceDestroyed); +} + +void IviSurfaceIntegration::handleIviSurfaceDestroyed() +{ + m_shellSurface = nullptr; +} + +} + +QT_END_NAMESPACE diff --git a/src/compositor/extensions/qwaylandivisurfaceintegration_p.h b/src/compositor/extensions/qwaylandivisurfaceintegration_p.h new file mode 100644 index 000000000..534caf642 --- /dev/null +++ b/src/compositor/extensions/qwaylandivisurfaceintegration_p.h @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtWaylandCompositor module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWAYLANDIVISURFACEINTEGRATION_H +#define QWAYLANDIVISURFACEINTEGRATION_H + +#include + +#include + +QT_BEGIN_NAMESPACE + +// +// 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. +// + +namespace QtWayland { + +class IviSurfaceIntegration : public QWaylandQuickShellIntegration +{ + Q_OBJECT +public: + IviSurfaceIntegration(QWaylandQuickShellSurfaceItem *item); + +private Q_SLOTS: + void handleIviSurfaceDestroyed(); + +private: + QWaylandQuickShellSurfaceItem *m_item; + QWaylandIviSurface *m_shellSurface; +}; + +} + +QT_END_NAMESPACE + +#endif // QWAYLANDIVISURFACEINTEGRATION_H diff --git a/src/imports/compositor/qwaylandquickcompositorplugin.cpp b/src/imports/compositor/qwaylandquickcompositorplugin.cpp index e8204f7f2..28c517fd5 100644 --- a/src/imports/compositor/qwaylandquickcompositorplugin.cpp +++ b/src/imports/compositor/qwaylandquickcompositorplugin.cpp @@ -56,6 +56,8 @@ #include #include #include +#include +#include #include #include "qwaylandmousetracker_p.h" @@ -64,6 +66,7 @@ QT_BEGIN_NAMESPACE Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CONTAINER_CLASS(QWaylandQuickCompositor) Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CLASS(QWaylandQtWindowManager) +Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CLASS(QWaylandIviApplication) Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CLASS(QWaylandWlShell) Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CLASS(QWaylandXdgShellV5) Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CLASS(QWaylandTextInputManager) @@ -133,6 +136,8 @@ public: //This should probably be somewhere else qmlRegisterType(uri, 1, 0, "QtWindowManager"); + qmlRegisterType(uri, 1, 0, "IviApplication"); + qmlRegisterType(uri, 1, 0, "IviSurface"); qmlRegisterType(uri, 1, 0, "WlShell"); qmlRegisterType(uri, 1, 0, "WlShellSurface"); qmlRegisterType(uri, 1, 0, "ShellSurfaceItem"); -- cgit v1.2.3