[gtk/wip/baedert/for-master: 36/57] gesturestylus: Only add histroy element if translation succeeded
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/baedert/for-master: 36/57] gesturestylus: Only add histroy element if translation succeeded
- Date: Thu, 31 Dec 2020 07:08:29 +0000 (UTC)
commit 2d8cd2572d2988534dcb2596695cc95b86a1371d
Author: Timm Bäder <mail baedert org>
Date: Fri Dec 25 10:07:43 2020 +0100
gesturestylus: Only add histroy element if translation succeeded
Instead of always doing it and then undoing it if the translation does
not succeed.
gtk/gtkgesturestylus.c | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
---
diff --git a/gtk/gtkgesturestylus.c b/gtk/gtkgesturestylus.c
index d6ac7e166c..92d4a37226 100644
--- a/gtk/gtkgesturestylus.c
+++ b/gtk/gtkgesturestylus.c
@@ -344,24 +344,22 @@ gtk_gesture_stylus_get_backlog (GtkGestureStylus *gesture,
controller_widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (gesture));
for (i = 0; i < n_coords; i++)
{
- GdkTimeCoord *time_coord = &history[i];
+ const GdkTimeCoord *time_coord = &history[i];
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,
&GRAPHENE_POINT_INIT (time_coord->axes[GDK_AXIS_X] - surf_x,
time_coord->axes[GDK_AXIS_Y] - surf_y),
&p))
{
- time_coord->axes[GDK_AXIS_X] = p.x;
- time_coord->axes[GDK_AXIS_Y] = p.y;
- }
- else
- {
- g_array_set_size (backlog_array, backlog_array->len - 1);
+ GdkTimeCoord translated_coord = *time_coord;
+
+ translated_coord.axes[GDK_AXIS_X] = p.x;
+ translated_coord.axes[GDK_AXIS_Y] = p.y;
+
+ g_array_append_val (backlog_array, translated_coord);
}
- }
+ }
*n_elems = backlog_array->len;
*backlog = (GdkTimeCoord *) g_array_free (backlog_array, FALSE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]