From: Matthias Clasen Date: Fri, 24 Mar 2023 18:49:18 +0000 (-0400) Subject: texthandle: Correct placement of handles X-Git-Tag: archive/raspbian/4.12.3+ds-1+rpi1~1^2^2^2~22^2~1^2~505^2~1 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=9db08c7a86be691ccca80f5b0d18787552c0dff4;p=gtk4.git texthandle: Correct placement of handles Text handles had the same problem as popovers. They were interpreting their pointing-to rectangle relative to the widgets bounds, when it is meant to be relative to the widgtets allocation. While we touch this code, rewrite it to use gtk_widget_compute_point. --- diff --git a/gtk/gtktexthandle.c b/gtk/gtktexthandle.c index a373c6527c..40e6c9c191 100644 --- a/gtk/gtktexthandle.c +++ b/gtk/gtktexthandle.c @@ -131,15 +131,26 @@ gtk_text_handle_present_surface (GtkTextHandle *handle) GdkRectangle rect; GtkRequisition req; GtkWidget *parent; + GtkNative *native; + graphene_point_t point = GRAPHENE_POINT_INIT (handle->pointing_to.x, handle->pointing_to.y); + graphene_point_t transformed; + double nx, ny; gtk_widget_get_preferred_size (widget, NULL, &req); gtk_text_handle_get_padding (handle, &handle->border); parent = gtk_widget_get_parent (widget); - gtk_widget_get_surface_allocation (parent, &rect); - rect.x += handle->pointing_to.x; - rect.y += handle->pointing_to.y + handle->pointing_to.height - handle->border.top; + native = gtk_widget_get_native (parent); + gtk_native_get_surface_transform (native, &nx, &ny); + + if (!gtk_widget_compute_point (parent, GTK_WIDGET (native), + &point, &transformed)) + transformed = point; + + rect.x = (int)(transformed.x + nx); + rect.y = (int)(transformed.y + ny) + handle->pointing_to.height - handle->border.top; + rect.width = req.width - handle->border.left - handle->border.right; rect.height = 1;