From c90078fd4a6d23802619dfdf29279c5d98ec2495 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 17 May 2020 02:04:22 -0400 Subject: [PATCH] widget: Fix gtk_widget_get_surface_allocation As the name implies, this should be surface-relative coordinates, so it needs to take the surface transform into account. --- gtk/gtkwidget.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index a537530b80..d3c9e7232f 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -3447,6 +3447,7 @@ gtk_widget_get_surface_allocation (GtkWidget *widget, { GtkWidget *parent; graphene_rect_t bounds; + int nx, ny; /* Don't consider the parent == widget case here. */ parent = _gtk_widget_get_parent (widget); @@ -3454,12 +3455,13 @@ gtk_widget_get_surface_allocation (GtkWidget *widget, parent = _gtk_widget_get_parent (parent); g_assert (GTK_IS_WINDOW (parent) || GTK_IS_POPOVER (parent)); + gtk_native_get_surface_transform (GTK_NATIVE (parent), &nx, &ny); if (gtk_widget_compute_bounds (widget, parent, &bounds)) { *allocation = (GtkAllocation){ - floorf (bounds.origin.x), - floorf (bounds.origin.y), + floorf (bounds.origin.x) + nx, + floorf (bounds.origin.y) + ny, ceilf (bounds.size.width), ceilf (bounds.size.height) };