diff --git a/src/wayland/abstract_data_source.h b/src/wayland/abstract_data_source.h index aea38acbb8..3688c8b75f 100644 --- a/src/wayland/abstract_data_source.h +++ b/src/wayland/abstract_data_source.h @@ -67,6 +67,13 @@ public: Q_UNUSED(action); }; + /** + * Called when a user stops clicking but it is not accepted by a client. + */ + virtual void dndCancelled() + { + } + virtual wl_client *client() const { return nullptr; diff --git a/src/wayland/datasource_interface.cpp b/src/wayland/datasource_interface.cpp index 417ee7d100..445765a064 100644 --- a/src/wayland/datasource_interface.cpp +++ b/src/wayland/datasource_interface.cpp @@ -118,9 +118,7 @@ void DataSourceInterface::requestData(const QString &mimeType, qint32 fd) void DataSourceInterface::cancel() { - if (wl_resource_get_version(resource()) >= WL_DATA_SOURCE_DND_FINISHED_SINCE_VERSION) { - d->send_cancelled(); - } + d->send_cancelled(); } QStringList DataSourceInterface::mimeTypes() const @@ -173,6 +171,15 @@ void DataSourceInterface::dndAction(DataDeviceManagerInterface::DnDAction action d->send_action(wlAction); } +void DataSourceInterface::dndCancelled() +{ + // for v3 or less, cancel should not be called after a failed drag operation + if (wl_resource_get_version(resource()) < 3) { + return; + } + d->send_cancelled(); +} + wl_resource *DataSourceInterface::resource() const { return d->resource()->handle; diff --git a/src/wayland/datasource_interface.h b/src/wayland/datasource_interface.h index 5db7d45bb1..f99971f7d4 100644 --- a/src/wayland/datasource_interface.h +++ b/src/wayland/datasource_interface.h @@ -41,6 +41,7 @@ public: void dropPerformed() override; void dndFinished() override; void dndAction(DataDeviceManagerInterface::DnDAction action) override; + void dndCancelled() override; wl_resource *resource() const; diff --git a/src/wayland/seat_interface.cpp b/src/wayland/seat_interface.cpp index e046c72e21..0f7579e7d0 100644 --- a/src/wayland/seat_interface.cpp +++ b/src/wayland/seat_interface.cpp @@ -293,7 +293,7 @@ void SeatInterfacePrivate::endDrag(quint32 serial) dragTargetDevice->drop(); dragSource->dropPerformed(); } else { - dragSource->cancel(); + dragSource->dndCancelled(); } }