diff options
author | Matthias Clasen <mclasen@redhat.com> | 2016-10-28 12:56:21 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2016-11-01 14:29:25 -0400 |
commit | 68cc1412e59abf5b3c4982a2978600bc30cb29da (patch) | |
tree | ab49879da56808c130dcbf0bf7f2ccbf93f543a3 /gtk/gtkcontainer.c | |
parent | 30a56acc7deb0ba6d91d38fbe04771130211f874 (diff) | |
download | gtk+-68cc1412e59abf5b3c4982a2978600bc30cb29da.tar.gz |
container: Add a private api for render node propagation
Add a function that propagates a render node for a single
child. This will be used in the box gadget to handle widgets.
Diffstat (limited to 'gtk/gtkcontainer.c')
-rw-r--r-- | gtk/gtkcontainer.c | 68 |
1 files changed, 42 insertions, 26 deletions
diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c index 59fb3ad647..5797aaf29e 100644 --- a/gtk/gtkcontainer.c +++ b/gtk/gtkcontainer.c @@ -3287,28 +3287,12 @@ gtk_container_get_path_for_child (GtkContainer *container, return path; } -typedef struct { - GtkContainer *container; - GskRenderer *renderer; - GskRenderNode *parent; - GArray *child_infos; -} RenderData; - -static gboolean -should_propagate_node (GtkWidget *child, - RenderData *data) -{ - if (!_gtk_widget_is_drawable (child)) - return FALSE; - - return TRUE; -} - -static void -propagate_render_node (GtkWidget *child, - gpointer data_) +void +gtk_container_propagate_render_node_for_child (GtkContainer *container, + GtkWidget *child, + GskRenderer *renderer, + GskRenderNode *parent) { - RenderData *data = data_; GskRenderNode *node; GdkWindow *window, *w; GtkAllocation allocation; @@ -3316,14 +3300,17 @@ propagate_render_node (GtkWidget *child, graphene_matrix_t m; graphene_point3d_t tmp; - node = gtk_widget_get_render_node (child, data->renderer); + if (!_gtk_widget_is_drawable (child)) + return; + + node = gtk_widget_get_render_node (child, renderer); if (node == NULL) return; /* translate coordinates. Ugly business, that. */ - if (!_gtk_widget_get_has_window (GTK_WIDGET (data->container))) + if (!_gtk_widget_get_has_window (GTK_WIDGET (container))) { - gtk_widget_get_clip (GTK_WIDGET (data->container), &allocation); + gtk_widget_get_clip (GTK_WIDGET (container), &allocation); x = -allocation.x; y = -allocation.y; } @@ -3333,7 +3320,7 @@ propagate_render_node (GtkWidget *child, y = 0; } - window = _gtk_widget_get_window (GTK_WIDGET (data->container)); + window = _gtk_widget_get_window (GTK_WIDGET (container)); for (w = _gtk_widget_get_window (child); w && w != window; w = gdk_window_get_parent (w)) { @@ -3359,10 +3346,39 @@ propagate_render_node (GtkWidget *child, graphene_matrix_init_translate (&m, graphene_point3d_init (&tmp, x, y, 0)); gsk_render_node_set_transform (node, &m); - gsk_render_node_append_child (data->parent, node); + gsk_render_node_append_child (parent, node); gsk_render_node_unref (node); } +typedef struct { + GtkContainer *container; + GskRenderer *renderer; + GskRenderNode *parent; + GArray *child_infos; +} RenderData; + +static gboolean +should_propagate_node (GtkWidget *child, + RenderData *data) +{ + if (!_gtk_widget_is_drawable (child)) + return FALSE; + + return TRUE; +} + +static void +propagate_render_node (GtkWidget *child, + gpointer data_) +{ + RenderData *data = data_; + + gtk_container_propagate_render_node_for_child (data->container, + child, + data->renderer, + data->parent); +} + static void collect_child_infos (GtkWidget *widget, gpointer data_) |