From bdda694e86a791b76a5acee0712f5e470700542d Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Fri, 10 Jun 2011 11:59:01 +0200 Subject: Handle really global selection offers in wayland clipboard. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Handle selection offer globals properly even if they arrive during the initial blocking read. If such a global arrives so early, the platform integration is not yet available from QApplicationPrivate (as it is just being constructed). Therefore the handling of the selection offer has to be delayed. At the moment selection offers are typically posted as globals and not added to the global list, but that is likely to change in the future. Change-Id: Ib4ae804ad7f19e05978ee08828b88e028a3bf7b2 Reviewed-on: http://codereview.qt.nokia.com/446 Reviewed-by: Qt Sanity Bot Reviewed-by: Jørgen Lind --- src/plugins/platforms/wayland/qwaylanddisplay.cpp | 21 +++++++++++++++++---- src/plugins/platforms/wayland/qwaylanddisplay.h | 4 ++++ 2 files changed, 21 insertions(+), 4 deletions(-) (limited to 'src/plugins/platforms/wayland') diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.cpp b/src/plugins/platforms/wayland/qwaylanddisplay.cpp index 83516e9b4e..e6d39683fe 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.cpp +++ b/src/plugins/platforms/wayland/qwaylanddisplay.cpp @@ -129,6 +129,8 @@ const struct wl_shell_listener QWaylandDisplay::shellListener = { QWaylandDisplay::QWaylandDisplay(void) : argb_visual(0), premultiplied_argb_visual(0), rgb_visual(0) { + qRegisterMetaType("uint32_t"); + mDisplay = wl_display_connect(NULL); if (mDisplay == NULL) { qErrnoWarning(errno, "Failed to create display"); @@ -147,8 +149,6 @@ QWaylandDisplay::QWaylandDisplay(void) blockingReadEvents(); - qRegisterMetaType("uint32_t"); - #ifdef QT_WAYLAND_GL_SUPPORT mEglIntegration->initialize(); #endif @@ -291,11 +291,24 @@ void QWaylandDisplay::displayHandleGlobal(uint32_t id, mInputDevices.append(inputDevice); } else if (interface == "wl_selection_offer") { QPlatformIntegration *plat = QApplicationPrivate::platformIntegration(); - QWaylandClipboard *clipboard = static_cast(plat->clipboard()); - clipboard->createSelectionOffer(id); + mSelectionOfferId = id; + if (plat) + handleSelectionOffer(id); + else + QMetaObject::invokeMethod(this, "handleSelectionOffer", + Qt::QueuedConnection, Q_ARG(uint32_t, id)); } } +void QWaylandDisplay::handleSelectionOffer(uint32_t id) +{ + if (mSelectionOfferId != id) + return; + QPlatformIntegration *plat = QApplicationPrivate::platformIntegration(); + QWaylandClipboard *clipboard = static_cast(plat->clipboard()); + clipboard->createSelectionOffer(id); +} + void QWaylandDisplay::handleVisual(void *data, struct wl_compositor *compositor, uint32_t id, uint32_t token) diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.h b/src/plugins/platforms/wayland/qwaylanddisplay.h index 765be62eb4..ff8c760557 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.h +++ b/src/plugins/platforms/wayland/qwaylanddisplay.h @@ -97,6 +97,9 @@ public slots: void blockingReadEvents(); void flushRequests(); +private slots: + void handleSelectionOffer(uint32_t id); + private: void waitForScreens(); void displayHandleGlobal(uint32_t id, @@ -115,6 +118,7 @@ private: bool mScreensInitialized; uint32_t mSocketMask; + uint32_t mSelectionOfferId; struct wl_visual *argb_visual, *premultiplied_argb_visual, *rgb_visual; -- cgit v1.2.3