From b73f5130917cc2fba19733317ae5bbc9474dd6f0 Mon Sep 17 00:00:00 2001 From: Giovanni Campagna Date: Thu, 22 Aug 2013 00:19:21 +0200 Subject: [PATCH] evdev: use monotonic times for the events The monotonic clock is what X uses too, so this way the timestamps can be compared. https://bugzilla.gnome.org/show_bug.cgi?id=706543 --- clutter/evdev/clutter-device-manager-evdev.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/clutter/evdev/clutter-device-manager-evdev.c b/clutter/evdev/clutter-device-manager-evdev.c index 866676395..08ea17241 100644 --- a/clutter/evdev/clutter-device-manager-evdev.c +++ b/clutter/evdev/clutter-device-manager-evdev.c @@ -567,7 +567,7 @@ clutter_event_source_new (ClutterInputDeviceEvdev *input_device) GSource *source = g_source_new (&event_funcs, sizeof (ClutterEventSource)); ClutterEventSource *event_source = (ClutterEventSource *) source; const gchar *node_path; - gint fd; + gint fd, clkid; GError *error; /* grab the udev input device node and open it */ @@ -602,6 +602,10 @@ clutter_event_source_new (ClutterInputDeviceEvdev *input_device) event_source->event_poll_fd.fd = fd; event_source->event_poll_fd.events = G_IO_IN; + /* Tell evdev to use the monotonic clock for its timestamps */ + clkid = CLOCK_MONOTONIC; + ioctl (fd, EVIOCSCLOCKID, &clkid); + /* and finally configure and attach the GSource */ g_source_set_priority (source, CLUTTER_PRIORITY_EVENTS); g_source_add_poll (source, &event_source->event_poll_fd);