app: Avoid double gtk_drag_finish() call on GimpToolbox

According to the ::drag-drop GTK documentation: "The call to gtk_drag_finish()
can be done either directly or in a “drag-data-received” handler which gets
triggered by calling gtk_drag_get_data()"

The GimpToolbox's vbox handling DnD chooses however to do both, the drag-drop
handler is calling gtk_drag_get_data() and invariably calling gtk_drag_finish()
to hint that the DnD operation is ending. While this worked in practice in X11,
This is a harder either/or in Wayland resulting in the transfer being cancelled.

In order to behave better wrt the documentation, and make DnD into the toolbox
work on both X11 and Wayland, avoid the first gtk_drag_finish() if the data is
being requested, and only bail out if no offered target matches what the widget
can handle. The handling done indirectly through gimp_toolbox_dnd_init() and
gimp_dnd_*_dest_add() will take care of finalizing the DnD data transfers
successfully.

Closes: https://gitlab.gnome.org/GNOME/gimp/-/issues/7373
This commit is contained in:
Carlos Garnacho 2023-05-25 01:50:07 +02:00 committed by Michael Natterer
parent 310ab1f708
commit 467fa6c5e7
1 changed files with 8 additions and 6 deletions

View File

@ -449,13 +449,15 @@ gimp_toolbox_drag_drop (GtkWidget *widget,
gtk_drag_get_data (widget, context, target, time);
dropped = TRUE;
}
else
{
gtk_drag_finish (context, FALSE,
gdk_drag_context_get_selected_action (context) ==
GDK_ACTION_MOVE,
time);
}
gtk_drag_finish (context, dropped,
gdk_drag_context_get_selected_action (context) ==
GDK_ACTION_MOVE,
time);
return TRUE;
return dropped;
}
static gchar *