summaryrefslogtreecommitdiff
path: root/gtk/gtkdnd.c
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2002-10-03 20:53:30 +0000
committerOwen Taylor <otaylor@src.gnome.org>2002-10-03 20:53:30 +0000
commitef33adff83617e2c937052316b9fb925d4972252 (patch)
treec6badff88c8dca205f9013043ab12c7f68db5903 /gtk/gtkdnd.c
parent6cb79658c2a64d01f6e488f065eb2d265be97414 (diff)
downloadgtk+-ef33adff83617e2c937052316b9fb925d4972252.tar.gz
Add a 'type' parameter, make public.
Thu Oct 3 14:13:33 2002 Owen Taylor <otaylor@redhat.com> * gdk/gdkevents.c (gdk_event_new): Add a 'type' parameter, make public. * gdk/gdkevents.c (gdk_event_copy): Copy the screen. * gdk/gdkevents.c gdk/linux-fb/gdkmain-fb.c gdk/x11/gdkevents-x11.c gdk/win32/gdkevents-win32.c: _gdk_event_new() => gdk_event_new(). * gdk/win32/gdkevents-win32.c (real_window_procedure): Fix event_private->screen breakage that results from evil encapsulation breakage here. * gtk/gtkclist.c gtk/gtkcombo.c gtk/gtkcontainer.c gtk/gtkdialog.c gtk/gtkdnd.c gtk/gtkdrawingarea.c gtk/gtkimcontextsimple.c gtk/gtklist.c gtk/gtkmenu.c gtk/gtknotebook.c gtk/gtkplug.c gtk/gtkselection.c gtk/gtktext.c gtk/gtktreeitem.c gtk/gtktreeview.c gtk/gtkviewport.c gtk/gtkwindow-decorate.c gtk/gtkwindow.c tests/testgtk.c: Remove most usage of stack-allocated GdkEvent structures. * gtk/gtktreeview.c: Use a cut-and-paste of the full send_focus_event() from gtkwindow.c that does the necessary notification of the ::has-focus property and setting of the HAS_FOCUS flag.x * gtk/gtkdnd.c: Clean up some mess/duplicated code; removing an extraneous use of a GdkEvent.
Diffstat (limited to 'gtk/gtkdnd.c')
-rw-r--r--gtk/gtkdnd.c73
1 files changed, 41 insertions, 32 deletions
diff --git a/gtk/gtkdnd.c b/gtk/gtkdnd.c
index 2dc5daddff..d6a80a6822 100644
--- a/gtk/gtkdnd.c
+++ b/gtk/gtkdnd.c
@@ -234,6 +234,8 @@ static void gtk_drag_drop (GtkDragSourceInfo *info,
static void gtk_drag_drop_finished (GtkDragSourceInfo *info,
gboolean success,
guint time);
+static void gtk_drag_cancel (GtkDragSourceInfo *info,
+ guint32 time);
static gint gtk_drag_source_event_cb (GtkWidget *widget,
GdkEvent *event,
@@ -1886,15 +1888,7 @@ gtk_drag_begin (GtkWidget *widget,
{
if (gdk_keyboard_grab (info->ipc_widget->window, FALSE, time) != 0)
{
- /* FIXME: This should be cleaned up... */
- GdkEventButton ev;
-
- ev.time = time;
- ev.type = GDK_BUTTON_RELEASE;
- ev.button = info->button;
-
- gtk_drag_button_release_cb (widget, &ev, info);
-
+ gtk_drag_cancel (info, time);
return NULL;
}
}
@@ -3015,15 +3009,15 @@ gtk_drag_update (GtkDragSourceInfo *info,
* Called when the user finishes to drag, either by
* releasing the mouse, or by pressing Esc.
* arguments:
- * widget: GtkInvisible widget for this drag
- * info:
+ * info: Source info for the drag
+ * time: Timestamp for ending the drag
* results:
*************************************************************/
static void
gtk_drag_end (GtkDragSourceInfo *info, guint32 time)
{
- GdkEvent send_event;
+ GdkEvent *send_event;
GtkWidget *source_widget = info->widget;
GdkDisplay *display = gtk_widget_get_display (source_widget);
@@ -3050,20 +3044,39 @@ gtk_drag_end (GtkDragSourceInfo *info, guint32 time)
* expect propagation.
*/
- send_event.button.type = GDK_BUTTON_RELEASE;
- send_event.button.window = gtk_widget_get_root_window (source_widget);
- send_event.button.send_event = TRUE;
- send_event.button.time = time;
- send_event.button.x = 0;
- send_event.button.y = 0;
- send_event.button.axes = NULL;
- send_event.button.state = 0;
- send_event.button.button = info->button;
- send_event.button.device = gdk_display_get_core_pointer (display);
- send_event.button.x_root = 0;
- send_event.button.y_root = 0;
+ send_event = gdk_event_new (GDK_BUTTON_RELEASE);
+ send_event->button.window = g_object_ref (gtk_widget_get_root_window (source_widget));
+ send_event->button.send_event = TRUE;
+ send_event->button.time = time;
+ send_event->button.x = 0;
+ send_event->button.y = 0;
+ send_event->button.axes = NULL;
+ send_event->button.state = 0;
+ send_event->button.button = info->button;
+ send_event->button.device = gdk_display_get_core_pointer (display);
+ send_event->button.x_root = 0;
+ send_event->button.y_root = 0;
- gtk_propagate_event (source_widget, &send_event);
+ gtk_propagate_event (source_widget, send_event);
+ gdk_event_free (send_event);
+}
+
+/*************************************************************
+ * gtk_drag_cancel:
+ * Called on cancellation of a drag, either by the user
+ * or programmatically.
+ * arguments:
+ * info: Source info for the drag
+ * time: Timestamp for ending the drag
+ * results:
+ *************************************************************/
+
+static void
+gtk_drag_cancel (GtkDragSourceInfo *info, guint32 time)
+{
+ gtk_drag_end (info, time);
+ gdk_drag_abort (info->context, time);
+ gtk_drag_drop_finished (info, FALSE, time);
}
/*************************************************************
@@ -3117,9 +3130,7 @@ gtk_drag_key_cb (GtkWidget *widget,
{
if (event->keyval == GDK_Escape)
{
- gtk_drag_end (info, event->time);
- gdk_drag_abort (info->context, event->time);
- gtk_drag_drop_finished (info, FALSE, event->time);
+ gtk_drag_cancel (info, event->time);
return TRUE;
}
@@ -3158,16 +3169,14 @@ gtk_drag_button_release_cb (GtkWidget *widget,
if (event->button != info->button)
return FALSE;
- gtk_drag_end (info, event->time);
-
if ((info->context->action != 0) && (info->context->dest_window != NULL))
{
+ gtk_drag_end (info, event->time);
gtk_drag_drop (info, event->time);
}
else
{
- gdk_drag_abort (info->context, event->time);
- gtk_drag_drop_finished (info, FALSE, event->time);
+ gtk_drag_cancel (info, event->time);
}
return TRUE;