Commit b219b917 authored by David Edmundson's avatar David Edmundson Committed by Vlad Zahorodnii
Browse files

Only guard DND cancel events with the version check

In a recent refactor a guard seemingly in the wrong place on
SeatInterface was moved into AbstractDataSource, as typically that's
where we guard.

However it turns out the original code was correct, we want to send
cancel for all clipboard cancels, but for D&D it's version dependent.

This class introduces a new method to astract that from seat.
parent cd512fee
......@@ -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;
......
......@@ -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;
......
......@@ -41,6 +41,7 @@ public:
void dropPerformed() override;
void dndFinished() override;
void dndAction(DataDeviceManagerInterface::DnDAction action) override;
void dndCancelled() override;
wl_resource *resource() const;
......
......@@ -293,7 +293,7 @@ void SeatInterfacePrivate::endDrag(quint32 serial)
dragTargetDevice->drop();
dragSource->dropPerformed();
} else {
dragSource->cancel();
dragSource->dndCancelled();
}
}
......
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