From: Peter Hutterer Date: Tue, 20 Oct 2020 23:06:16 +0000 (+1000) Subject: tools/debug-events: rework touch event printing X-Git-Tag: 1.16.901~57 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1ebdc605762967fe32b23816b083b17c53829d7a;p=platform%2Fupstream%2Flibinput.git tools/debug-events: rework touch event printing Previously, touch up events did not contain the slot number which makes the logs ambiguous (e.g. see the one in #532). Fix that, and since doing so would require extra conditions anyway get rid of the current with/without coords function and just handle it all inside one function instead. Signed-off-by: Peter Hutterer --- diff --git a/tools/libinput-debug-events.c b/tools/libinput-debug-events.c index 42125dc0..358bca48 100644 --- a/tools/libinput-debug-events.c +++ b/tools/libinput-debug-events.c @@ -520,15 +520,6 @@ print_tablet_axis_event(struct libinput_event *ev) printq("\n"); } -static void -print_touch_event_without_coords(struct libinput_event *ev) -{ - struct libinput_event_touch *t = libinput_event_get_touch_event(ev); - - print_event_time(libinput_event_touch_get_time(t)); - printq("\n"); -} - static void print_proximity_event(struct libinput_event *ev) { @@ -629,21 +620,30 @@ print_proximity_event(struct libinput_event *ev) } static void -print_touch_event_with_coords(struct libinput_event *ev) +print_touch_event(struct libinput_event *ev) { struct libinput_event_touch *t = libinput_event_get_touch_event(ev); - double x = libinput_event_touch_get_x_transformed(t, screen_width); - double y = libinput_event_touch_get_y_transformed(t, screen_height); - double xmm = libinput_event_touch_get_x(t); - double ymm = libinput_event_touch_get_y(t); + enum libinput_event_type type = libinput_event_get_type(ev); print_event_time(libinput_event_touch_get_time(t)); - printq("%d (%d) %5.2f/%5.2f (%5.2f/%5.2fmm)\n", - libinput_event_touch_get_slot(t), - libinput_event_touch_get_seat_slot(t), - x, y, - xmm, ymm); + if (type != LIBINPUT_EVENT_TOUCH_FRAME) { + printq("%d (%d)", + libinput_event_touch_get_slot(t), + libinput_event_touch_get_seat_slot(t)); + } + + if (type == LIBINPUT_EVENT_TOUCH_DOWN || + type == LIBINPUT_EVENT_TOUCH_MOTION) { + double x = libinput_event_touch_get_x_transformed(t, screen_width); + double y = libinput_event_touch_get_y_transformed(t, screen_height); + double xmm = libinput_event_touch_get_x(t); + double ymm = libinput_event_touch_get_y(t); + + printq(" %5.2f/%5.2f (%5.2f/%5.2fmm)", x, y, xmm, ymm); + } + + printq("\n"); } static void @@ -855,19 +855,11 @@ handle_and_print_events(struct libinput *li) print_pointer_axis_event(ev); break; case LIBINPUT_EVENT_TOUCH_DOWN: - print_touch_event_with_coords(ev); - break; case LIBINPUT_EVENT_TOUCH_MOTION: - print_touch_event_with_coords(ev); - break; case LIBINPUT_EVENT_TOUCH_UP: - print_touch_event_without_coords(ev); - break; case LIBINPUT_EVENT_TOUCH_CANCEL: - print_touch_event_without_coords(ev); - break; case LIBINPUT_EVENT_TOUCH_FRAME: - print_touch_event_without_coords(ev); + print_touch_event(ev); break; case LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN: print_gesture_event_without_coords(ev);