From 6ac07a2e85ea8d53fc28455e46c2b0592607135b Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 26 Jul 2015 02:10:47 -0400 Subject: [PATCH] quartz: Implement NO_TARGET drag result This is necessary to make notebook tab DND work. https://bugzilla.gnome.org/show_bug.cgi?id=752638 --- gtk/gtkdnd-quartz.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/gtk/gtkdnd-quartz.c b/gtk/gtkdnd-quartz.c index 8bc5ef3027..68a47c409a 100644 --- a/gtk/gtkdnd-quartz.c +++ b/gtk/gtkdnd-quartz.c @@ -2054,14 +2054,23 @@ gtk_drag_source_info_destroy (GtkDragSourceInfo *info) static gboolean drag_drop_finished_idle_cb (gpointer data) { - gtk_drag_source_info_destroy (data); + GtkDragSourceInfo* info = (GtkDragSourceInfo*) data; + if (info->success) + gtk_drag_source_info_destroy (data); return G_SOURCE_REMOVE; } static void -gtk_drag_drop_finished (GtkDragSourceInfo *info) +gtk_drag_drop_finished (GtkDragSourceInfo *info, + GtkDragResult result) { - if (info->success && info->delete) + gboolean success = (result == GTK_DRAG_RESULT_SUCCESS); + + if (!success) + g_signal_emit_by_name (info->source_widget, "drag-failed", + info->context, GTK_DRAG_RESULT_NO_TARGET, &success); + + if (success && info->delete) g_signal_emit_by_name (info->source_widget, "drag-data-delete", info->context); @@ -2089,6 +2098,7 @@ _gtk_drag_source_handle_event (GtkWidget *widget, { GtkDragSourceInfo *info; GdkDragContext *context; + GtkDragResult result; g_return_if_fail (widget != NULL); g_return_if_fail (event != NULL); @@ -2101,7 +2111,8 @@ _gtk_drag_source_handle_event (GtkWidget *widget, switch (event->type) { case GDK_DROP_FINISHED: - gtk_drag_drop_finished (info); + result = (gdk_drag_context_get_dest_window (context) != NULL) ? GTK_DRAG_RESULT_SUCCESS : GTK_DRAG_RESULT_NO_TARGET; + gtk_drag_drop_finished (info, result); break; default: g_assert_not_reached ();