From 4c5920fc041ee42e3aae6c954d48eb424c453de9 Mon Sep 17 00:00:00 2001 From: Giulio Camuffo Date: Sat, 23 Aug 2014 20:00:03 +0300 Subject: Explicitly define the interface versions Currently a global is bound with the version the interface has in the xml file. This is a problem for apps that explicitly link to libwayland-client because they may link to a newer libwayland, so the version of some interface may be higher than the one that it is actually implemented. Change-Id: Id0dbe6c0f1e05fe91954b9d8d9472d42d2053cdc Reviewed-by: Laszlo Agocs --- examples/server-buffer/client/main.cpp | 2 +- .../hardwareintegration/qwaylandhardwareintegration.cpp | 2 +- src/client/qwaylanddatadevicemanager.cpp | 2 +- src/client/qwaylanddisplay.cpp | 12 ++++++------ src/client/qwaylandinputdevice.cpp | 2 +- src/client/qwaylandqtkey.cpp | 2 +- src/client/qwaylandscreen.cpp | 2 +- src/client/qwaylandtouch.cpp | 2 +- src/client/qwaylandwindowmanagerintegration.cpp | 2 +- src/client/qwaylandxdgshell.cpp | 2 +- .../client/drm-egl-server/drmeglserverbufferintegration.cpp | 2 +- .../libhybriseglserverbufferintegration.cpp | 2 +- src/qtwaylandscanner/qtwaylandscanner.cpp | 12 ++++++------ 13 files changed, 23 insertions(+), 23 deletions(-) diff --git a/examples/server-buffer/client/main.cpp b/examples/server-buffer/client/main.cpp index ce705b6a..54c586ce 100644 --- a/examples/server-buffer/client/main.cpp +++ b/examples/server-buffer/client/main.cpp @@ -149,7 +149,7 @@ protected: { Q_UNUSED(version); if (interface == QStringLiteral("qt_share_buffer")) { - QtWayland::qt_share_buffer::init(QtWayland::wl_registry::object(), name); + QtWayland::qt_share_buffer::init(QtWayland::wl_registry::object(), name, 1); } } diff --git a/src/client/hardwareintegration/qwaylandhardwareintegration.cpp b/src/client/hardwareintegration/qwaylandhardwareintegration.cpp index a7269ce9..469f8036 100644 --- a/src/client/hardwareintegration/qwaylandhardwareintegration.cpp +++ b/src/client/hardwareintegration/qwaylandhardwareintegration.cpp @@ -45,7 +45,7 @@ QT_BEGIN_NAMESPACE QWaylandHardwareIntegration::QWaylandHardwareIntegration(struct ::wl_registry *registry, int id) - : qt_hardware_integration(registry, id) + : qt_hardware_integration(registry, id, 1) { } diff --git a/src/client/qwaylanddatadevicemanager.cpp b/src/client/qwaylanddatadevicemanager.cpp index 1aef7734..ea578ff7 100644 --- a/src/client/qwaylanddatadevicemanager.cpp +++ b/src/client/qwaylanddatadevicemanager.cpp @@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id) - : wl_data_device_manager(display->wl_registry(), id) + : wl_data_device_manager(display->wl_registry(), id, 1) , m_display(display) { // Create transfer devices for all input devices. diff --git a/src/client/qwaylanddisplay.cpp b/src/client/qwaylanddisplay.cpp index 94bfa88b..595d2ce7 100644 --- a/src/client/qwaylanddisplay.cpp +++ b/src/client/qwaylanddisplay.cpp @@ -219,33 +219,33 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin // We need to get the output events before creating surfaces forceRoundTrip(); } else if (interface == QStringLiteral("wl_compositor")) { - mCompositor.init(registry, id); + mCompositor.init(registry, id, 3); } else if (interface == QStringLiteral("wl_shm")) { mShm = static_cast(wl_registry_bind(registry, id, &wl_shm_interface,1)); } else if (interface == QStringLiteral("xdg_shell") && qEnvironmentVariableIsSet("QT_WAYLAND_USE_XDG_SHELL")) { mShellXdg.reset(new QWaylandXdgShell(registry,id)); } else if (interface == QStringLiteral("wl_shell")){ - mShell.reset(new QtWayland::wl_shell(registry, id)); + mShell.reset(new QtWayland::wl_shell(registry, id, 1)); } else if (interface == QStringLiteral("wl_seat")) { QWaylandInputDevice *inputDevice = new QWaylandInputDevice(this, id); mInputDevices.append(inputDevice); } else if (interface == QStringLiteral("wl_data_device_manager")) { mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, id)); } else if (interface == QStringLiteral("qt_output_extension")) { - mOutputExtension.reset(new QtWayland::qt_output_extension(registry, id)); + mOutputExtension.reset(new QtWayland::qt_output_extension(registry, id, 1)); foreach (QPlatformScreen *screen, screens()) static_cast(screen)->createExtendedOutput(); } else if (interface == QStringLiteral("qt_surface_extension")) { - mWindowExtension.reset(new QtWayland::qt_surface_extension(registry, id)); + mWindowExtension.reset(new QtWayland::qt_surface_extension(registry, id, 1)); } else if (interface == QStringLiteral("qt_sub_surface_extension")) { - mSubSurfaceExtension.reset(new QtWayland::qt_sub_surface_extension(registry, id)); + mSubSurfaceExtension.reset(new QtWayland::qt_sub_surface_extension(registry, id, 1)); } else if (interface == QStringLiteral("qt_touch_extension")) { mTouchExtension.reset(new QWaylandTouchExtension(this, id)); } else if (interface == QStringLiteral("qt_key_extension")) { mQtKeyExtension.reset(new QWaylandQtKeyExtension(this, id)); } else if (interface == QStringLiteral("wl_text_input_manager")) { - mTextInputManager.reset(new QtWayland::wl_text_input_manager(registry, id)); + mTextInputManager.reset(new QtWayland::wl_text_input_manager(registry, id, 1)); } else if (interface == QStringLiteral("qt_hardware_integration")) { mHardwareIntegration.reset(new QWaylandHardwareIntegration(registry, id)); // make a roundtrip here since we need to receive the events sent by diff --git a/src/client/qwaylandinputdevice.cpp b/src/client/qwaylandinputdevice.cpp index 145ef608..6c132010 100644 --- a/src/client/qwaylandinputdevice.cpp +++ b/src/client/qwaylandinputdevice.cpp @@ -228,7 +228,7 @@ public: QWaylandInputDevice::QWaylandInputDevice(QWaylandDisplay *display, uint32_t id) : QObject() - , QtWayland::wl_seat(display->wl_registry(), id) + , QtWayland::wl_seat(display->wl_registry(), id, 2) , mQDisplay(display) , mDisplay(display->wl_display()) , mCaps(0) diff --git a/src/client/qwaylandqtkey.cpp b/src/client/qwaylandqtkey.cpp index 197914b0..16562357 100644 --- a/src/client/qwaylandqtkey.cpp +++ b/src/client/qwaylandqtkey.cpp @@ -46,7 +46,7 @@ QT_BEGIN_NAMESPACE QWaylandQtKeyExtension::QWaylandQtKeyExtension(QWaylandDisplay *display, uint32_t id) - : QtWayland::qt_key_extension(display->wl_registry(), id) + : QtWayland::qt_key_extension(display->wl_registry(), id, 2) , m_display(display) { } diff --git a/src/client/qwaylandscreen.cpp b/src/client/qwaylandscreen.cpp index fde5751d..19c3e5d4 100644 --- a/src/client/qwaylandscreen.cpp +++ b/src/client/qwaylandscreen.cpp @@ -55,7 +55,7 @@ QT_BEGIN_NAMESPACE QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, uint32_t id) : QPlatformScreen() - , QtWayland::wl_output(waylandDisplay->wl_registry(), id) + , QtWayland::wl_output(waylandDisplay->wl_registry(), id, 2) , mWaylandDisplay(waylandDisplay) , mExtendedOutput(0) , mDepth(32) diff --git a/src/client/qwaylandtouch.cpp b/src/client/qwaylandtouch.cpp index 71cc1c3c..3dabd1ea 100644 --- a/src/client/qwaylandtouch.cpp +++ b/src/client/qwaylandtouch.cpp @@ -46,7 +46,7 @@ QT_BEGIN_NAMESPACE QWaylandTouchExtension::QWaylandTouchExtension(QWaylandDisplay *display, uint32_t id) - : QtWayland::qt_touch_extension(display->wl_registry(), id), + : QtWayland::qt_touch_extension(display->wl_registry(), id, 1), mDisplay(display), mTouchDevice(0), mPointsLeft(0), diff --git a/src/client/qwaylandwindowmanagerintegration.cpp b/src/client/qwaylandwindowmanagerintegration.cpp index c2e0153a..174ef93a 100644 --- a/src/client/qwaylandwindowmanagerintegration.cpp +++ b/src/client/qwaylandwindowmanagerintegration.cpp @@ -95,7 +95,7 @@ void QWaylandWindowManagerIntegration::wlHandleListenerGlobal(void *data, wl_reg { Q_UNUSED(version); if (interface == QStringLiteral("qt_windowmanager")) - static_cast(data)->init(registry, id); + static_cast(data)->init(registry, id, 1); } void QWaylandWindowManagerIntegration::windowmanager_hints(int32_t showIsFullScreen) diff --git a/src/client/qwaylandxdgshell.cpp b/src/client/qwaylandxdgshell.cpp index eb9f91c4..8a96a030 100644 --- a/src/client/qwaylandxdgshell.cpp +++ b/src/client/qwaylandxdgshell.cpp @@ -57,7 +57,7 @@ QWaylandXdgShell::QWaylandXdgShell(struct ::xdg_shell *shell) } QWaylandXdgShell::QWaylandXdgShell(struct ::wl_registry *registry, uint32_t id) - : QtWayland::xdg_shell(registry, id) + : QtWayland::xdg_shell(registry, id, 1) { use_unstable_version(QtWayland::xdg_shell::version_current); } diff --git a/src/hardwareintegration/client/drm-egl-server/drmeglserverbufferintegration.cpp b/src/hardwareintegration/client/drm-egl-server/drmeglserverbufferintegration.cpp index beb9106b..ac969114 100644 --- a/src/hardwareintegration/client/drm-egl-server/drmeglserverbufferintegration.cpp +++ b/src/hardwareintegration/client/drm-egl-server/drmeglserverbufferintegration.cpp @@ -150,7 +150,7 @@ void DrmEglServerBufferIntegration::registry_global(uint32_t name, const QString Q_UNUSED(version); if (interface == QStringLiteral("qt_drm_egl_server_buffer")) { struct ::wl_registry *registry = QtWayland::wl_registry::object(); - QtWayland::qt_drm_egl_server_buffer::init(registry, name); + QtWayland::qt_drm_egl_server_buffer::init(registry, name, 1); } } diff --git a/src/hardwareintegration/client/libhybris-egl-server/libhybriseglserverbufferintegration.cpp b/src/hardwareintegration/client/libhybris-egl-server/libhybriseglserverbufferintegration.cpp index 0fcfca43..a723ae59 100644 --- a/src/hardwareintegration/client/libhybris-egl-server/libhybriseglserverbufferintegration.cpp +++ b/src/hardwareintegration/client/libhybris-egl-server/libhybriseglserverbufferintegration.cpp @@ -159,7 +159,7 @@ void LibHybrisEglServerBufferIntegration::registry_global(uint32_t name, const Q Q_UNUSED(version); if (interface == QStringLiteral("qt_libhybris_egl_server_buffer")) { struct ::wl_registry *registry = QtWayland::wl_registry::object(); - QtWayland::qt_libhybris_egl_server_buffer::init(registry, name); + QtWayland::qt_libhybris_egl_server_buffer::init(registry, name, 1); } } diff --git a/src/qtwaylandscanner/qtwaylandscanner.cpp b/src/qtwaylandscanner/qtwaylandscanner.cpp index 475b9fec..c99bf2b4 100644 --- a/src/qtwaylandscanner/qtwaylandscanner.cpp +++ b/src/qtwaylandscanner/qtwaylandscanner.cpp @@ -822,13 +822,13 @@ void process(QXmlStreamReader &xml, const QByteArray &headerPath, const QByteArr printf(" class %s %s\n {\n", clientExport.constData(), interfaceName); printf(" public:\n"); - printf(" %s(struct ::wl_registry *registry, int id);\n", interfaceName); + printf(" %s(struct ::wl_registry *registry, int id, int version);\n", interfaceName); printf(" %s(struct ::%s *object);\n", interfaceName, interfaceName); printf(" %s();\n", interfaceName); printf("\n"); printf(" virtual ~%s();\n", interfaceName); printf("\n"); - printf(" void init(struct ::wl_registry *registry, int id);\n"); + printf(" void init(struct ::wl_registry *registry, int id, int version);\n"); printf(" void init(struct ::%s *object);\n", interfaceName); printf("\n"); printf(" struct ::%s *object() { return m_%s; }\n", interfaceName, interfaceName); @@ -908,9 +908,9 @@ void process(QXmlStreamReader &xml, const QByteArray &headerPath, const QByteArr bool hasEvents = !interface.events.isEmpty(); - printf(" %s::%s(struct ::wl_registry *registry, int id)\n", interfaceName, interfaceName); + printf(" %s::%s(struct ::wl_registry *registry, int id, int version)\n", interfaceName, interfaceName); printf(" {\n"); - printf(" init(registry, id);\n"); + printf(" init(registry, id, version);\n"); printf(" }\n"); printf("\n"); @@ -933,9 +933,9 @@ void process(QXmlStreamReader &xml, const QByteArray &headerPath, const QByteArr printf(" }\n"); printf("\n"); - printf(" void %s::init(struct ::wl_registry *registry, int id)\n", interfaceName); + printf(" void %s::init(struct ::wl_registry *registry, int id, int version)\n", interfaceName); printf(" {\n"); - printf(" m_%s = static_cast(wl_registry_bind(registry, id, &%s_interface, %s_interface.version));\n", interfaceName, interfaceName, interfaceName, interfaceName); + printf(" m_%s = static_cast(wl_registry_bind(registry, id, &%s_interface, version));\n", interfaceName, interfaceName, interfaceName); if (hasEvents) printf(" init_listener();\n"); printf(" }\n"); -- cgit v1.2.1