wl_data_source::cancelled events are not sent when DnD drop is performed in overview mode
Affected version
I'm using GNOME Shell 40.5 on Arch Linux 5.14.14.
Bug summary
When starting a DnD session in an application and releasing the mouse in overview mode, either only a wl_data_source::leave event is sent (if no leave event has occurred since the last enter event), or a wl_data_source::dnd_finished event is sent instead of wl_data_source::cancelled.
Steps to reproduce
I discovered this bug while working on Chromium's tab dragging, which gave me more detailed feedback about the specific wayland events. But it is easier to reproduce this using weston-dnd
. I'll also detail my findings from Chromium.
- Run
weston-dnd
- Start dragging one of the displayed symbols, do not drag out of
weston-dnd
's window - Enter overview mode (e.g. by pressing the Super key), do not release mouse yet
- Release mouse while in overview mode
What happened
The drag session did not end correctly: the drag icon is gone, but weston-dnd
shows a greyed out version of the dragged symbol as if the drag was still underway.
Debugging the same scenario in Chromium (starting a drag session, not leaving the surface, and releasing the mouse in overview mode) yielded the following series of events:
- wl_data_source::target
- wl_data_device::offer
- wl_data_source::offer
- wl_data_source::action
- wl_data_source::action
- wl_data_source::source_actions
- wl_data_device::enter
- wl_data_source::action
- wl_data_source::action
- wl_data_source::target
- wl_data_device::leave
When I left the surface before entering overview mode and then released the mouse, these were the emitted events:
- wl_data_source::target
- wl_data_device::offer
- wl_data_source::offer
- wl_data_source::action
- wl_data_source::action
- wl_data_source::source_actions
- wl_data_device::enter
- wl_data_source::action
- wl_data_source::action
- wl_data_source::target
- wl_data_device::leave
- wl_data_source::target
- wl_data_source::action
- wl_data_source::target
- wl_data_source::dnd_finished
What did you expect to happen
The drag session should have ended by means of a wl_data_source::cancelled event. For example, here is a series of events from Chromium when dragging out of the surface and releasing the mouse:
- wl_data_source::target
- wl_data_device::offer
- wl_data_source::offer
- wl_data_source::action
- wl_data_source::action
- wl_data_source::source_actions
- wl_data_device::enter
- wl_data_source::action
- wl_data_source::action
- wl_data_source::target
- wl_data_device::leave
- wl_data_source::target
- wl_data_source::action
- wl_data_source::target
- wl_data_source::cancelled
Relevant section of the Wayland protocol specification
The Wayland specification lists
The drag-and-drop operation was performed, but the drop destination did not accept any of the mime types offered through wl_data_source.target.
as one of the reasons for emitting the wl_data_source::cancelled event.
wl_data_source::dnd_finished is described as
The drop destination finished interoperating with this data source, so the client is now free to destroy this data source and free all associated data. [...]
which seems kind of fitting, but in my opinion definitely less fitting than the wl_data_source::cancelled event.