diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | gtk/gtkdnd.c | 29 |
2 files changed, 36 insertions, 0 deletions
@@ -1,3 +1,10 @@ +2006-11-06 Alexander Larsson <alexl@redhat.com> + + * gtk/gtkdnd.c: (gtk_drag_begin_internal), + (gtk_drag_source_info_destroy), (gtk_drag_end), + (gtk_drag_grab_notify_cb): + Cancel drag when the grab is shadowed. (#122688) + 2006-11-01 Kristian Rietveld <kris@imendio.com> * gtk/gtkcombobox.c (gtk_combo_box_class_init), diff --git a/gtk/gtkdnd.c b/gtk/gtkdnd.c index eaa95ddc69..3ebfd9c0b7 100644 --- a/gtk/gtkdnd.c +++ b/gtk/gtkdnd.c @@ -285,6 +285,9 @@ static gboolean gtk_drag_key_cb (GtkWidget *widget, static gboolean gtk_drag_grab_broken_event_cb (GtkWidget *widget, GdkEventGrabBroken *event, gpointer data); +static void gtk_drag_grab_notify_cb (GtkWidget *widget, + gboolean was_grabbed, + gpointer data); static gboolean gtk_drag_button_release_cb (GtkWidget *widget, GdkEventButton *event, gpointer data); @@ -2331,6 +2334,8 @@ gtk_drag_begin_internal (GtkWidget *widget, g_signal_connect (info->ipc_widget, "grab_broken_event", G_CALLBACK (gtk_drag_grab_broken_event_cb), info); + g_signal_connect (info->ipc_widget, "grab_notify", + G_CALLBACK (gtk_drag_grab_notify_cb), info); g_signal_connect (info->ipc_widget, "button_release_event", G_CALLBACK (gtk_drag_button_release_cb), info); g_signal_connect (info->ipc_widget, "motion_notify_event", @@ -3762,6 +3767,9 @@ gtk_drag_source_info_destroy (GtkDragSourceInfo *info) gtk_drag_grab_broken_event_cb, info); g_signal_handlers_disconnect_by_func (info->ipc_widget, + gtk_drag_grab_notify_cb, + info); + g_signal_handlers_disconnect_by_func (info->ipc_widget, gtk_drag_button_release_cb, info); g_signal_handlers_disconnect_by_func (info->ipc_widget, @@ -3926,6 +3934,9 @@ gtk_drag_end (GtkDragSourceInfo *info, guint32 time) gtk_drag_grab_broken_event_cb, info); g_signal_handlers_disconnect_by_func (info->ipc_widget, + gtk_drag_grab_notify_cb, + info); + g_signal_handlers_disconnect_by_func (info->ipc_widget, gtk_drag_button_release_cb, info); g_signal_handlers_disconnect_by_func (info->ipc_widget, @@ -4117,6 +4128,24 @@ gtk_drag_grab_broken_event_cb (GtkWidget *widget, return TRUE; } +static void +gtk_drag_grab_notify_cb (GtkWidget *widget, + gboolean was_grabbed, + gpointer data) +{ + GtkDragSourceInfo *info = (GtkDragSourceInfo *)data; + + if (!was_grabbed) + { + /* We have to block callbacks to avoid recursion here, because + gtk_drag_cancel calls gtk_grab_remove (via gtk_drag_end) */ + g_signal_handlers_block_by_func (widget, gtk_drag_grab_notify_cb, data); + gtk_drag_cancel (info, gtk_get_current_event_time ()); + g_signal_handlers_unblock_by_func (widget, gtk_drag_grab_notify_cb, data); + } +} + + /************************************************************* * gtk_drag_button_release_cb: * "button_release_event" callback during drag. |