summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2022-03-16 09:55:20 +0100
committerCarlos Garnacho <carlosg@gnome.org>2022-03-16 19:50:21 +0100
commitd808298b68b919b4cd9eb834b2da8d0d72759c55 (patch)
tree200966bfc347a3ae14f60cfb66dfec37a8965357
parent108b7025dc814e70b98c98634aa3b9e7e77e3446 (diff)
downloadgtk+-d808298b68b919b4cd9eb834b2da8d0d72759c55.tar.gz
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
-rw-r--r--gtk/gtkimcontextwayland.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/gtk/gtkimcontextwayland.c b/gtk/gtkimcontextwayland.c
index 60e1e466bf..e0259d0182 100644
--- a/gtk/gtkimcontextwayland.c
+++ b/gtk/gtkimcontextwayland.c
@@ -357,7 +357,7 @@ notify_cursor_location (GtkIMContextWayland *context)
{
GtkIMContextWaylandGlobal *global;
cairo_rectangle_int_t rect;
- double x, y;
+ double x, y, sx, sy;
global = gtk_im_context_wayland_get_global (context);
if (global == NULL)
@@ -369,8 +369,11 @@ notify_cursor_location (GtkIMContextWayland *context)
rect.x, rect.y,
&x, &y);
- rect.x = x;
- rect.y = y;
+ gtk_native_get_surface_transform (gtk_widget_get_native (context->widget),
+ &sx, &sy);
+
+ rect.x = x + sx;
+ rect.y = y + sy;
zwp_text_input_v3_set_cursor_rectangle (global->text_input,
rect.x, rect.y,
rect.width, rect.height);