touchpad: Only break out of tap FSM for clickpad button presses
[platform/upstream/libinput.git] / src / timer.c
index 65fdd17..ad0fd7c 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <assert.h>
 #include <errno.h>
+#include <inttypes.h>
 #include <string.h>
 #include <sys/timerfd.h>
 #include <unistd.h>
@@ -44,7 +45,7 @@ libinput_timer_arm_timer_fd(struct libinput *libinput)
 {
        int r;
        struct libinput_timer *timer;
-       struct itimerspec its = { { 0 }, { 0 } };
+       struct itimerspec its = { { 0, 0 }, { 0, 0 } };
        uint64_t earliest_expire = UINT64_MAX;
 
        list_for_each(timer, &libinput->timer.list, link) {
@@ -59,12 +60,28 @@ libinput_timer_arm_timer_fd(struct libinput *libinput)
 
        r = timerfd_settime(libinput->timer.fd, TFD_TIMER_ABSTIME, &its, NULL);
        if (r)
-               log_error("timerfd_settime error: %s\n", strerror(errno));
+               log_error(libinput, "timerfd_settime error: %s\n", strerror(errno));
 }
 
 void
 libinput_timer_set(struct libinput_timer *timer, uint64_t expire)
 {
+#ifndef NDEBUG
+       struct timespec ts;
+
+       if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) {
+               uint64_t now = ts.tv_sec * 1000ULL + ts.tv_nsec / 1000000;
+               if (abs(expire - now) > 5000)
+                       log_bug_libinput(timer->libinput,
+                                        "timer offset more than 5s, now %"
+                                        PRIu64 " expire %" PRIu64 "\n",
+                                        now, expire);
+       } else {
+               log_error(timer->libinput,
+                         "clock_gettime error: %s\n", strerror(errno));
+       }
+#endif
+
        assert(expire);
 
        if (!timer->expire)
@@ -96,7 +113,7 @@ libinput_timer_handler(void *data)
 
        r = clock_gettime(CLOCK_MONOTONIC, &ts);
        if (r) {
-               log_error("clock_gettime error: %s\n", strerror(errno));
+               log_error(libinput, "clock_gettime error: %s\n", strerror(errno));
                return;
        }