Skip to content

Commit

Permalink
geyes: consider the offset widget <-> window
Browse files Browse the repository at this point in the history
To compute the correct pupil position, we should consider the offset
between the eye widget and their parent window.

Signed-off-by: Goffredo Baroncelli <kreijack@inwind.it>
  • Loading branch information
kreijack authored and raveit65 committed Jan 29, 2022
1 parent 478b4c6 commit c0d0f06
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion geyes/src/geyes.c
Expand Up @@ -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;

Expand All @@ -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])) {
Expand Down

0 comments on commit c0d0f06

Please sign in to comment.