From d9d4d92ff0aa995d4749c570e9ac17220f6ca213 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 6 May 2025 13:02:41 +1000 Subject: [PATCH] Move libinput_now() to our timer.c helper functions This is just general cleanup so libinput_now() is easier to use without needing to include libinput-private.h (which itself opens up most of libinput's internals). Part-of: --- src/libinput-private.h | 14 -------------- src/timer.c | 14 ++++++++++++++ src/timer.h | 3 +++ 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/libinput-private.h b/src/libinput-private.h index 80fff4bf..199eab4d 100644 --- a/src/libinput-private.h +++ b/src/libinput-private.h @@ -908,20 +908,6 @@ switch_notify_toggle(struct libinput_device *device, enum libinput_switch sw, enum libinput_switch_state state); -static inline uint64_t -libinput_now(struct libinput *libinput) -{ - uint64_t now; - int rc = now_in_us(&now); - - if (rc < 0) { - log_error(libinput, "clock_gettime failed: %s\n", strerror(-rc)); - return 0; - } - - return now; -} - static inline struct device_float_coords device_delta(const struct device_coords a, const struct device_coords b) { diff --git a/src/timer.c b/src/timer.c index da3f5931..07c23419 100644 --- a/src/timer.c +++ b/src/timer.c @@ -250,3 +250,17 @@ libinput_timer_flush(struct libinput *libinput, uint64_t now) libinput_timer_handler(libinput, now); } + +uint64_t +libinput_now(struct libinput *libinput) +{ + uint64_t now; + int rc = now_in_us(&now); + + if (rc < 0) { + log_error(libinput, "clock_gettime failed: %s\n", strerror(-rc)); + return 0; + } + + return now; +} diff --git a/src/timer.h b/src/timer.h index 2da0163b..e6bbf9c6 100644 --- a/src/timer.h +++ b/src/timer.h @@ -76,4 +76,7 @@ libinput_timer_subsys_destroy(struct libinput *libinput); void libinput_timer_flush(struct libinput *libinput, uint64_t now); +uint64_t +libinput_now(struct libinput *libinput); + #endif