Handle really global selection offers in wayland clipboard.

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 <qt_sanity_bot@ovi.com>
Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
bb10
Laszlo Agocs 2011-06-10 11:59:01 +02:00 committed by Qt Continuous Integration System
parent fc74b4e564
commit bdda694e86
2 changed files with 21 additions and 4 deletions

View File

@ -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>("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>("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<QWaylandClipboard *>(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<QWaylandClipboard *>(plat->clipboard());
clipboard->createSelectionOffer(id);
}
void QWaylandDisplay::handleVisual(void *data,
struct wl_compositor *compositor,
uint32_t id, uint32_t token)

View File

@ -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;