diff options
author | Erik Larsson <erik@ortogonal.com> | 2016-01-03 15:51:27 +0100 |
---|---|---|
committer | Erik Larsson <erik@ortogonal.com> | 2016-03-18 07:38:55 +0000 |
commit | 47202ee55978d12e27efb0e3ebbe841fb1af043f (patch) | |
tree | 2b85fde7db285b9a85323c74ba5d2d09549a1e61 /examples | |
parent | c7aa6bae0cf827d5a6bbfebea947d557b56a2bfb (diff) |
Simplify client-side API for Wayland extensions
This simplifies the client-side API for Wayland extensions by
introducing QWaylandClientExtension/QWaylandClientExtensionTemplate
classes. These classes takes care of the initialization of the extension
if it matches the interface name.
Change-Id: I7c4fb34563563af4be072cdebda54954b79cddbe
Reviewed-by: Johan Helsing <johan.helsing@theqtcompany.com>
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
Diffstat (limited to 'examples')
3 files changed, 7 insertions, 27 deletions
diff --git a/examples/wayland/custom-extension/client/customextension.cpp b/examples/wayland/custom-extension/client/customextension.cpp index 81694fdab..68a1d4b81 100644 --- a/examples/wayland/custom-extension/client/customextension.cpp +++ b/examples/wayland/custom-extension/client/customextension.cpp @@ -48,14 +48,9 @@ QT_BEGIN_NAMESPACE namespace QtWaylandClient { -CustomExtension::CustomExtension(QWaylandIntegration *wayland_integration) - : m_display(0) +CustomExtension::CustomExtension() + : QWaylandClientExtensionTemplate(/* Supported protocol version */ 1 ) { - // TODO: add a simpler API for this - - QtWaylandClient::QWaylandDisplay *wayland_display = wayland_integration->display(); - struct ::wl_registry *registry = wl_display_get_registry(wayland_display->wl_display()); - QtWayland::wl_registry::init(registry); } void CustomExtension::sendRequest(const QString &text, int value) @@ -73,13 +68,6 @@ void CustomExtension::example_extension_qtevent(struct wl_surface *surface, emit eventReceived(text, value); } -void CustomExtension::registry_global(uint32_t id, const QString &interface, uint32_t version) -{ - if (interface == QStringLiteral("qt_example_extension")) { - QtWayland::qt_example_extension::init(QtWayland::wl_registry::object(), id, version); - } -} - } QT_END_NAMESPACE diff --git a/examples/wayland/custom-extension/client/customextension.h b/examples/wayland/custom-extension/client/customextension.h index d8797a9eb..16ace4bfd 100644 --- a/examples/wayland/custom-extension/client/customextension.h +++ b/examples/wayland/custom-extension/client/customextension.h @@ -43,20 +43,18 @@ #include <qpa/qwindowsysteminterface.h> #include <QtWaylandClient/private/qwayland-wayland.h> +#include <QtWaylandClient/qwaylandclientextension.h> #include "qwayland-custom.h" QT_BEGIN_NAMESPACE namespace QtWaylandClient { -class QWaylandDisplay; -class QWaylandIntegration; - -class CustomExtension : public QObject, QtWayland::qt_example_extension, public QtWayland::wl_registry +class CustomExtension : public QWaylandClientExtensionTemplate<CustomExtension>, public QtWayland::qt_example_extension { Q_OBJECT public: - CustomExtension(QWaylandIntegration *wayland_integration); + CustomExtension(); public slots: void sendRequest(const QString &text, int value); @@ -65,15 +63,11 @@ signals: void eventReceived(const QString &text, uint value); private: - QWaylandDisplay *m_display; - void example_extension_qtevent(struct wl_surface *surface, uint32_t time, const QString &text, uint32_t value) Q_DECL_OVERRIDE; - void registry_global(uint32_t id, const QString &interface, uint32_t version) Q_DECL_OVERRIDE; - }; } diff --git a/examples/wayland/custom-extension/client/main.cpp b/examples/wayland/custom-extension/client/main.cpp index 907053886..fe8ec59a8 100644 --- a/examples/wayland/custom-extension/client/main.cpp +++ b/examples/wayland/custom-extension/client/main.cpp @@ -66,9 +66,7 @@ public: qDebug() << "************* The Qt Custom Extension Example Plugin is active ************"; - QWaylandIntegration *integration = new QWaylandIntegration(); - - extension_global = new CustomExtension(integration); + extension_global = new CustomExtension(); // We need a way for client apps to get hold of the extension. The proper API for this is // QPlatformNativeInterface, but that's a low-level API using void*. There will be a nice @@ -77,7 +75,7 @@ public: extension_global->setParent(qApp); extension_global->setObjectName("qt_example_custom_extension"); - return integration; + return extension_global->integration(); } } |