From c0d0f06e1021fd16b6f8a3e8315968cca1a76d28 Mon Sep 17 00:00:00 2001 From: Goffredo Baroncelli Date: Mon, 3 Jan 2022 15:45:22 +0100 Subject: geyes: consider the offset widget <-> window To compute the correct pupil position, we should consider the offset between the eye widget and their parent window. Signed-off-by: Goffredo Baroncelli --- geyes/src/geyes.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'geyes/src') diff --git a/geyes/src/geyes.c b/geyes/src/geyes.c index 7fca8539..5fdecf38 100644 --- a/geyes/src/geyes.c +++ b/geyes/src/geyes.c @@ -132,7 +132,7 @@ timer_cb (EyesApplet *eyes_applet) { GdkDisplay *display; GdkSeat *seat; - gint x, y; + gint x, y, dx, dy; gint pupil_x, pupil_y; gsize i; @@ -144,6 +144,11 @@ timer_cb (EyesApplet *eyes_applet) gdk_window_get_device_position (gtk_widget_get_window (eyes_applet->eyes[i]), gdk_seat_get_pointer (seat), &x, &y, NULL); + gtk_widget_translate_coordinates (eyes_applet->eyes[i], + gtk_widget_get_toplevel(eyes_applet->eyes[i]), + 0, 0, &dx, &dy); + x -= dx; + y -= dy; if ((x != eyes_applet->pointer_last_x[i]) || (y != eyes_applet->pointer_last_y[i])) { -- cgit v1.2.1