[xorg-x11-drv-synaptics/f20] Fix click delays when realtime/monotonic clocks drift apart
Peter Hutterer
whot at fedoraproject.org
Fri Sep 5 00:05:49 UTC 2014
commit ad6e091f4354d5bb33fc4ef876a9c73e8e61b36a
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date: Thu Aug 28 16:10:07 2014 +1000
Fix click delays when realtime/monotonic clocks drift apart
...nsure-we-re-on-the-same-clock-as-the-serv.patch | 95 ++++++++++++++++++++
xorg-x11-drv-synaptics.spec | 7 ++-
2 files changed, 101 insertions(+), 1 deletions(-)
---
diff --git a/0001-eventcomm-ensure-we-re-on-the-same-clock-as-the-serv.patch b/0001-eventcomm-ensure-we-re-on-the-same-clock-as-the-serv.patch
new file mode 100644
index 0000000..b79148c
--- /dev/null
+++ b/0001-eventcomm-ensure-we-re-on-the-same-clock-as-the-serv.patch
@@ -0,0 +1,95 @@
+From d1bc699ad796f61f1b9f61b77bd445212fdf24b2 Mon Sep 17 00:00:00 2001
+From: Peter Hutterer <peter.hutterer at who-t.net>
+Date: Thu, 28 Aug 2014 14:13:38 +1000
+Subject: [PATCH synaptics] eventcomm: ensure we're on the same clock as the
+ server
+
+Default on evdev devices is CLOCK_REALTIME. If that clock falls behind the
+server's CLOCK_MONOTONIC, motion after a clickpad click may be delayed by the
+difference in the clocks.
+
+In detail:
+When the timer func is triggered, GetTimeInMillis() which is CLOCK_MONOTONIC,
+is stored as hwState->millis. The eventcomm backend uses struct
+input_event time (CLOCK_REALTIME).
+
+When we read events from the device, if the evdev time is less than the server
+time, the fix for (#48777) sets the current event time to hwState->millis.
+Until the evdev time overtakes that stored time, all events have the
+hwState->millis time.
+
+If during that time a clickpad triggers a physical click,
+clickpad_click_millis is set to hwState->millis + the ignore-motion timeout.
+Thus, all motion is ignored until the event time overtakes that stored
+time.
+
+The whole issue is further enhanced by us unconditionally setting the timer
+func if we get any events, which is a separate issue anyway.
+
+Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
+---
+ src/eventcomm.c | 17 ++++++++++++++---
+ 1 file changed, 14 insertions(+), 3 deletions(-)
+
+diff --git a/src/eventcomm.c b/src/eventcomm.c
+index 20dbeea..3b32425 100644
+--- a/src/eventcomm.c
++++ b/src/eventcomm.c
+@@ -39,6 +39,7 @@
+ #include <dirent.h>
+ #include <string.h>
+ #include <stdio.h>
++#include <time.h>
+ #include "synproto.h"
+ #include "synapticsstr.h"
+ #include <xf86.h>
+@@ -80,6 +81,8 @@ struct eventcomm_proto_data {
+ ValuatorMask **last_mt_vals;
+ int num_touches;
+ int *tracking_ids;
++
++ int have_monotonic_clock;
+ };
+
+ struct eventcomm_proto_data *
+@@ -198,11 +201,11 @@ EventDeviceOnHook(InputInfoPtr pInfo, SynapticsParameters * para)
+ SynapticsPrivate *priv = (SynapticsPrivate *) pInfo->private;
+ struct eventcomm_proto_data *proto_data =
+ (struct eventcomm_proto_data *) priv->proto_data;
++ int clockid = CLOCK_MONOTONIC;
++ int ret;
+
+ if (para->grab_event_device) {
+ /* Try to grab the event device so that data don't leak to /dev/input/mice */
+- int ret;
+-
+ SYSCALL(ret = ioctl(pInfo->fd, EVIOCGRAB, (pointer) 1));
+ if (ret < 0) {
+ xf86IDrvMsg(pInfo, X_WARNING, "can't grab event device, errno=%d\n",
+@@ -213,6 +216,11 @@ EventDeviceOnHook(InputInfoPtr pInfo, SynapticsParameters * para)
+
+ proto_data->need_grab = FALSE;
+
++#ifdef EVIOCSCLOCKID
++ SYSCALL(ret = ioctl(pInfo->fd, EVIOCSCLOCKID, &clockid));
++ proto_data->have_monotonic_clock = (ret == 0);
++#endif
++
+ InitializeTouch(pInfo);
+
+ return TRUE;
+@@ -684,7 +692,10 @@ EventReadHwState(InputInfoPtr pInfo,
+ switch (ev.code) {
+ case SYN_REPORT:
+ hw->numFingers = count_fingers(pInfo, comm);
+- hw->millis = 1000 * ev.time.tv_sec + ev.time.tv_usec / 1000;
++ if (proto_data->have_monotonic_clock)
++ hw->millis = 1000 * ev.time.tv_sec + ev.time.tv_usec / 1000;
++ else
++ hw->millis = GetTimeInMillis();
+ SynapticsCopyHwState(hwRet, hw);
+ return TRUE;
+ }
+--
+1.9.3
+
diff --git a/xorg-x11-drv-synaptics.spec b/xorg-x11-drv-synaptics.spec
index 7c89bbf..243344d 100644
--- a/xorg-x11-drv-synaptics.spec
+++ b/xorg-x11-drv-synaptics.spec
@@ -8,7 +8,7 @@
Name: xorg-x11-drv-synaptics
Summary: Xorg X11 Synaptics touchpad input driver
Version: 1.7.6
-Release: 4%{?gitdate:.%{gitdate}git%{gitversion}}%{?dist}
+Release: 5%{?gitdate:.%{gitdate}git%{gitversion}}%{?dist}
URL: http://www.x.org
License: MIT
Group: User Interface/X Hardware Support
@@ -25,6 +25,7 @@ Source4: 70-touchpad-quirks.rules
Patch01: 0001-conf-increase-top-software-button-area-to-15.patch
Patch02: 0002-Prevent-two-finger-taps-from-being-ignored.patch
+Patch03: 0001-eventcomm-ensure-we-re-on-the-same-clock-as-the-serv.patch
ExcludeArch: s390 s390x
@@ -85,6 +86,7 @@ Features:
%setup -q -n %{tarball}-%{?gitdate:%{gitdate}}%{!?gitdate:%{version}}
%patch01 -p1
%patch02 -p1
+%patch03 -p1
%build
autoreconf -v --install --force || exit 1
@@ -133,6 +135,9 @@ Development files for the Synaptics TouchPad for X.Org.
%changelog
+* Thu Aug 28 2014 Peter Hutterer <peter.hutterer at redhat.com> 1.7.6-5
+- Fix click delays when realtime/monotonic clocks drift apart
+
* Thu Aug 28 2014 Peter Hutterer <peter.hutterer at redhat.com> 1.7.6-4
- This time with the patches applied
More information about the scm-commits
mailing list