From: Matthias Clasen Date: Sun, 17 May 2020 06:03:41 +0000 (-0400) Subject: textview: Fix context menu placement X-Git-Tag: archive/raspbian/4.4.1+ds1-2+rpi1^2~18^2~17^2~24^2~4 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=428e647238b7e1e53599ce822273aca6d511667c;p=gtk4.git textview: Fix context menu placement Take the surface transform into account for positioning the context menu. --- diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c index a6a02473ab..5486e13339 100644 --- a/gtk/gtktextview.c +++ b/gtk/gtktextview.c @@ -53,7 +53,7 @@ #include "gtkmagnifierprivate.h" #include "gtkemojichooser.h" #include "gtkpango.h" -#include "gtknative.h" +#include "gtknativeprivate.h" #include "gtkwidgetprivate.h" #include "a11y/gtktextviewaccessibleprivate.h" @@ -8615,13 +8615,17 @@ gtk_text_view_do_popup (GtkTextView *text_view, if (device) { + GtkNative *native; GdkSurface *surface; double px, py; + int nx, ny; - surface = gtk_native_get_surface (gtk_widget_get_native (GTK_WIDGET (text_view))); + native = gtk_widget_get_native (GTK_WIDGET (text_view)); + surface = gtk_native_get_surface (native); gdk_surface_get_device_position (surface, device, &px, &py, NULL); - rect.x = round (px); - rect.y = round (py); + gtk_native_get_surface_transform (native, &nx, &ny); + rect.x = round (px) - nx; + rect.y = round (py) - ny; gtk_widget_translate_coordinates (GTK_WIDGET (gtk_widget_get_native (GTK_WIDGET (text_view))), GTK_WIDGET (text_view),