From bc6eba61147815c44dcb7838e204b5552a7b561d Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Fri, 4 Jun 2021 13:03:28 +0100 Subject: [PATCH] [xwl] Create a new datasource on offer changes Offers shoul be set on a source before data_device.set_selection. Doing so afterwards appears to be against the spec and as such we may not pass the update to wayland clients / klipper. --- src/xwl/clipboard.cpp | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/src/xwl/clipboard.cpp b/src/xwl/clipboard.cpp index e1b1e9698e..b9572ccde9 100644 --- a/src/xwl/clipboard.cpp +++ b/src/xwl/clipboard.cpp @@ -167,22 +167,16 @@ void Clipboard::x11OffersChanged(const QStringList &added, const QStringList &re const Mimes offers = source->offers(); if (!offers.isEmpty()) { - if (!source->dataSource() || !removed.isEmpty()) { - // create new Wl DataSource if there is none or when types - // were removed (Wl Data Sources can only add types) - KWayland::Client::DataDeviceManager *dataDeviceManager = - waylandServer()->internalDataDeviceManager(); - KWayland::Client::DataSource *dataSource = - dataDeviceManager->createDataSource(source); + // create new Wl DataSource if there is none or when types + // were removed (Wl Data Sources can only add types) + KWayland::Client::DataDeviceManager *dataDeviceManager = + waylandServer()->internalDataDeviceManager(); + KWayland::Client::DataSource *dataSource = + dataDeviceManager->createDataSource(source); - // also offers directly the currently available types - source->setDataSource(dataSource); - DataBridge::self()->dataDevice()->setSelection(0, dataSource); - } else if (auto *dataSource = source->dataSource()) { - for (const QString &mime : added) { - dataSource->offer(mime); - } - } + // also offers directly the currently available types + source->setDataSource(dataSource); + DataBridge::self()->dataDevice()->setSelection(0, dataSource); } else { KWaylandServer::AbstractDataSource *currentSelection = waylandServer()->seat()->selection(); if (!ownsSelection(currentSelection)) {