diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2020-10-21 09:06:16 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2020-10-21 09:09:50 +1000 |
commit | 1ebdc605762967fe32b23816b083b17c53829d7a (patch) | |
tree | 0c56fab5f4db0f06b1cbdaac85c61558ba5349f5 /tools | |
parent | 08999899cbd80e8ed22712cc2de579583d72a287 (diff) |
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 <peter.hutterer@who-t.net>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/libinput-debug-events.c | 48 |
1 files changed, 20 insertions, 28 deletions
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 @@ -521,15 +521,6 @@ print_tablet_axis_event(struct libinput_event *ev) } 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) { struct libinput_event_tablet_tool *t = libinput_event_get_tablet_tool_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); |