X11 drag-and-drop failure not communicated to source, unlike Wayland
Steps to reproduce
- Ensure you are using X11 backend and not Wayland
- Open gtk4-demo and select "Peg Solitaire"
- Drag one of the "peg" squares either away from and then back to its original spot, or drag it to a position that is not a legal move (e.g. drag a peg adjacent to the center into the center).
- Observe that the peg disappears, contrary to the game logic.
- Repeat under Wayland (if available) to observe how it's supposed to work.
Current behavior
The peg disappears under X11 because the "drop" signal is called in the GtkDragSource with parameter delete_data
true, in spite of the fact that the "drop" signal in the GtkDropTarget returned a false result.
Expected outcome
Since this is supposed to be a "move"-type operation, then surely it is a dangerous condition for delete_data
to be true when the destination of the drop actually failed. Clearly the logic of the demo is not expecting the X11 behavior here.
Version information
Tested by me on Gtk 4.10.3 on FreeBSD 13.2-stable (built from FreeBSD ports) and (by other people) on various Linux distributions (sorry, I don't have exact details). Everyone who has tested this for me has reported that the demo works on Wayland and misbehaves on X11, regardless of distro.
Additional information
My analysis of the issue is:
At the gtk level, the gtkdragsource emits the "drag-end" signal with delete_data == true if it gets the "dnd-finished" signal from gdk, and the x11 and wayland versions have completely different logic over whether/when they emit that signal.
X11 emits it in gdk_x11_drag_handle_finished regardless of whether the drop failed or succeeded, wayland emits it in response to a "finished" call on the data source.
If the drop target rejects the drop before the "drop" signal, then the _finished
method is not called so the drag source doesn't see a successful drop. But this demo is checking for legal/illegal moves inside the "drop" signal and relying on a true/false return being communicated back to the drag source to keep the game state consistent.