summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2017-04-28 13:44:59 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2017-04-28 16:47:38 +1000
commit2b867feab754ff19dc7cdd694ef74d1d63982e62 (patch)
tree05117eb5a36d7ffab4124b89ec67ddceec172c14
parentea4332a6cf84bad73adc8f61da027ca2591105ec (diff)
Put a check in to make sure our events have correct timestamps
This is for debugging purposes only, we cannot guarantee that event timestamps always go up - at least not across devices. Example: tapping on a touchpad may delay an event until a timeout expires, but that event is then sent with the original touch timestamps (i.e. in the past). If any other device produces events during that timeout period, our timestamps are out-of-order. This isn't really a bug because we are forced to do that, but for bug-fixing it can be useful to detect. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--src/libinput-private.h2
-rw-r--r--src/libinput.c86
2 files changed, 51 insertions, 37 deletions
diff --git a/src/libinput-private.h b/src/libinput-private.h
index a1d5000..1a564f9 100644
--- a/src/libinput-private.h
+++ b/src/libinput-private.h
@@ -136,6 +136,8 @@ struct libinput {
int refcount;
struct list device_group_list;
+
+ uint64_t last_event_time;
};
typedef void (*libinput_seat_destroy_func) (struct libinput_seat *seat);
diff --git a/src/libinput.c b/src/libinput.c
index 514a611..472b1c0 100644
--- a/src/libinput.c
+++ b/src/libinput.c
@@ -25,6 +25,7 @@
#include "config.h"
#include <errno.h>
+#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -73,6 +74,43 @@ check_event_type(struct libinput *libinput,
return rc;
}
+static inline const char *
+event_type_to_str(enum libinput_event_type type)
+{
+ switch(type) {
+ CASE_RETURN_STRING(LIBINPUT_EVENT_DEVICE_ADDED);
+ CASE_RETURN_STRING(LIBINPUT_EVENT_DEVICE_REMOVED);
+ CASE_RETURN_STRING(LIBINPUT_EVENT_KEYBOARD_KEY);
+ CASE_RETURN_STRING(LIBINPUT_EVENT_POINTER_MOTION);
+ CASE_RETURN_STRING(LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE);
+ CASE_RETURN_STRING(LIBINPUT_EVENT_POINTER_BUTTON);
+ CASE_RETURN_STRING(LIBINPUT_EVENT_POINTER_AXIS);
+ CASE_RETURN_STRING(LIBINPUT_EVENT_TOUCH_DOWN);
+ CASE_RETURN_STRING(LIBINPUT_EVENT_TOUCH_UP);
+ CASE_RETURN_STRING(LIBINPUT_EVENT_TOUCH_MOTION);
+ CASE_RETURN_STRING(LIBINPUT_EVENT_TOUCH_CANCEL);
+ CASE_RETURN_STRING(LIBINPUT_EVENT_TOUCH_FRAME);
+ CASE_RETURN_STRING(LIBINPUT_EVENT_TABLET_TOOL_AXIS);
+ CASE_RETURN_STRING(LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
+ CASE_RETURN_STRING(LIBINPUT_EVENT_TABLET_TOOL_TIP);
+ CASE_RETURN_STRING(LIBINPUT_EVENT_TABLET_TOOL_BUTTON);
+ CASE_RETURN_STRING(LIBINPUT_EVENT_TABLET_PAD_BUTTON);
+ CASE_RETURN_STRING(LIBINPUT_EVENT_TABLET_PAD_RING);
+ CASE_RETURN_STRING(LIBINPUT_EVENT_TABLET_PAD_STRIP);
+ CASE_RETURN_STRING(LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN);
+ CASE_RETURN_STRING(LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE);
+ CASE_RETURN_STRING(LIBINPUT_EVENT_GESTURE_SWIPE_END);
+ CASE_RETURN_STRING(LIBINPUT_EVENT_GESTURE_PINCH_BEGIN);
+ CASE_RETURN_STRING(LIBINPUT_EVENT_GESTURE_PINCH_UPDATE);
+ CASE_RETURN_STRING(LIBINPUT_EVENT_GESTURE_PINCH_END);
+ CASE_RETURN_STRING(LIBINPUT_EVENT_SWITCH_TOGGLE);
+ case LIBINPUT_EVENT_NONE:
+ abort();
+ }
+
+ return NULL;
+}
+
struct libinput_source {
libinput_source_dispatch_t dispatch;
void *user_data;
@@ -2026,6 +2064,17 @@ post_device_event(struct libinput_device *device,
struct libinput_event *event)
{
struct libinput_event_listener *listener, *tmp;
+#if 0
+ struct libinput *libinput = device->seat->libinput;
+
+ if (libinput->last_event_time > time) {
+ log_bug_libinput(device->seat->libinput,
+ "out-of-order timestamps for %s time %" PRIu64 "\n",
+ event_type_to_str(type),
+ time);
+ }
+ libinput->last_event_time = time;
+#endif
init_event_base(event, device, type);
@@ -2660,43 +2709,6 @@ gesture_notify_pinch_end(struct libinput_device *device,
finger_count, cancelled, &zero, &zero, scale, 0.0);
}
-static inline const char *
-event_type_to_str(enum libinput_event_type type)
-{
- switch(type) {
- CASE_RETURN_STRING(LIBINPUT_EVENT_DEVICE_ADDED);
- CASE_RETURN_STRING(LIBINPUT_EVENT_DEVICE_REMOVED);
- CASE_RETURN_STRING(LIBINPUT_EVENT_KEYBOARD_KEY);
- CASE_RETURN_STRING(LIBINPUT_EVENT_POINTER_MOTION);
- CASE_RETURN_STRING(LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE);
- CASE_RETURN_STRING(LIBINPUT_EVENT_POINTER_BUTTON);
- CASE_RETURN_STRING(LIBINPUT_EVENT_POINTER_AXIS);
- CASE_RETURN_STRING(LIBINPUT_EVENT_TOUCH_DOWN);
- CASE_RETURN_STRING(LIBINPUT_EVENT_TOUCH_UP);
- CASE_RETURN_STRING(LIBINPUT_EVENT_TOUCH_MOTION);
- CASE_RETURN_STRING(LIBINPUT_EVENT_TOUCH_CANCEL);
- CASE_RETURN_STRING(LIBINPUT_EVENT_TOUCH_FRAME);
- CASE_RETURN_STRING(LIBINPUT_EVENT_TABLET_TOOL_AXIS);
- CASE_RETURN_STRING(LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
- CASE_RETURN_STRING(LIBINPUT_EVENT_TABLET_TOOL_TIP);
- CASE_RETURN_STRING(LIBINPUT_EVENT_TABLET_TOOL_BUTTON);
- CASE_RETURN_STRING(LIBINPUT_EVENT_TABLET_PAD_BUTTON);
- CASE_RETURN_STRING(LIBINPUT_EVENT_TABLET_PAD_RING);
- CASE_RETURN_STRING(LIBINPUT_EVENT_TABLET_PAD_STRIP);
- CASE_RETURN_STRING(LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN);
- CASE_RETURN_STRING(LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE);
- CASE_RETURN_STRING(LIBINPUT_EVENT_GESTURE_SWIPE_END);
- CASE_RETURN_STRING(LIBINPUT_EVENT_GESTURE_PINCH_BEGIN);
- CASE_RETURN_STRING(LIBINPUT_EVENT_GESTURE_PINCH_UPDATE);
- CASE_RETURN_STRING(LIBINPUT_EVENT_GESTURE_PINCH_END);
- CASE_RETURN_STRING(LIBINPUT_EVENT_SWITCH_TOGGLE);
- case LIBINPUT_EVENT_NONE:
- abort();
- }
-
- return NULL;
-}
-
void
switch_notify_toggle(struct libinput_device *device,
uint64_t time,