[gtk+/xi2-playground] GtkWidget: ensure device events are set on realize.
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/xi2-playground] GtkWidget: ensure device events are set on realize.
- Date: Wed, 9 Jun 2010 16:11:09 +0000 (UTC)
commit 9f558a183c6832bab307ada4acb2d2476fb95f9b
Author: Carlos Garnacho <carlosg gnome org>
Date: Wed Jun 9 17:50:26 2010 +0200
GtkWidget: ensure device events are set on realize.
gtk/gtkwidget.c | 78 ++++++++++++++++++++++++++++++++++--------------------
1 files changed, 49 insertions(+), 29 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index b25641b..d19b346 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -370,6 +370,9 @@ static void gtk_widget_set_usize_internal (GtkWidget *widget,
static void gtk_widget_get_draw_rectangle (GtkWidget *widget,
GdkRectangle *rect);
+static void gtk_widget_add_events_internal (GtkWidget *widget,
+ GdkDevice *device,
+ gint events);
/* --- variables --- */
static gpointer gtk_widget_parent_class = NULL;
@@ -3518,6 +3521,8 @@ gtk_widget_realize (GtkWidget *widget)
if (!gtk_widget_get_realized (widget))
{
+ GHashTable *device_events;
+
/*
if (GTK_IS_CONTAINER (widget) && gtk_widget_get_has_window (widget))
g_message ("gtk_widget_realize(%s)", G_OBJECT_TYPE_NAME (widget));
@@ -3562,6 +3567,26 @@ gtk_widget_realize (GtkWidget *widget)
if ((GTK_WIDGET_FLAGS (widget) & GTK_MULTIDEVICE) != 0)
gdk_window_set_support_multidevice (widget->window, TRUE);
+
+ device_events = g_object_get_qdata (G_OBJECT (widget), quark_device_event_mask);
+
+ if (device_events)
+ {
+ GHashTableIter iter;
+ gpointer key, value;
+
+ g_hash_table_iter_init (&iter, device_events);
+
+ while (g_hash_table_iter_next (&iter, &key, &value))
+ {
+ GdkDevice *device;
+ GdkEventMask event_mask;
+
+ device = key;
+ event_mask = GPOINTER_TO_UINT (value);
+ gtk_widget_add_events_internal (widget, device, event_mask);
+ }
+ }
}
}
@@ -8112,10 +8137,10 @@ gtk_widget_set_device_events (GtkWidget *widget,
}
static void
-gtk_widget_add_events_internal (GtkWidget *widget,
- GdkDevice *device,
- gint events,
- GList *window_list)
+gtk_widget_add_events_internal_list (GtkWidget *widget,
+ GdkDevice *device,
+ gint events,
+ GList *window_list)
{
GList *l;
@@ -8135,12 +8160,29 @@ gtk_widget_add_events_internal (GtkWidget *widget,
gdk_window_set_events (window, gdk_window_get_events (window) | events);
children = gdk_window_get_children (window);
- gtk_widget_add_events_internal (widget, device, events, children);
+ gtk_widget_add_events_internal_list (widget, device, events, children);
g_list_free (children);
}
}
}
+static void
+gtk_widget_add_events_internal (GtkWidget *widget,
+ GdkDevice *device,
+ gint events)
+{
+ GList *window_list;
+
+ if (!gtk_widget_get_has_window (widget))
+ window_list = gdk_window_get_children (widget->window);
+ else
+ window_list = g_list_prepend (NULL, widget->window);
+
+ gtk_widget_add_events_internal_list (widget, device, events, window_list);
+
+ g_list_free (window_list);
+}
+
/**
* gtk_widget_add_events:
* @widget: a #GtkWidget
@@ -8162,18 +8204,7 @@ gtk_widget_add_events (GtkWidget *widget,
GINT_TO_POINTER (old_events | events));
if (gtk_widget_get_realized (widget))
- {
- GList *window_list;
-
- if (!gtk_widget_get_has_window (widget))
- window_list = gdk_window_get_children (widget->window);
- else
- window_list = g_list_prepend (NULL, widget->window);
-
- gtk_widget_add_events_internal (widget, NULL, events, window_list);
-
- g_list_free (window_list);
- }
+ gtk_widget_add_events_internal (widget, NULL, events);
g_object_notify (G_OBJECT (widget), "events");
}
@@ -8215,18 +8246,7 @@ gtk_widget_add_device_events (GtkWidget *widget,
GUINT_TO_POINTER (old_events | events));
if (gtk_widget_get_realized (widget))
- {
- GList *window_list;
-
- if (!gtk_widget_get_has_window (widget))
- window_list = gdk_window_get_children (widget->window);
- else
- window_list = g_list_prepend (NULL, widget->window);
-
- gtk_widget_add_events_internal (widget, device, events, window_list);
-
- g_list_free (window_list);
- }
+ gtk_widget_add_events_internal (widget, device, events);
g_object_notify (G_OBJECT (widget), "events");
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]