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 <gunnar.sletta@jollamobile.com>
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
This commit is contained in:
Giulio Camuffo 2014-04-24 13:59:39 +03:00 committed by The Qt Project
parent def782f1a4
commit 7fb846e5f2

View File

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