From 9648cf226b558bdfdf623b38e1167713aaaa72f5 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 14 Dec 2021 23:43:29 -0500 Subject: [PATCH] inspector: Show event history in recorder This was instrumental in debugging why scroll compression does not work. --- gtk/inspector/recorder.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/gtk/inspector/recorder.c b/gtk/inspector/recorder.c index 395381bc53..9a50567c17 100644 --- a/gtk/inspector/recorder.c +++ b/gtk/inspector/recorder.c @@ -1375,6 +1375,7 @@ populate_event_properties (GtkListStore *store, type = gdk_event_get_event_type (event); add_text_row (store, "Type", event_type_name (type)); + add_int_row (store, "Timestamp", gdk_event_get_time (event)); device = gdk_event_get_device (event); if (device) @@ -1448,6 +1449,35 @@ populate_event_properties (GtkListStore *store, /* FIXME */ ; } + + if (type == GDK_MOTION_NOTIFY || type == GDK_SCROLL) + { + GdkTimeCoord *history; + guint n_coords; + + history = gdk_event_get_history (event, &n_coords); + if (history) + { + GString *s; + + s = g_string_new (""); + + for (int i = 0; i < n_coords; i++) + { + if (i > 0) + g_string_append (s, "\n"); + if ((history[i].flags & (GDK_AXIS_FLAG_X|GDK_AXIS_FLAG_Y)) == (GDK_AXIS_FLAG_X|GDK_AXIS_FLAG_Y)) + g_string_append_printf (s, "%d: %.2f %.2f", history[i].time, history[i].axes[GDK_AXIS_X], history[i].axes[GDK_AXIS_Y]); + if ((history[i].flags & (GDK_AXIS_FLAG_DELTA_X|GDK_AXIS_FLAG_DELTA_Y)) == (GDK_AXIS_FLAG_DELTA_X|GDK_AXIS_FLAG_DELTA_Y)) + g_string_append_printf (s, "%d: %.2f %.2f", history[i].time, history[i].axes[GDK_AXIS_DELTA_X], history[i].axes[GDK_AXIS_DELTA_Y]); + } + + add_text_row (store, "History", s->str); + + g_string_free (s, TRUE); + g_free (history); + } + } } static GskRenderNode *