Commit 7265ed4f authored by Christian Persch's avatar Christian Persch

Store the event mask and extension event mode directly in the gobject data

	* gtk/gtkwidget.c: Store the event mask and extension event mode
	directly in the gobject data pointer, instead of in an allocated
	gint. Bug #506604.

svn path=/trunk/; revision=19381
parent 00a56fc2
2008-01-16 Christian Persch <chpe@gnome.org>
* gtk/gtkwidget.c: Store the event mask and extension event mode
directly in the gobject data pointer, instead of in an allocated
gint. Bug #506604.
2008-01-16 Michael Natterer <mitch@imendio.com> 2008-01-16 Michael Natterer <mitch@imendio.com>
* configure.in (GDK_PIXBUF_PACKAGES): add "gio-2.0" because * configure.in (GDK_PIXBUF_PACKAGES): add "gio-2.0" because
......
...@@ -2468,8 +2468,8 @@ gtk_widget_get_property (GObject *object, ...@@ -2468,8 +2468,8 @@ gtk_widget_get_property (GObject *object,
switch (prop_id) switch (prop_id)
{ {
gint *eventp; gpointer *eventp;
GdkExtensionMode *modep; gpointer *modep;
case PROP_NAME: case PROP_NAME:
if (widget->name) if (widget->name)
...@@ -2532,17 +2532,11 @@ gtk_widget_get_property (GObject *object, ...@@ -2532,17 +2532,11 @@ gtk_widget_get_property (GObject *object,
break; break;
case PROP_EVENTS: case PROP_EVENTS:
eventp = g_object_get_qdata (G_OBJECT (widget), quark_event_mask); eventp = g_object_get_qdata (G_OBJECT (widget), quark_event_mask);
if (!eventp) g_value_set_flags (value, GPOINTER_TO_INT (eventp));
g_value_set_flags (value, 0);
else
g_value_set_flags (value, *eventp);
break; break;
case PROP_EXTENSION_EVENTS: case PROP_EXTENSION_EVENTS:
modep = g_object_get_qdata (G_OBJECT (widget), quark_extension_event_mode); modep = g_object_get_qdata (G_OBJECT (widget), quark_extension_event_mode);
if (!modep) g_value_set_enum (value, GPOINTER_TO_INT (modep));
g_value_set_enum (value, 0);
else
g_value_set_enum (value, (GdkExtensionMode) *modep);
break; break;
case PROP_NO_SHOW_ALL: case PROP_NO_SHOW_ALL:
g_value_set_boolean (value, gtk_widget_get_no_show_all (widget)); g_value_set_boolean (value, gtk_widget_get_no_show_all (widget));
...@@ -7117,27 +7111,11 @@ void ...@@ -7117,27 +7111,11 @@ void
gtk_widget_set_events (GtkWidget *widget, gtk_widget_set_events (GtkWidget *widget,
gint events) gint events)
{ {
gint *eventp;
g_return_if_fail (GTK_IS_WIDGET (widget)); g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (!GTK_WIDGET_REALIZED (widget)); g_return_if_fail (!GTK_WIDGET_REALIZED (widget));
eventp = g_object_get_qdata (G_OBJECT (widget), quark_event_mask); g_object_set_qdata (G_OBJECT (widget), quark_event_mask,
GINT_TO_POINTER (events));
if (events)
{
if (!eventp)
eventp = g_slice_new (gint);
*eventp = events;
g_object_set_qdata (G_OBJECT (widget), quark_event_mask, eventp);
}
else if (eventp)
{
g_slice_free (gint, eventp);
g_object_set_qdata (G_OBJECT (widget), quark_event_mask, NULL);
}
g_object_notify (G_OBJECT (widget), "events"); g_object_notify (G_OBJECT (widget), "events");
} }
...@@ -7179,28 +7157,13 @@ void ...@@ -7179,28 +7157,13 @@ void
gtk_widget_add_events (GtkWidget *widget, gtk_widget_add_events (GtkWidget *widget,
gint events) gint events)
{ {
gint *eventp; gint old_events;
g_return_if_fail (GTK_IS_WIDGET (widget)); g_return_if_fail (GTK_IS_WIDGET (widget));
eventp = g_object_get_qdata (G_OBJECT (widget), quark_event_mask); old_events = GPOINTER_TO_INT (g_object_get_qdata (G_OBJECT (widget), quark_event_mask));
g_object_set_qdata (G_OBJECT (widget), quark_event_mask,
if (events) GINT_TO_POINTER (old_events | events));
{
if (!eventp)
{
eventp = g_slice_new (gint);
*eventp = 0;
}
*eventp |= events;
g_object_set_qdata (G_OBJECT (widget), quark_event_mask, eventp);
}
else if (eventp)
{
g_slice_free (gint, eventp);
g_object_set_qdata (G_OBJECT (widget), quark_event_mask, NULL);
}
if (GTK_WIDGET_REALIZED (widget)) if (GTK_WIDGET_REALIZED (widget))
{ {
...@@ -7231,20 +7194,13 @@ void ...@@ -7231,20 +7194,13 @@ void
gtk_widget_set_extension_events (GtkWidget *widget, gtk_widget_set_extension_events (GtkWidget *widget,
GdkExtensionMode mode) GdkExtensionMode mode)
{ {
GdkExtensionMode *modep;
g_return_if_fail (GTK_IS_WIDGET (widget)); g_return_if_fail (GTK_IS_WIDGET (widget));
modep = g_object_get_qdata (G_OBJECT (widget), quark_extension_event_mode);
if (!modep)
modep = g_slice_new (GdkExtensionMode);
if (GTK_WIDGET_REALIZED (widget)) if (GTK_WIDGET_REALIZED (widget))
gtk_widget_set_extension_events_internal (widget, mode, NULL); gtk_widget_set_extension_events_internal (widget, mode, NULL);
*modep = mode; g_object_set_qdata (G_OBJECT (widget), quark_extension_event_mode,
g_object_set_qdata (G_OBJECT (widget), quark_extension_event_mode, modep); GINT_TO_POINTER (mode));
g_object_notify (G_OBJECT (widget), "extension-events"); g_object_notify (G_OBJECT (widget), "extension-events");
} }
...@@ -7437,15 +7393,9 @@ gtk_widget_set_colormap (GtkWidget *widget, ...@@ -7437,15 +7393,9 @@ gtk_widget_set_colormap (GtkWidget *widget,
gint gint
gtk_widget_get_events (GtkWidget *widget) gtk_widget_get_events (GtkWidget *widget)
{ {
gint *events;
g_return_val_if_fail (GTK_IS_WIDGET (widget), 0); g_return_val_if_fail (GTK_IS_WIDGET (widget), 0);
events = g_object_get_qdata (G_OBJECT (widget), quark_event_mask); return GPOINTER_TO_INT (g_object_get_qdata (G_OBJECT (widget), quark_event_mask));
if (events)
return *events;
return 0;
} }
/** /**
...@@ -7460,15 +7410,9 @@ gtk_widget_get_events (GtkWidget *widget) ...@@ -7460,15 +7410,9 @@ gtk_widget_get_events (GtkWidget *widget)
GdkExtensionMode GdkExtensionMode
gtk_widget_get_extension_events (GtkWidget *widget) gtk_widget_get_extension_events (GtkWidget *widget)
{ {
GdkExtensionMode *mode;
g_return_val_if_fail (GTK_IS_WIDGET (widget), 0); g_return_val_if_fail (GTK_IS_WIDGET (widget), 0);
mode = g_object_get_qdata (G_OBJECT (widget), quark_extension_event_mode); return GPOINTER_TO_INT (g_object_get_qdata (G_OBJECT (widget), quark_extension_event_mode));
if (mode)
return *mode;
return 0;
} }
/** /**
...@@ -7883,8 +7827,6 @@ gtk_widget_finalize (GObject *object) ...@@ -7883,8 +7827,6 @@ gtk_widget_finalize (GObject *object)
{ {
GtkWidget *widget = GTK_WIDGET (object); GtkWidget *widget = GTK_WIDGET (object);
GtkWidgetAuxInfo *aux_info; GtkWidgetAuxInfo *aux_info;
gint *events;
GdkExtensionMode *mode;
GtkAccessible *accessible; GtkAccessible *accessible;
gtk_grab_remove (widget); gtk_grab_remove (widget);
...@@ -7897,14 +7839,6 @@ gtk_widget_finalize (GObject *object) ...@@ -7897,14 +7839,6 @@ gtk_widget_finalize (GObject *object)
aux_info =_gtk_widget_get_aux_info (widget, FALSE); aux_info =_gtk_widget_get_aux_info (widget, FALSE);
if (aux_info) if (aux_info)
gtk_widget_aux_info_destroy (aux_info); gtk_widget_aux_info_destroy (aux_info);
events = g_object_get_qdata (G_OBJECT (widget), quark_event_mask);
if (events)
g_slice_free (gint, events);
mode = g_object_get_qdata (G_OBJECT (widget), quark_extension_event_mode);
if (mode)
g_slice_free (GdkExtensionMode, mode);
accessible = g_object_get_qdata (G_OBJECT (widget), quark_accessible_object); accessible = g_object_get_qdata (G_OBJECT (widget), quark_accessible_object);
if (accessible) if (accessible)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment