Commit ef33adff authored by Owen Taylor's avatar Owen Taylor Committed by Owen Taylor

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.
parent 6cb79658
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.
Wed Oct 2 17:46:53 2002 Owen Taylor <otaylor@redhat.com>
* gdk/gdkdrawable.h gdk/gdkinternals.h gdk/gdkdraw.c
......
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.
Wed Oct 2 17:46:53 2002 Owen Taylor <otaylor@redhat.com>
* gdk/gdkdrawable.h gdk/gdkinternals.h gdk/gdkdraw.c
......
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.
Wed Oct 2 17:46:53 2002 Owen Taylor <otaylor@redhat.com>
* gdk/gdkdrawable.h gdk/gdkinternals.h gdk/gdkdraw.c
......
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.
Wed Oct 2 17:46:53 2002 Owen Taylor <otaylor@redhat.com>
* gdk/gdkdrawable.h gdk/gdkinternals.h gdk/gdkdraw.c
......
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.
Wed Oct 2 17:46:53 2002 Owen Taylor <otaylor@redhat.com>
* gdk/gdkdrawable.h gdk/gdkinternals.h gdk/gdkdraw.c
......
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.
Wed Oct 2 17:46:53 2002 Owen Taylor <otaylor@redhat.com>
* gdk/gdkdrawable.h gdk/gdkinternals.h gdk/gdkdraw.c
......
......@@ -24,6 +24,8 @@
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#include <string.h> /* For memset() */
#include "gdk.h"
#include "gdkinternals.h"
......@@ -259,9 +261,10 @@ static GMemChunk *event_chunk = NULL;
static GHashTable *event_hash = NULL;
GdkEvent*
_gdk_event_new (void)
gdk_event_new (GdkEventType type)
{
GdkEventPrivate *new_event;
GdkEventPrivate *new_private;
GdkEvent *new_event;
if (event_chunk == NULL)
{
......@@ -272,13 +275,59 @@ _gdk_event_new (void)
event_hash = g_hash_table_new (g_direct_hash, NULL);
}
new_event = g_chunk_new (GdkEventPrivate, event_chunk);
new_event->flags = 0;
new_event->screen = NULL;
new_private = g_chunk_new (GdkEventPrivate, event_chunk);
memset (new_private, 0, sizeof (GdkEventPrivate));
new_private->flags = 0;
new_private->screen = NULL;
g_hash_table_insert (event_hash, new_private, GUINT_TO_POINTER (1));
g_hash_table_insert (event_hash, new_event, GUINT_TO_POINTER (1));
new_event = (GdkEvent *) new_private;
new_event->any.type = type;
/*
* Bytewise 0 initialization is reasonable for most of the
* current event types. Explicitely initialize double fields
* since I trust bytewise 0 == 0. less than for integers
* or pointers.
*/
switch (type)
{
case GDK_MOTION_NOTIFY:
new_event->motion.x = 0.;
new_event->motion.y = 0.;
new_event->motion.x_root = 0.;
new_event->motion.y_root = 0.;
break;
case GDK_BUTTON_PRESS:
case GDK_2BUTTON_PRESS:
case GDK_3BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
new_event->button.x = 0.;
new_event->button.y = 0.;
new_event->button.x_root = 0.;
new_event->button.y_root = 0.;
break;
case GDK_SCROLL:
new_event->scroll.x = 0.;
new_event->scroll.y = 0.;
new_event->scroll.x_root = 0.;
new_event->scroll.y_root = 0.;
break;
case GDK_ENTER_NOTIFY:
case GDK_LEAVE_NOTIFY:
new_event->crossing.x = 0.;
new_event->crossing.y = 0.;
new_event->crossing.x_root = 0.;
new_event->crossing.y_root = 0.;
break;
default:
break;
}
return (GdkEvent*) new_event;
return new_event;
}
static gboolean
......@@ -303,15 +352,22 @@ gdk_event_is_allocated (GdkEvent *event)
GdkEvent*
gdk_event_copy (GdkEvent *event)
{
GdkEventPrivate *private;
GdkEventPrivate *new_private;
GdkEvent *new_event;
g_return_val_if_fail (event != NULL, NULL);
new_event = _gdk_event_new ();
new_event = gdk_event_new (GDK_NOTHING);
new_private = (GdkEventPrivate *)new_event;
private = (GdkEventPrivate *)event;
*new_event = *event;
if (new_event->any.window)
g_object_ref (new_event->any.window);
new_private->screen = private->screen;
switch (event->any.type)
{
......
......@@ -237,7 +237,6 @@ struct _GdkEventNoExpose
GdkEventType type;
GdkWindow *window;
gint8 send_event;
/* XXX: does anyone need the X major_code or minor_code fields? */
};
struct _GdkEventVisibility
......@@ -451,6 +450,7 @@ GdkEvent* gdk_event_peek (void);
GdkEvent* gdk_event_get_graphics_expose (GdkWindow *window);
void gdk_event_put (GdkEvent *event);
GdkEvent* gdk_event_new (GdkEventType type);
GdkEvent* gdk_event_copy (GdkEvent *event);
void gdk_event_free (GdkEvent *event);
......
......@@ -169,9 +169,6 @@ extern gchar *_gdk_display_name;
extern const GdkPointerHooks *_gdk_current_pointer_hooks;
GdkEvent* _gdk_event_new (void);
void _gdk_events_queue (GdkDisplay *display);
GdkEvent* _gdk_event_unqueue (GdkDisplay *display);
......
......@@ -1456,12 +1456,11 @@ gdk_event_make (GdkWindow *window,
GdkEventType type,
gboolean append_to_queue)
{
GdkEvent *event = _gdk_event_new ();
GdkEvent *event = gdk_event_new (type);
guint32 the_time;
the_time = gdk_fb_get_time ();
event->any.type = type;
event->any.window = gdk_window_ref (window);
event->any.send_event = FALSE;
switch (type)
......
......@@ -166,6 +166,7 @@ real_window_procedure (HWND hwnd,
msg.pt.y = HIWORD (pos);
event.flags = GDK_EVENT_PENDING;
event.screen = NULL;
if (gdk_event_translate (display, &event.event, &msg, &ret_val_flag, &ret_val, FALSE))
{
event.flags &= ~GDK_EVENT_PENDING;
......@@ -217,7 +218,7 @@ real_window_procedure (HWND hwnd,
}
}
#endif
eventp = _gdk_event_new ();
eventp = gdk_event_new (GDK_NOTHING);
*((GdkEventPrivate *) eventp) = event;
/* Philippe Colantoni <colanton@aris.ss.uci.edu> suggests this
......@@ -505,7 +506,7 @@ gdk_event_get_graphics_expose (GdkWindow *window)
#else
if (PeekMessage (&msg, GDK_WINDOW_HWND (window), WM_PAINT, WM_PAINT, PM_REMOVE))
{
event = _gdk_event_new ();
event = gdk_event_new (GDK_NOTHING);
if (gdk_event_translate (gdk_drawable_get_display (window),
event, &msg, NULL, NULL, TRUE))
......@@ -1246,8 +1247,7 @@ synthesize_enter_or_leave_event (GdkWindow *window,
{
GdkEvent *event;
event = _gdk_event_new ();
event->crossing.type = type;
event = gdk_event_new (type);
event->crossing.window = window;
event->crossing.send_event = FALSE;
gdk_window_ref (event->crossing.window);
......@@ -1468,8 +1468,7 @@ synthesize_expose_events (GdkWindow *window)
WIN32_GDI_FAILED ("GetClipBox");
else if (k != NULLREGION)
{
event = _gdk_event_new ();
event->expose.type = GDK_EXPOSE;
event = gdk_event_new (GDK_EXPOSE);
event->expose.window = window;
gdk_window_ref (window);
event->expose.area.x = r.left;
......@@ -2533,7 +2532,7 @@ gdk_event_translate (GdkDisplay *display,
* (from which it will be fetched before the release
* event).
*/
GdkEvent *event2 = _gdk_event_new ();
GdkEvent *event2 = gdk_event_new (GDK_KEY_PRESS);
build_keypress_event (event2, msg);
event2->key.window = window;
gdk_drawable_ref (window);
......
......@@ -269,7 +269,7 @@ gdk_event_get_graphics_expose (GdkWindow *window)
if (xevent.xany.type == GraphicsExpose)
{
event = _gdk_event_new ();
event = gdk_event_new (GDK_NOTHING);
if (gdk_event_translate (GDK_WINDOW_DISPLAY (window), event,
&xevent, TRUE))
......@@ -1799,9 +1799,8 @@ _gdk_events_queue (GdkDisplay *display)
continue;
}
event = _gdk_event_new ();
event = gdk_event_new (GDK_NOTHING);
event->any.type = GDK_NOTHING;
event->any.window = NULL;
event->any.send_event = xevent.xany.send_event ? TRUE : FALSE;
......
......@@ -7047,21 +7047,24 @@ move_vertical (GtkCList *clist,
gtk_adjustment_set_value (clist->vadjustment, value);
}
static gint
horizontal_timeout (GtkCList *clist)
static void
do_fake_motion (GtkWidget *widget)
{
GdkEventMotion event;
GdkEvent *event = gdk_event_new (GDK_MOTION_NOTIFY);
memset (&event, 0, sizeof (event));
event->motion.send_event = TRUE;
gtk_clist_motion (widget, (GdkEventMotion *)event);
gdk_event_free (event);
}
static gint
horizontal_timeout (GtkCList *clist)
{
GDK_THREADS_ENTER ();
clist->htimer = 0;
event.type = GDK_MOTION_NOTIFY;
event.send_event = TRUE;
gtk_clist_motion (GTK_WIDGET (clist), &event);
do_fake_motion (GTK_WIDGET (clist));
GDK_THREADS_LEAVE ();
......@@ -7071,18 +7074,10 @@ horizontal_timeout (GtkCList *clist)
static gint
vertical_timeout (GtkCList *clist)
{
GdkEventMotion event;
memset (&event, 0, sizeof (event));
GDK_THREADS_ENTER ();
clist->vtimer = 0;
event.type = GDK_MOTION_NOTIFY;
event.send_event = TRUE;
gtk_clist_motion (GTK_WIDGET (clist), &event);
do_fake_motion (GTK_WIDGET (clist));
GDK_THREADS_LEAVE ();
......
......@@ -710,7 +710,7 @@ gtk_combo_list_enter (GtkWidget *widget,
(combo->current_button != 0) &&
(!GTK_WIDGET_HAS_GRAB (combo->list)))
{
GdkEvent tmp_event;
GdkEvent *tmp_event = gdk_event_new (GDK_BUTTON_PRESS);
gint x, y;
GdkModifierType mask;
......@@ -721,19 +721,19 @@ gtk_combo_list_enter (GtkWidget *widget,
*/
gdk_window_get_pointer (combo->list->window, &x, &y, &mask);
tmp_event.button.type = GDK_BUTTON_PRESS;
tmp_event.button.window = combo->list->window;
tmp_event.button.send_event = TRUE;
tmp_event.button.time = GDK_CURRENT_TIME; /* bad */
tmp_event.button.x = x;
tmp_event.button.y = y;
tmp_event->button.window = g_object_ref (combo->list->window);
tmp_event->button.send_event = TRUE;
tmp_event->button.time = GDK_CURRENT_TIME; /* bad */
tmp_event->button.x = x;
tmp_event->button.y = y;
/* We leave all the XInput fields unfilled here, in the expectation
* that GtkList doesn't care.
*/
tmp_event.button.button = combo->current_button;
tmp_event.button.state = mask;
tmp_event->button.button = combo->current_button;
tmp_event->button.state = mask;
gtk_widget_event (combo->list, &tmp_event);
gtk_widget_event (combo->list, tmp_event);
gdk_event_free (tmp_event);
}
return FALSE;
......
......@@ -2296,7 +2296,7 @@ gtk_container_propagate_expose (GtkContainer *container,
GtkWidget *child,
GdkEventExpose *event)
{
GdkEventExpose child_event;
GdkEvent *child_event;
g_return_if_fail (GTK_IS_CONTAINER (container));
g_return_if_fail (GTK_IS_WIDGET (child));
......@@ -2308,14 +2308,16 @@ gtk_container_propagate_expose (GtkContainer *container,
GTK_WIDGET_NO_WINDOW (child) &&
(child->window == event->window))
{
child_event = *event;
child_event = gdk_event_new (GDK_EXPOSE);
child_event->expose = *event;
g_object_ref (child_event->expose.window);
child_event.region = gtk_widget_region_intersect (child, event->region);
if (!gdk_region_empty (child_event.region))
child_event->expose.region = gtk_widget_region_intersect (child, event->region);
if (!gdk_region_empty (child_event->expose.region))
{
gdk_region_get_clipbox (child_event.region, &child_event.area);
gtk_widget_send_expose (child, (GdkEvent *)&child_event);
gdk_region_get_clipbox (child_event->expose.region, &child_event->expose.area);
gtk_widget_send_expose (child, child_event);
}
gdk_region_destroy (child_event.region);
gdk_event_free (child_event);
}
}
......@@ -349,20 +349,16 @@ gtk_dialog_close (GtkDialog *dialog)
{
/* Synthesize delete_event to close dialog. */
GdkEventAny event;
GdkEvent *event = gdk_event_new (GDK_DELETE);
GtkWidget *widget;
widget = GTK_WIDGET (dialog);
event.type = GDK_DELETE;
event.window = widget->window;
event.send_event = TRUE;
event->any.window = g_object_ref (widget->window);
event->any.send_event = TRUE;
g_object_ref (G_OBJECT (event.window));
gtk_main_do_event ((GdkEvent*)&event);
g_object_unref (G_OBJECT (event.window));
gtk_main_do_event (event);
gdk_event_free (event);
}
GtkWidget*
......
......@@ -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;
......
......@@ -151,17 +151,17 @@ static void
gtk_drawing_area_send_configure (GtkDrawingArea *darea)
{
GtkWidget *widget;
GdkEventConfigure event;
GdkEvent *event = gdk_event_new (GDK_CONFIGURE);
widget = GTK_WIDGET (darea);
event.type = GDK_CONFIGURE;
event.window = widget->window;
event.send_event = TRUE;
event.x = widget->allocation.x;
event.y = widget->allocation.y;
event.width = widget->allocation.width;
event.height = widget->allocation.height;
event->configure.window = g_object_ref (widget->window);
event->configure.send_event = TRUE;
event->configure.x = widget->allocation.x;
event->configure.y = widget->allocation.y;