From d140bb7c2d542874698dbd31958d35d065327bcd Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 3 May 2018 12:18:22 +1000 Subject: [PATCH] tools: libinput-record: move the event time offset to the first place we get it Leftover from a previous version where printing and handling an event was identical. Now we may handle events but not actually print them until a bit later, so other events may have a (wrong) zero timestamp. Signed-off-by: Peter Hutterer --- tools/libinput-record.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/libinput-record.c b/tools/libinput-record.c index fed63ca2..33bb47fb 100644 --- a/tools/libinput-record.c +++ b/tools/libinput-record.c @@ -193,8 +193,6 @@ print_evdev_event(struct record_context *ctx, struct input_event *ev) bool was_modified = false; char desc[1024]; - if (ctx->offset == 0) - ctx->offset = tv2us(&ev->time); ev->time = us2tv(tv2us(&ev->time) - ctx->offset); /* Don't leak passwords unless the user wants to */ @@ -269,6 +267,9 @@ handle_evdev_frame(struct record_context *ctx, struct record_device *d) LIBEVDEV_READ_FLAG_NORMAL, &e) == LIBEVDEV_READ_STATUS_SUCCESS) { + if (ctx->offset == 0) + ctx->offset = tv2us(&e.time); + if (d->nevents == d->events_sz) resize(d->events, d->events_sz);