From 7fb846e5f2fff72fbb16d27e8e6904ed67b311dc Mon Sep 17 00:00:00 2001 From: Giulio Camuffo Date: Thu, 24 Apr 2014 13:59:39 +0300 Subject: [PATCH] Discard the selection and drag source when not active anymore If another client sets a selection or starts a drag the active wl_data_source, if any, gets a 'cancelled' event. We must listen to this and discard the wl_data_source, else e.g. checking the clipboard content will still return the data of the source instead of the current wl_data_offer. Change-Id: I80b202baf95fbc8abe19496a991cb30bc0b78bb0 Reviewed-by: Gunnar Sletta Reviewed-by: Robin Burchell --- src/plugins/platforms/wayland/qwaylanddatadevice.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/wayland/qwaylanddatadevice.cpp b/src/plugins/platforms/wayland/qwaylanddatadevice.cpp index 2d6a6f4b6cf..f5056f6d05f 100644 --- a/src/plugins/platforms/wayland/qwaylanddatadevice.cpp +++ b/src/plugins/platforms/wayland/qwaylanddatadevice.cpp @@ -84,6 +84,8 @@ QWaylandDataSource *QWaylandDataDevice::selectionSource() const void QWaylandDataDevice::setSelectionSource(QWaylandDataSource *source) { m_selectionSource.reset(source); + if (source) + connect(source, &QWaylandDataSource::cancelled, this, &QWaylandDataDevice::selectionSourceCancelled); set_selection(source ? source->object() : 0, 0 /* TODO m_display->serial() */); } @@ -95,7 +97,7 @@ QWaylandDataOffer *QWaylandDataDevice::dragOffer() const void QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon) { m_dragSource.reset(new QWaylandDataSource(m_display->dndSelectionHandler(), mimeData)); - + connect(m_dragSource.data(), &QWaylandDataSource::cancelled, this, &QWaylandDataDevice::dragSourceCancelled); QWaylandWindow *origin = m_display->currentInputDevice()->pointerFocus(); start_drag(m_dragSource->object(), origin->object(), icon->object(), m_display->currentInputDevice()->serial());