Skip to content

Commit

Permalink
audgui: Make drag and drop work on Wayland. Closes: audacious-media-p…
Browse files Browse the repository at this point in the history
…layer#1423

Calling both gtk_drag_get_data() and gtk_drag_finish()
leads to drag and drop not working on Wayland and this error:
"error reading selection buffer: Operation was cancelled"

See also: https://gitlab.gnome.org/GNOME/gimp/-/merge_requests/927
  • Loading branch information
radioactiveman committed Jul 8, 2024
1 parent 465c12c commit f628066
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/libaudgui/list.cc
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ static gboolean drag_drop (GtkWidget * widget, GdkDragContext * context, int x,
g_signal_stop_emission_by_name (widget, "drag-drop");

gboolean success = true;
bool finish_drag = true;
int row = audgui_list_row_at_point_rounded (widget, x, y);

if (model->dragging && MODEL_HAS_CB (model, shift_rows))
Expand All @@ -504,11 +505,16 @@ static gboolean drag_drop (GtkWidget * widget, GdkDragContext * context, int x,
model->receive_row = row;
gtk_drag_get_data (widget, context, gdk_atom_intern
(model->cbs->data_type, false), time);

/* avoid calling both gtk_drag_get_data() and gtk_drag_finish()
* to keep drag and drop working on Wayland */
finish_drag = false;
}
else
success = false;

gtk_drag_finish (context, success, false, time);
if (finish_drag)
gtk_drag_finish (context, success, false, time);
gtk_tree_view_set_drag_dest_row ((GtkTreeView *) widget, nullptr, (GtkTreeViewDropPosition) 0);
stop_autoscroll (model, widget);
return true;
Expand Down

0 comments on commit f628066

Please sign in to comment.