summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2013-05-03 10:39:24 +0200
committerAlexander Larsson <alexl@redhat.com>2013-05-03 10:39:24 +0200
commit97ad2d7897f222598c3d36d4cf0e707a320a959d (patch)
tree9539453eb5800a3982cf3c2adfc2ef631b38b4b3
parentf9592e3c9a481f5549f80540a4796bed6668a488 (diff)
downloadgtk+-97ad2d7897f222598c3d36d4cf0e707a320a959d.tar.gz
Add gdk_window_get_children_with_user_data
This function returns all the children that has a specific user_data set. This is used a lot in the new GtkWidget drawing code and doing it this way is faster than getting every child and calling get_user_data on each (which was a non-neglible part of the profiles). Additionally it also allows use to use some kind of hashtable to make this operation even faster if needed in the future.
-rw-r--r--gdk/gdkwindow.c41
-rw-r--r--gdk/gdkwindow.h3
2 files changed, 44 insertions, 0 deletions
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index 39ccda0b68..7a9b0c3657 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -2399,6 +2399,47 @@ gdk_window_peek_children (GdkWindow *window)
return window->children;
}
+
+/**
+ * gdk_window_get_children_with_user_data:
+ * @window: a #GdkWindow
+ *
+ * Gets the list of children of @window known to GDK with a particular
+ * user_data set on it.
+ *
+ * The returned list must be freed, but the elements in the
+ * list need not be.
+ *
+ * The list is returned in (relative) stacking order, i.e. the
+ * lowest window is first.
+ *
+ * Return value: (transfer container) (element-type GdkWindow):
+ * list of child windows inside @window
+ **/
+GList *
+gdk_window_get_children_with_user_data (GdkWindow *window, gpointer user_data)
+{
+ GdkWindow *child;
+ GList *res, *l;
+
+ g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
+
+ if (GDK_WINDOW_DESTROYED (window))
+ return NULL;
+
+ res = NULL;
+ for (l = window->children; l != NULL; l = l->next)
+ {
+ child = l->data;
+
+ if (child->user_data == user_data)
+ res = g_list_prepend (res, child);
+ }
+
+ return res;
+}
+
+
/**
* gdk_window_add_filter: (skip)
* @window: (allow-none): a #GdkWindow
diff --git a/gdk/gdkwindow.h b/gdk/gdkwindow.h
index 6ee09c4f69..2d4fa7a595 100644
--- a/gdk/gdkwindow.h
+++ b/gdk/gdkwindow.h
@@ -767,6 +767,9 @@ GdkWindow * gdk_window_get_effective_toplevel (GdkWindow *window);
GList * gdk_window_get_children (GdkWindow *window);
GList * gdk_window_peek_children (GdkWindow *window);
+GList * gdk_window_get_children_with_user_data (GdkWindow *window,
+ gpointer user_data);
+
GdkEventMask gdk_window_get_events (GdkWindow *window);
void gdk_window_set_events (GdkWindow *window,
GdkEventMask event_mask);