[gtk+/wip/ebassi/gsk-renderer: 92/103] gtk: Update the coordinates when propagating render nodes
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/ebassi/gsk-renderer: 92/103] gtk: Update the coordinates when propagating render nodes
- Date: Thu, 4 Aug 2016 10:35:53 +0000 (UTC)
commit 0751d665dbe8f6541d10c5290df1ceca3f0a62da
Author: Emmanuele Bassi <ebassi gnome org>
Date: Tue Aug 2 17:01:08 2016 +0100
gtk: Update the coordinates when propagating render nodes
Just like gtk_container_propagate_draw() does for the immediate mode
rendering.
gtk/gtkcontainer.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 49 insertions(+), 5 deletions(-)
---
diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c
index c5d792d..8704833 100644
--- a/gtk/gtkcontainer.c
+++ b/gtk/gtkcontainer.c
@@ -3886,18 +3886,62 @@ typedef struct {
} RenderData;
static void
-propagate_render_node (GtkWidget *widget,
+propagate_render_node (GtkWidget *child,
gpointer data_)
{
RenderData *data = data_;
GskRenderNode *node;
+ GdkWindow *window, *w;
+ GtkAllocation allocation;
+ int x, y;
+ graphene_matrix_t m;
+ graphene_point3d_t tmp;
+
+ node = gtk_widget_get_render_node (child, data->renderer);
+ if (node == NULL)
+ return;
- node = gtk_widget_get_render_node (widget, data->renderer);
- if (node != NULL)
+ /* translate coordinates. Ugly business, that. */
+ if (!_gtk_widget_get_has_window (GTK_WIDGET (data->container)))
{
- gsk_render_node_append_child (data->parent, node);
- gsk_render_node_unref (node);
+ _gtk_widget_get_allocation (GTK_WIDGET (data->container), &allocation);
+ x = -allocation.x;
+ y = -allocation.y;
}
+ else
+ {
+ x = 0;
+ y = 0;
+ }
+
+ window = _gtk_widget_get_window (GTK_WIDGET (data->container));
+
+ for (w = _gtk_widget_get_window (child); w && w != window; w = gdk_window_get_parent (w))
+ {
+ int wx, wy;
+ gdk_window_get_position (w, &wx, &wy);
+ x += wx;
+ y += wy;
+ }
+
+ if (w == NULL)
+ {
+ x = 0;
+ y = 0;
+ }
+
+ if (!_gtk_widget_get_has_window (child))
+ {
+ _gtk_widget_get_allocation (child, &allocation);
+ x += allocation.x;
+ y += allocation.y;
+ }
+
+ 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_unref (node);
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]