diff options
author | Timm Bäder <mail@baedert.org> | 2020-12-25 09:58:04 +0100 |
---|---|---|
committer | Timm Bäder <mail@baedert.org> | 2021-01-03 11:01:28 +0100 |
commit | e336fe2bf8905bcc020fcdf6eae3ca4d754280ef (patch) | |
tree | 5bca68b3ed97fdf40f4b37d1d4ba2b648be97f95 /gtk/gtkgesturestylus.c | |
parent | d7f15c15e94d0b87a4bef99cde681fa6867daba5 (diff) | |
download | gtk+-e336fe2bf8905bcc020fcdf6eae3ca4d754280ef.tar.gz |
gesturestylus: Retrieve event and controller widget only once
Make it clear that these are not gonna chance while iterating the loop.
Diffstat (limited to 'gtk/gtkgesturestylus.c')
-rw-r--r-- | gtk/gtkgesturestylus.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/gtk/gtkgesturestylus.c b/gtk/gtkgesturestylus.c index 2d49783baf..d6ac7e166c 100644 --- a/gtk/gtkgesturestylus.c +++ b/gtk/gtkgesturestylus.c @@ -322,6 +322,8 @@ gtk_gesture_stylus_get_backlog (GtkGestureStylus *gesture, guint n_coords = 0, i; double surf_x, surf_y; GtkNative *native; + GtkWidget *event_widget; + GtkWidget *controller_widget; g_return_val_if_fail (GTK_IS_GESTURE_STYLUS (gesture), FALSE); g_return_val_if_fail (backlog != NULL && n_elems != NULL, FALSE); @@ -338,6 +340,8 @@ gtk_gesture_stylus_get_backlog (GtkGestureStylus *gesture, gtk_native_get_surface_transform (native, &surf_x, &surf_y); backlog_array = g_array_new (FALSE, FALSE, sizeof (GdkTimeCoord)); + event_widget = gtk_get_event_widget (event); + controller_widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (gesture)); for (i = 0; i < n_coords; i++) { GdkTimeCoord *time_coord = &history[i]; @@ -345,9 +349,7 @@ gtk_gesture_stylus_get_backlog (GtkGestureStylus *gesture, 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 (GTK_WIDGET (native), - gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (gesture)), + 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)) |