gtkgesture: Preserve accuracy when translating events

gtk_widget_translate_coordinates() uses int argument and thus cuts off
any decimal parts. This can leads to reduces accuracy when e.g.
measuring the distance of a drag.

GTK4 is not affected as the translations is done differently.
This commit is contained in:
Guido Günther 2023-12-14 14:36:25 +01:00 committed by Carlos Garnacho
parent 1b38fcad64
commit d89447d68e

View File

@ -504,8 +504,11 @@ _update_widget_coordinates (GtkGesture *gesture,
gtk_widget_translate_coordinates (event_widget, widget,
event_x, event_y, &x, &y);
data->widget_x = x;
data->widget_y = y;
/* gtk_widget_translate() loses the fractional part so we need to
* add it back to not lose accuracy */
data->widget_x = x + (event_x - (int)event_x);
data->widget_y = y + (event_y - (int)event_y);
}
static GtkEventSequenceState