diff --git a/src/evdev-mt-touchpad-buttons.c b/src/evdev-mt-touchpad-buttons.c index 358b9ea4..8c374345 100644 --- a/src/evdev-mt-touchpad-buttons.c +++ b/src/evdev-mt-touchpad-buttons.c @@ -1056,8 +1056,7 @@ tp_notify_clickpadbutton(struct tp_dispatch *tp, struct evdev_dispatch *dispatch = tp->buttons.trackpoint->dispatch; struct input_event event; - event.time.tv_sec = time / ms2us(1000); - event.time.tv_usec = time % ms2us(1000); + event.time = us2tv(time); event.type = EV_KEY; event.code = button; event.value = (state == LIBINPUT_BUTTON_STATE_PRESSED) ? 1 : 0; diff --git a/src/libinput-util.h b/src/libinput-util.h index ab485c56..57bcdbb5 100644 --- a/src/libinput-util.h +++ b/src/libinput-util.h @@ -473,6 +473,17 @@ tv2us(const struct timeval *tv) return s2us(tv->tv_sec) + tv->tv_usec; } +static inline struct timeval +us2tv(uint64_t time) +{ + struct timeval tv; + + tv.tv_sec = time / ms2us(1000); + tv.tv_usec = time % ms2us(1000); + + return tv; +} + static inline bool safe_atoi_base(const char *str, int *val, int base) {