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 <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2018-05-03 12:18:22 +10:00
parent 1392c1f3ac
commit d140bb7c2d

View file

@ -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);