a11y: Transform GetCharacterExtents coords to native surface ones
authorCarlos Garnacho <carlosg@gnome.org>
Thu, 2 Jun 2022 12:32:41 +0000 (14:32 +0200)
committerCarlos Garnacho <carlosg@gnome.org>
Thu, 2 Jun 2022 12:35:53 +0000 (14:35 +0200)
These coordinates are "window"-relative, so transform textview coordinates
to the coordinate system of the GtkNative containing it.

gtk/a11y/gtkatspitext.c

index 5bac320813ba84c85004181b246722d057aaa88b..e4a6140298f93e0cdaeb602172e1870abc603e00 100644 (file)
@@ -1126,6 +1126,13 @@ text_view_handle_method (GDBusConnection       *connection,
                                              rect.x, rect.y,
                                              &x, &y);
 
+      double dx, dy;
+      gtk_widget_translate_coordinates (widget,
+                                        GTK_WIDGET (gtk_widget_get_native (widget)),
+                                        (double) x, (double) y, &dx, &dy);
+      x = floor (dx);
+      y = floor (dy);
+
       g_dbus_method_invocation_return_value (invocation,
                                              g_variant_new ("(iiii)",
                                                             x,