[gtk+] container: Add a private api for render node propagation
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] container: Add a private api for render node propagation
- Date: Tue, 1 Nov 2016 18:40:52 +0000 (UTC)
commit 68cc1412e59abf5b3c4982a2978600bc30cb29da
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Oct 28 12:56:21 2016 -0400
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.
gtk/gtkcontainer.c | 68 +++++++++++++++++++++++++++-----------------
gtk/gtkcontainerprivate.h | 4 ++
2 files changed, 46 insertions(+), 26 deletions(-)
---
diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c
index 59fb3ad..5797aaf 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_)
diff --git a/gtk/gtkcontainerprivate.h b/gtk/gtkcontainerprivate.h
index 2030591..c106ab8 100644
--- a/gtk/gtkcontainerprivate.h
+++ b/gtk/gtkcontainerprivate.h
@@ -46,6 +46,10 @@ void gtk_container_get_children_clip (GtkContainer *container,
void gtk_container_propagate_render_node (GtkContainer *container,
GskRenderer *renderer,
GskRenderNode *parent_node);
+void gtk_container_propagate_render_node_for_child (GtkContainer *container,
+ GtkWidget *child,
+ GskRenderer *renderer,
+ GskRenderNode *parent_node);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]