From ce3c975ab1804c6ad2a10cca0de3096368eccf1e Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Fri, 11 May 2012 14:18:15 +0300 Subject: [PATCH] Remove unnecessary display_sync and use the safer pattern in xcomposite MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit and QWaylandDataOffer. No more annoying "server sent delete_id for live object" messages. Change-Id: Ibc3736cd752bf52823a0ae0ea536c9faf5663987 Reviewed-by: Jørgen Lind --- .../xcomposite_glx/qwaylandxcompositeglxwindow.cpp | 24 +++++++++++----------- .../xcomposite_glx/qwaylandxcompositeglxwindow.h | 2 +- .../platforms/wayland/qwaylanddataoffer.cpp | 20 +++++++++--------- src/plugins/platforms/wayland/qwaylanddataoffer.h | 3 ++- 4 files changed, 25 insertions(+), 24 deletions(-) diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp index 58a8761..e607f76 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp @@ -49,14 +49,13 @@ #include - QWaylandXCompositeGLXWindow::QWaylandXCompositeGLXWindow(QWindow *window, QWaylandXCompositeGLXIntegration *glxIntegration) : QWaylandWindow(window) , m_glxIntegration(glxIntegration) , m_xWindow(0) , m_config(qglx_findConfig(glxIntegration->xDisplay(), glxIntegration->screen(), window->format(), GLX_WINDOW_BIT | GLX_PIXMAP_BIT)) , m_buffer(0) - , m_waitingForSync(false) + , m_syncCallback(0) { } @@ -88,13 +87,13 @@ Window QWaylandXCompositeGLXWindow::xWindow() const void QWaylandXCompositeGLXWindow::waitForSync() { - struct wl_display *dpy = m_glxIntegration->waylandDisplay()->wl_display(); - wl_callback *sync_callback = wl_display_sync(dpy); - wl_callback_add_listener(sync_callback, &sync_callback_listener, this); - m_waitingForSync = true; - wl_display_sync(dpy); + if (!m_syncCallback) { + struct wl_display *dpy = m_glxIntegration->waylandDisplay()->wl_display(); + m_syncCallback = wl_display_sync(dpy); + wl_callback_add_listener(m_syncCallback, &sync_callback_listener, this); + } m_glxIntegration->waylandDisplay()->flushRequests(); - while (m_waitingForSync) + while (m_syncCallback) m_glxIntegration->waylandDisplay()->readEvents(); } @@ -138,11 +137,12 @@ void QWaylandXCompositeGLXWindow::createSurface() waitForSync(); } -void QWaylandXCompositeGLXWindow::sync_function(void *data, struct wl_callback *wl_callback, uint32_t time) +void QWaylandXCompositeGLXWindow::sync_function(void *data, struct wl_callback *callback, uint32_t time) { Q_UNUSED(time); QWaylandXCompositeGLXWindow *that = static_cast(data); - that->m_waitingForSync = false; - wl_callback_destroy(wl_callback); + if (that->m_syncCallback != callback) + return; + that->m_syncCallback = 0; + wl_callback_destroy(callback); } - diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.h index f7c1b3c..ec5dff3 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.h +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.h @@ -71,7 +71,7 @@ private: QWaylandBuffer *m_buffer; void waitForSync(); - bool m_waitingForSync; + wl_callback *m_syncCallback; static const struct wl_callback_listener sync_callback_listener; static void sync_function(void *data, struct wl_callback *wl_callback, uint32_t time); diff --git a/src/plugins/platforms/wayland/qwaylanddataoffer.cpp b/src/plugins/platforms/wayland/qwaylanddataoffer.cpp index 9229719..beb393b 100644 --- a/src/plugins/platforms/wayland/qwaylanddataoffer.cpp +++ b/src/plugins/platforms/wayland/qwaylanddataoffer.cpp @@ -49,14 +49,15 @@ void QWaylandDataOffer::offer_sync_callback(void *data, - struct wl_callback *wl_callback, + struct wl_callback *callback, uint32_t time) { Q_UNUSED(time); - QWaylandDataOffer *mime = static_cast(data); - mime->m_receiving_offers = false; - wl_callback_destroy(wl_callback); + if (mime->m_receiveSyncCallback == callback) { + mime->m_receiveSyncCallback = 0; + wl_callback_destroy(callback); + } } const struct wl_callback_listener QWaylandDataOffer::offer_sync_callback_listener = { @@ -71,14 +72,13 @@ void QWaylandDataOffer::offer(void *data, QWaylandDataOffer *data_offer = static_cast(data); - if (!data_offer->m_receiving_offers) { - struct wl_callback *callback = wl_display_sync(data_offer->m_display->wl_display()); - wl_callback_add_listener(callback,&offer_sync_callback_listener,data_offer); - data_offer->m_receiving_offers = true; + if (!data_offer->m_receiveSyncCallback) { + data_offer->m_receiveSyncCallback = wl_display_sync(data_offer->m_display->wl_display()); + wl_callback_add_listener(data_offer->m_receiveSyncCallback, &offer_sync_callback_listener, data_offer); } data_offer->m_offered_mime_types.append(QString::fromLocal8Bit(type)); - qDebug() << data_offer->m_offered_mime_types; +// qDebug() << data_offer->m_offered_mime_types; } const struct wl_data_offer_listener QWaylandDataOffer::data_offer_listener = { @@ -87,7 +87,7 @@ const struct wl_data_offer_listener QWaylandDataOffer::data_offer_listener = { QWaylandDataOffer::QWaylandDataOffer(QWaylandDisplay *display, struct wl_data_offer *data_offer) : m_display(display) - , m_receiving_offers(false) + , m_receiveSyncCallback(0) { m_data_offer = data_offer; wl_data_offer_set_user_data(m_data_offer,this); diff --git a/src/plugins/platforms/wayland/qwaylanddataoffer.h b/src/plugins/platforms/wayland/qwaylanddataoffer.h index c975c6c..3cb7ce0 100644 --- a/src/plugins/platforms/wayland/qwaylanddataoffer.h +++ b/src/plugins/platforms/wayland/qwaylanddataoffer.h @@ -52,6 +52,7 @@ #include class QWaylandDisplay; +struct wl_callback; class QWaylandDataOffer : public QInternalMimeData { @@ -69,7 +70,7 @@ private: struct wl_data_offer *m_data_offer; QWaylandDisplay *m_display; QStringList m_offered_mime_types; - bool m_receiving_offers; + wl_callback *m_receiveSyncCallback; static void offer(void *data, struct wl_data_offer *wl_data_offer, const char *type); static const struct wl_data_offer_listener data_offer_listener; -- 2.7.4