gtkimcontextwayland: Add native surface offset to input coordinates

We were missing the surface offset (e.g. shadows) at the time of expressing
the text caret location in surface coordinates. Add this offset so the
coordinates are as expected by the compositor.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/4668
This commit is contained in:
Carlos Garnacho 2022-03-16 09:55:20 +01:00
parent eb599653e6
commit 4dcd011486

View File

@ -357,7 +357,7 @@ notify_cursor_location (GtkIMContextWayland *context)
{ {
GtkIMContextWaylandGlobal *global; GtkIMContextWaylandGlobal *global;
cairo_rectangle_int_t rect; cairo_rectangle_int_t rect;
double x, y; double x, y, sx, sy;
global = gtk_im_context_wayland_get_global (context); global = gtk_im_context_wayland_get_global (context);
if (global == NULL) if (global == NULL)
@ -369,8 +369,11 @@ notify_cursor_location (GtkIMContextWayland *context)
rect.x, rect.y, rect.x, rect.y,
&x, &y); &x, &y);
rect.x = x; gtk_native_get_surface_transform (gtk_widget_get_native (context->widget),
rect.y = y; &sx, &sy);
rect.x = x + sx;
rect.y = y + sy;
zwp_text_input_v3_set_cursor_rectangle (global->text_input, zwp_text_input_v3_set_cursor_rectangle (global->text_input,
rect.x, rect.y, rect.x, rect.y,
rect.width, rect.height); rect.width, rect.height);