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: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1216>
This commit is contained in:
Peter Hutterer 2025-05-06 13:02:41 +10:00
parent 5774463dde
commit d9d4d92ff0
3 changed files with 17 additions and 14 deletions

View file

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

View file

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

View file

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