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
This commit is contained in:
parent
b8381f3718
commit
d3f15a5388
2 changed files with 9 additions and 0 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue