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.
This commit is contained in:
Matthias Clasen 2020-05-17 02:04:22 -04:00
parent 428e647238
commit c90078fd4a

View File

@ -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)
};