diff options
author | Alexander Larsson <alexl@redhat.com> | 2006-11-06 17:16:37 +0000 |
---|---|---|
committer | Alexander Larsson <alexl@src.gnome.org> | 2006-11-06 17:16:37 +0000 |
commit | 853f5e5fc2847a9fca0227098d5d72f1811117c9 (patch) | |
tree | d531f18ec44075927385ebcc5a167509e58830cc /gtk/gtkdnd.c | |
parent | 7e736986f54560e1c6f0239a28bd4c605b3eb2a0 (diff) | |
download | gtk+-853f5e5fc2847a9fca0227098d5d72f1811117c9.tar.gz |
Cancel drag when the grab is shadowed. (#122688)
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)
Diffstat (limited to 'gtk/gtkdnd.c')
-rw-r--r-- | gtk/gtkdnd.c | 29 |
1 files changed, 29 insertions, 0 deletions
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. |