Commit 0e580ae9 authored by Michal Srb's avatar Michal Srb Committed by Fabian Vogt
Browse files

Do not cancel old clipboard selection if it is same as the new one.

Summary:
GTK applications seem to call wl_data_device::set_selection multiple times with
the same wl_data_source object, replacing it with itself. If we cancel it, they
will destroy it and the selection will be gone.

With this patch it is again possible to copy from GTK applications.

BUG: 395366

Test Plan: Patch provided by the reporter, he reported success.

Reviewers: #plasma, #frameworks, romangg

Reviewed By: #plasma, romangg

Subscribers: michalsrb, romangg, graesslin, kde-frameworks-devel

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D13535
parent 7b9932e7
......@@ -512,6 +512,12 @@ void TestDataDevice::testReplaceSource()
QCOMPARE(selectionOfferedSpy.count(), 2);
QVERIFY(sourceCancelled2Spy.isEmpty());
// replace the data source with itself, ensure that it did not get cancelled
dataDevice->setSelection(1, dataSource2.data());
QVERIFY(!sourceCancelled2Spy.wait(500));
QCOMPARE(selectionOfferedSpy.count(), 2);
QVERIFY(sourceCancelled2Spy.isEmpty());
// create a new DataDevice and replace previous one
QScopedPointer<DataDevice> dataDevice2(m_dataDeviceManager->getDataDevice(m_seat));
QVERIFY(dataDevice2->isValid());
......
......@@ -130,6 +130,9 @@ void DataDeviceInterface::Private::setSelection(DataSourceInterface *dataSource)
wl_resource_post_error(dataSource->resource(), WL_DATA_SOURCE_ERROR_INVALID_SOURCE, "Data source is for drag and drop");
return;
}
if (selection == dataSource) {
return;
}
Q_Q(DataDeviceInterface);
QObject::disconnect(selectionUnboundConnection);
QObject::disconnect(selectionDestroyedConnection);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment