[gtk/wip/baedert/for-master: 27/58] gesturestylus: Retrieve event and controller widget only once
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/baedert/for-master: 27/58] gesturestylus: Retrieve event and controller widget only once
- Date: Sun, 3 Jan 2021 11:36:29 +0000 (UTC)
commit e336fe2bf8905bcc020fcdf6eae3ca4d754280ef
Author: Timm Bäder <mail baedert org>
Date: Fri Dec 25 09:58:04 2020 +0100
gesturestylus: Retrieve event and controller widget only once
Make it clear that these are not gonna chance while iterating the loop.
gtk/gtkgesturestylus.c | 8 +++++---
1 file 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))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]