gesturestylus: Only add histroy element if translation succeeded

Instead of always doing it and then undoing it if the translation does
not succeed.
This commit is contained in:
Timm Bäder 2020-12-25 10:07:43 +01:00
parent e336fe2bf8
commit 71efa96ef2

View File

@ -344,22 +344,20 @@ gtk_gesture_stylus_get_backlog (GtkGestureStylus *gesture,
controller_widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (gesture)); controller_widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (gesture));
for (i = 0; i < n_coords; i++) for (i = 0; i < n_coords; i++)
{ {
GdkTimeCoord *time_coord = &history[i]; const GdkTimeCoord *time_coord = &history[i];
graphene_point_t p; graphene_point_t p;
g_array_append_val (backlog_array, *time_coord);
time_coord = &g_array_index (backlog_array, GdkTimeCoord, backlog_array->len - 1);
if (gtk_widget_compute_point (event_widget, controller_widget, if (gtk_widget_compute_point (event_widget, controller_widget,
&GRAPHENE_POINT_INIT (time_coord->axes[GDK_AXIS_X] - surf_x, &GRAPHENE_POINT_INIT (time_coord->axes[GDK_AXIS_X] - surf_x,
time_coord->axes[GDK_AXIS_Y] - surf_y), time_coord->axes[GDK_AXIS_Y] - surf_y),
&p)) &p))
{ {
time_coord->axes[GDK_AXIS_X] = p.x; GdkTimeCoord translated_coord = *time_coord;
time_coord->axes[GDK_AXIS_Y] = p.y;
} translated_coord.axes[GDK_AXIS_X] = p.x;
else translated_coord.axes[GDK_AXIS_Y] = p.y;
{
g_array_set_size (backlog_array, backlog_array->len - 1); g_array_append_val (backlog_array, translated_coord);
} }
} }