summaryrefslogtreecommitdiff
path: root/gtk
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
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')
-rw-r--r--gtk/gtkclist.c31
-rw-r--r--gtk/gtkcombo.c20
-rw-r--r--gtk/gtkcontainer.c16
-rw-r--r--gtk/gtkdialog.c14
-rw-r--r--gtk/gtkdnd.c73
-rw-r--r--gtk/gtkdrawingarea.c18
-rw-r--r--gtk/gtkimcontextsimple.c7
-rw-r--r--gtk/gtklist.c33
-rw-r--r--gtk/gtkmenu.c41
-rw-r--r--gtk/gtknotebook.c18
-rw-r--r--gtk/gtkplug.c42
-rw-r--r--gtk/gtkselection.c13
-rw-r--r--gtk/gtktext.c15
-rw-r--r--gtk/gtktreeitem.c17
-rw-r--r--gtk/gtktreeview.c88
-rw-r--r--gtk/gtkviewport.c3
-rw-r--r--gtk/gtkwindow-decorate.c16
-rw-r--r--gtk/gtkwindow.c31
18 files changed, 260 insertions, 236 deletions
diff --git a/gtk/gtkclist.c b/gtk/gtkclist.c
index f66a12d72f..9f7f0d9c05 100644
--- a/gtk/gtkclist.c
+++ b/gtk/gtkclist.c
@@ -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 ();
diff --git a/gtk/gtkcombo.c b/gtk/gtkcombo.c
index 3c4e6cd637..09e43c8c1b 100644
--- a/gtk/gtkcombo.c
+++ b/gtk/gtkcombo.c
@@ -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;
diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c
index bccb2dec29..43e2a64d71 100644
--- a/gtk/gtkcontainer.c
+++ b/gtk/gtkcontainer.c
@@ -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);
}
}
diff --git a/gtk/gtkdialog.c b/gtk/gtkdialog.c
index d2d5af9538..228a6decc0 100644
--- a/gtk/gtkdialog.c
+++ b/gtk/gtkdialog.c
@@ -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*
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;
diff --git a/gtk/gtkdrawingarea.c b/gtk/gtkdrawingarea.c
index 5564488d49..87d5b205c6 100644
--- a/gtk/gtkdrawingarea.c
+++ b/gtk/gtkdrawingarea.c
@@ -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;
+ event->configure.width = widget->allocation.width;
+ event->configure.height = widget->allocation.height;
- gtk_widget_event (widget, (GdkEvent*) &event);
+ gtk_widget_event (widget, event);
+ gdk_event_free (event);
}
diff --git a/gtk/gtkimcontextsimple.c b/gtk/gtkimcontextsimple.c
index b4ba799667..99db9d2333 100644
--- a/gtk/gtkimcontextsimple.c
+++ b/gtk/gtkimcontextsimple.c
@@ -1132,10 +1132,11 @@ no_sequence_matches (GtkIMContextSimple *context_simple,
for (i=0; i < n_compose - len - 1; i++)
{
- GdkEventKey tmp_event = *event;
- tmp_event.keyval = context_simple->compose_buffer[len + i];
+ GdkEventKey *tmp_event = gdk_event_copy (event);
+ tmp_event->keyval = context_simple->compose_buffer[len + i];
- gtk_im_context_filter_keypress (context, &tmp_event);
+ gtk_im_context_filter_keypress (context, tmp_event);
+ gdk_event_free (tmp_event);
}
return gtk_im_context_filter_keypress (context, event);
diff --git a/gtk/gtklist.c b/gtk/gtklist.c
index 318b8f12f4..2f7b05ab12 100644
--- a/gtk/gtklist.c
+++ b/gtk/gtklist.c
@@ -2317,22 +2317,25 @@ gtk_list_move_focus_child (GtkList *list,
}
}
-static gint
-gtk_list_horizontal_timeout (GtkWidget *list)
+static void
+do_fake_motion (GtkWidget *list)
{
- GdkEventMotion event;
+ GdkEvent *event = gdk_event_new (GDK_MOTION_NOTIFY);
+
+ event->motion.send_event = TRUE;
- memset (&event, 0, sizeof (event));
+ gtk_list_motion_notify (list, (GdkEventMotion *)event);
+ gdk_event_free (event);
+}
+static gint
+gtk_list_horizontal_timeout (GtkWidget *list)
+{
GDK_THREADS_ENTER ();
GTK_LIST (list)->htimer = 0;
-
- event.type = GDK_MOTION_NOTIFY;
- event.send_event = TRUE;
-
- gtk_list_motion_notify (list, &event);
-
+ do_fake_motion (list);
+
GDK_THREADS_LEAVE ();
return FALSE;
@@ -2341,18 +2344,10 @@ gtk_list_horizontal_timeout (GtkWidget *list)
static gint
gtk_list_vertical_timeout (GtkWidget *list)
{
- GdkEventMotion event;
-
- memset (&event, 0, sizeof (event));
-
GDK_THREADS_ENTER ();
GTK_LIST (list)->vtimer = 0;
-
- event.type = GDK_MOTION_NOTIFY;
- event.send_event = TRUE;
-
- gtk_list_motion_notify (list, &event);
+ do_fake_motion (list);
GDK_THREADS_LEAVE ();
diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c
index 28bbcc0993..5b3efc51fd 100644
--- a/gtk/gtkmenu.c
+++ b/gtk/gtkmenu.c
@@ -1979,17 +1979,17 @@ gtk_menu_motion_notify (GtkWidget *widget,
if (event->x >= 0 && event->x < width &&
event->y >= 0 && event->y < height)
{
- GdkEvent send_event;
-
- memset (&send_event, 0, sizeof (send_event));
- send_event.crossing.type = GDK_ENTER_NOTIFY;
- send_event.crossing.window = event->window;
- send_event.crossing.time = event->time;
- send_event.crossing.send_event = TRUE;
- send_event.crossing.x_root = event->x_root;
- send_event.crossing.y_root = event->y_root;
- send_event.crossing.x = event->x;
- send_event.crossing.y = event->y;
+ GdkEvent *send_event = gdk_event_new (GDK_ENTER_NOTIFY);
+ gboolean result;
+
+ send_event->crossing.type = GDK_ENTER_NOTIFY;
+ send_event->crossing.window = g_object_ref (event->window);
+ send_event->crossing.time = event->time;
+ send_event->crossing.send_event = TRUE;
+ send_event->crossing.x_root = event->x_root;
+ send_event->crossing.y_root = event->y_root;
+ send_event->crossing.x = event->x;
+ send_event->crossing.y = event->y;
/* We send the event to 'widget', the currently active menu,
* instead of 'menu', the menu that the pointer is in. This
@@ -1997,7 +1997,10 @@ gtk_menu_motion_notify (GtkWidget *widget,
* menuitem is a child of the active menu or some parent
* menu of the active menu.
*/
- return gtk_widget_event (widget, &send_event);
+ result = gtk_widget_event (widget, &send_event);
+ gdk_event_free (send_event);
+
+ return result;
}
}
@@ -2244,15 +2247,15 @@ gtk_menu_stop_navigating_submenu_cb (gpointer user_data)
if (child_window)
{
- GdkEventCrossing send_event;
+ GdkEvent *send_event = gdk_event_new (GDK_ENTER_NOTIFY);
+
+ send_event->crossing.window = g_object_ref (child_window);
+ send_event->crossing.time = GDK_CURRENT_TIME; /* Bogus */
+ send_event->crossing.send_event = TRUE;
- memset (&send_event, 0, sizeof (send_event));
- send_event.window = child_window;
- send_event.type = GDK_ENTER_NOTIFY;
- send_event.time = GDK_CURRENT_TIME; /* Bogus */
- send_event.send_event = TRUE;
+ GTK_WIDGET_CLASS (parent_class)->enter_notify_event (GTK_WIDGET (menu), (GdkEventCrossing *)send_event);
- GTK_WIDGET_CLASS (parent_class)->enter_notify_event (GTK_WIDGET (menu), &send_event);
+ gdk_event_free (send_event);
}
}
diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c
index de2d2c0aba..ddcbe486e6 100644
--- a/gtk/gtknotebook.c
+++ b/gtk/gtknotebook.c
@@ -2779,20 +2779,20 @@ gtk_notebook_draw_tab (GtkNotebook *notebook,
if (gtk_widget_intersect (page->tab_label, area, &child_area) &&
GTK_WIDGET_DRAWABLE (page->tab_label))
{
- GdkEventExpose expose_event;
+ GdkEvent *expose_event = gdk_event_new (GDK_EXPOSE);
/* This is a lame hack since all this code needs rewriting anyhow */
- expose_event.window = page->tab_label->window;
- expose_event.area = child_area;
- expose_event.region = gdk_region_rectangle (&child_area);
- expose_event.send_event = TRUE;
- expose_event.type = GDK_EXPOSE;
- expose_event.count = 0;
+ expose_event->expose.window = g_object_ref (page->tab_label->window);
+ expose_event->expose.area = child_area;
+ expose_event->expose.region = gdk_region_rectangle (&child_area);
+ expose_event->expose.send_event = TRUE;
+ expose_event->expose.type = GDK_EXPOSE;
+ expose_event->expose.count = 0;
- gtk_container_propagate_expose (GTK_CONTAINER (notebook), page->tab_label, &expose_event);
+ gtk_container_propagate_expose (GTK_CONTAINER (notebook), page->tab_label, (GdkEventExpose *)&expose_event);
- gdk_region_destroy (expose_event.region);
+ gdk_event_free (expose_event);
}
}
}
diff --git a/gtk/gtkplug.c b/gtk/gtkplug.c
index 68554ec738..0ba21ce5a6 100644
--- a/gtk/gtkplug.c
+++ b/gtk/gtkplug.c
@@ -247,6 +247,24 @@ _gtk_plug_add_to_socket (GtkPlug *plug,
g_signal_emit_by_name (G_OBJECT (socket), "plug_added", 0);
}
+static void
+send_delete_event (GtkWidget *widget)
+{
+ GdkEvent *event = gdk_event_new (GDK_DELETE);
+
+ event->any.window = g_object_ref (widget->window);
+ event->any.send_event = FALSE;
+
+ gtk_widget_ref (widget);
+
+ if (!gtk_widget_event (widget, event))
+ gtk_widget_destroy (widget);
+
+ gtk_widget_unref (widget);
+
+ gdk_event_free (event);
+}
+
/**
* _gtk_plug_remove_from_socket:
* @plug: a #GtkPlug
@@ -259,7 +277,6 @@ _gtk_plug_remove_from_socket (GtkPlug *plug,
GtkSocket *socket)
{
GtkWidget *widget;
- GdkEvent event;
gboolean result;
gboolean widget_was_visible;
@@ -298,14 +315,8 @@ _gtk_plug_remove_from_socket (GtkPlug *plug,
if (!result)
gtk_widget_destroy (GTK_WIDGET (socket));
- event.any.type = GDK_DELETE;
- event.any.window = g_object_ref (widget->window);
- event.any.send_event = FALSE;
-
- if (!gtk_widget_event (widget, &event))
- gtk_widget_destroy (widget);
-
- g_object_unref (event.any.window);
+ send_delete_event (widget);
+
g_object_unref (plug);
if (widget_was_visible && GTK_WIDGET_VISIBLE (socket))
@@ -1110,18 +1121,7 @@ gtk_plug_filter_func (GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data)
*/
if (xre->parent == GDK_WINDOW_XWINDOW (gdk_screen_get_root_window (screen)))
- {
- GdkEvent event;
-
- event.any.type = GDK_DELETE;
- event.any.window = g_object_ref (widget->window);
- event.any.send_event = FALSE;
-
- if (!gtk_widget_event (widget, &event))
- gtk_widget_destroy (widget);
-
- g_object_unref (event.any.window);
- }
+ send_delete_event (widget);
}
else
goto done;
diff --git a/gtk/gtkselection.c b/gtk/gtkselection.c
index b8a081cc55..69ccb6985c 100644
--- a/gtk/gtkselection.c
+++ b/gtk/gtkselection.c
@@ -380,14 +380,15 @@ gtk_selection_owner_set_for_display (GdkDisplay *display,
*/
if (old_owner && old_owner != widget)
{
- GdkEventSelection event;
+ GdkEvent *event = gdk_event_new (GDK_SELECTION_CLEAR);
- event.type = GDK_SELECTION_CLEAR;
- event.window = old_owner->window;
- event.selection = selection;
- event.time = time;
+ event->selection.window = g_object_ref (old_owner->window);
+ event->selection.selection = selection;
+ event->selection.time = time;
- gtk_widget_event (old_owner, (GdkEvent *) &event);
+ gtk_widget_event (old_owner, event);
+
+ gdk_event_free (event);
}
return TRUE;
}
diff --git a/gtk/gtktext.c b/gtk/gtktext.c
index 4d17b791d0..dce952a59d 100644
--- a/gtk/gtktext.c
+++ b/gtk/gtktext.c
@@ -1644,7 +1644,6 @@ static gint
gtk_text_scroll_timeout (gpointer data)
{
GtkText *text;
- GdkEventMotion event;
gint x, y;
GdkModifierType mask;
@@ -1657,12 +1656,16 @@ gtk_text_scroll_timeout (gpointer data)
if (mask & (GDK_BUTTON1_MASK | GDK_BUTTON3_MASK))
{
- event.is_hint = 0;
- event.x = x;
- event.y = y;
- event.state = mask;
+ GdkEvent *event = gdk_event_new (GDK_MOTION_NOTIFY);
- gtk_text_motion_notify (GTK_WIDGET (text), &event);
+ event->motion.is_hint = 0;
+ event->motion.x = x;
+ event->motion.y = y;
+ event->motion.state = mask;
+
+ gtk_text_motion_notify (GTK_WIDGET (text), (GdkEventMotion *)event);
+
+ gdk_event_free (event);
}
GDK_THREADS_LEAVE ();
diff --git a/gtk/gtktreeitem.c b/gtk/gtktreeitem.c
index aa63e09c9f..c764a0d3f0 100644
--- a/gtk/gtktreeitem.c
+++ b/gtk/gtktreeitem.c
@@ -697,22 +697,23 @@ gtk_tree_item_expose_child (GtkWidget *child,
GtkWidget *container;
GdkEventExpose *event;
} *data = client_data;
- GdkEventExpose child_event;
if (GTK_WIDGET_DRAWABLE (child) &&
GTK_WIDGET_NO_WINDOW (child) &&
(child->window == data->event->window))
{
- child_event = *data->event;
+ GdkEvent *child_event = gdk_event_new (GDK_EXPOSE);
+ child_event->expose = *data->event;
+ g_object_ref (child_event->expose.window);
- child_event.region = gtk_widget_region_intersect (child,
- data->event->region);
- if (!gdk_region_empty (child_event.region))
+ child_event->expose.region = gtk_widget_region_intersect (child,
+ data->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);
}
}
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index 44681f83cf..eb6d1720a0 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -6802,7 +6802,7 @@ void
_gtk_tree_view_column_start_drag (GtkTreeView *tree_view,
GtkTreeViewColumn *column)
{
- GdkEvent send_event;
+ GdkEvent *send_event;
GtkAllocation allocation;
gint x, y, width, height;
GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET (tree_view));
@@ -6838,29 +6838,31 @@ _gtk_tree_view_column_start_drag (GtkTreeView *tree_view,
gtk_grab_remove (column->button);
- send_event.crossing.type = GDK_LEAVE_NOTIFY;
- send_event.crossing.send_event = TRUE;
- send_event.crossing.window = column->button->window;
- send_event.crossing.subwindow = NULL;
- send_event.crossing.detail = GDK_NOTIFY_ANCESTOR;
- send_event.crossing.time = GDK_CURRENT_TIME;
-
- gtk_propagate_event (column->button, &send_event);
-
- send_event.button.type = GDK_BUTTON_RELEASE;
- send_event.button.window = gdk_screen_get_root_window (screen);
- send_event.button.send_event = TRUE;
- send_event.button.time = GDK_CURRENT_TIME;
- send_event.button.x = -1;
- send_event.button.y = -1;
- send_event.button.axes = NULL;
- send_event.button.state = 0;
- send_event.button.button = 1;
- 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 (column->button, &send_event);
+ send_event = gdk_event_new (GDK_LEAVE_NOTIFY);
+ send_event->crossing.send_event = TRUE;
+ send_event->crossing.window = g_object_ref (column->button->window);
+ send_event->crossing.subwindow = NULL;
+ send_event->crossing.detail = GDK_NOTIFY_ANCESTOR;
+ send_event->crossing.time = GDK_CURRENT_TIME;
+
+ gtk_propagate_event (column->button, send_event);
+ gdk_event_free (send_event);
+
+ send_event = gdk_event_new (GDK_BUTTON_RELEASE);
+ send_event->button.window = g_object_ref (gdk_screen_get_root_window (screen));
+ send_event->button.send_event = TRUE;
+ send_event->button.time = GDK_CURRENT_TIME;
+ send_event->button.x = -1;
+ send_event->button.y = -1;
+ send_event->button.axes = NULL;
+ send_event->button.state = 0;
+ send_event->button.button = 1;
+ 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 (column->button, send_event);
+ gdk_event_free (send_event);
gdk_window_move_resize (tree_view->priv->drag_window,
column->button->allocation.x,
@@ -7515,13 +7517,38 @@ gtk_tree_view_real_select_cursor_parent (GtkTreeView *tree_view)
gtk_tree_path_free (cursor_path);
}
+/* Cut and paste from gtkwindow.c */
+static void
+send_focus_change (GtkWidget *widget,
+ gboolean in)
+{
+ GdkEvent *fevent = gdk_event_new (GDK_FOCUS_CHANGE);
+
+ g_object_ref (widget);
+
+ if (in)
+ GTK_WIDGET_SET_FLAGS (widget, GTK_HAS_FOCUS);
+ else
+ GTK_WIDGET_UNSET_FLAGS (widget, GTK_HAS_FOCUS);
+
+ fevent->focus_change.type = GDK_FOCUS_CHANGE;
+ fevent->focus_change.window = g_object_ref (widget->window);
+ fevent->focus_change.in = in;
+
+ gtk_widget_event (widget, fevent);
+
+ g_object_notify (G_OBJECT (widget), "has_focus");
+
+ g_object_unref (widget);
+ gdk_event_free (fevent);
+}
+
static void
gtk_tree_view_real_start_interactive_search (GtkTreeView *tree_view)
{
GtkWidget *window;
GtkWidget *entry;
GtkWidget *search_dialog;
- GdkEventFocus focus_event;
if (! GTK_WIDGET_HAS_FOCUS (tree_view))
return;
@@ -7566,9 +7593,7 @@ gtk_tree_view_real_start_interactive_search (GtkTreeView *tree_view)
gtk_widget_grab_focus (entry);
/* send focus-in event */
- focus_event.type = GDK_FOCUS_CHANGE;
- focus_event.in = TRUE;
- gtk_widget_event (entry, (GdkEvent *) &focus_event);
+ send_focus_change (entry, TRUE);
/* position window */
@@ -10448,11 +10473,8 @@ gtk_tree_view_search_dialog_destroy (GtkWidget *search_dialog,
if (entry)
{
- GdkEventFocus focus_event;
-
- focus_event.type = GDK_FOCUS_CHANGE;
- focus_event.in = FALSE;
- gtk_widget_event (GTK_WIDGET (entry), (GdkEvent *) &focus_event);
+ /* send focus-in event */
+ send_focus_change (GTK_WIDGET (entry), FALSE);
}
/* remove data from tree_view */
diff --git a/gtk/gtkviewport.c b/gtk/gtkviewport.c
index 1a41d758a3..e72945109d 100644
--- a/gtk/gtkviewport.c
+++ b/gtk/gtkviewport.c
@@ -582,7 +582,6 @@ gtk_viewport_expose (GtkWidget *widget,
{
GtkViewport *viewport;
GtkBin *bin;
- GdkEventExpose child_event;
if (GTK_WIDGET_DRAWABLE (widget))
{
@@ -593,8 +592,6 @@ gtk_viewport_expose (GtkWidget *widget,
gtk_viewport_paint (widget, &event->area);
else if (event->window == viewport->bin_window)
{
- child_event = *event;
-
gtk_paint_flat_box(widget->style, viewport->bin_window,
GTK_STATE_NORMAL, GTK_SHADOW_NONE,
&event->area, widget, "viewportbin",
diff --git a/gtk/gtkwindow-decorate.c b/gtk/gtkwindow-decorate.c
index d65da6680f..68a23d00fc 100644
--- a/gtk/gtkwindow-decorate.c
+++ b/gtk/gtkwindow-decorate.c
@@ -481,18 +481,14 @@ gtk_decorated_window_button_release (GtkWidget *widget,
type = gtk_decorated_window_region_type (window, event->x, event->y);
if (type == GTK_WINDOW_REGION_CLOSE)
{
- GdkEventAny event;
+ GdkEvent *event = gdk_event_new (GDK_DELETE);
- event.type = GDK_DELETE;
- event.window = widget->window;
- event.send_event = TRUE;
+ event->any.type = GDK_DELETE;
+ event->any.window = g_object_ref (widget->window);
+ event->any.send_event = TRUE;
- /* Synthesize delete_event */
- g_object_ref (event.window);
-
- gtk_main_do_event ((GdkEvent *) &event);
-
- g_object_unref (event.window);
+ gtk_main_do_event (event);
+ gdk_event_free (event);
}
}
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 60279caf21..62f5315b9a 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -4077,24 +4077,25 @@ static void
do_focus_change (GtkWidget *widget,
gboolean in)
{
- GdkEventFocus fevent;
-
+ GdkEvent *fevent = gdk_event_new (GDK_FOCUS_CHANGE);
+
g_object_ref (widget);
-
- if (in)
+
+ if (in)
GTK_WIDGET_SET_FLAGS (widget, GTK_HAS_FOCUS);
else
GTK_WIDGET_UNSET_FLAGS (widget, GTK_HAS_FOCUS);
-
- fevent.type = GDK_FOCUS_CHANGE;
- fevent.window = widget->window;
- fevent.in = in;
- gtk_widget_event (widget, (GdkEvent*) &fevent);
+ fevent->focus_change.type = GDK_FOCUS_CHANGE;
+ fevent->focus_change.window = g_object_ref (widget->window);
+ fevent->focus_change.in = in;
+
+ gtk_widget_event (widget, fevent);
g_object_notify (G_OBJECT (widget), "has_focus");
g_object_unref (widget);
+ gdk_event_free (fevent);
}
static gint
@@ -4140,20 +4141,22 @@ gtk_window_read_rcfiles (GtkWidget *widget,
embedded_windows = g_object_get_data (G_OBJECT (widget), "gtk-embedded");
if (embedded_windows)
{
- GdkEventClient sev;
+ GdkEvent *send_event = gdk_event_new (GDK_CLIENT_EVENT);
int i;
for (i = 0; i < 5; i++)
- sev.data.l[i] = 0;
- sev.data_format = 32;
- sev.message_type = atom_rcfiles;
+ send_event->client.data.l[i] = 0;
+ send_event->client.data_format = 32;
+ send_event->client.message_type = atom_rcfiles;
while (embedded_windows)
{
guint xid = GPOINTER_TO_UINT (embedded_windows->data);
- gdk_event_send_client_message_for_display (gtk_widget_get_display (widget), (GdkEvent *) &sev, xid);
+ gdk_event_send_client_message_for_display (gtk_widget_get_display (widget), send_event, xid);
embedded_windows = embedded_windows->next;
}
+
+ gdk_event_free (send_event);
}
gtk_rc_reparse_all_for_settings (gtk_widget_get_settings (widget), FALSE);