[PATCH evdev 2/2] Always report all valuators on absolute devices

Éric Brunet Eric.Brunet at lps.ens.fr
Sat Sep 27 13:08:39 PDT 2014


When dealing with a device identified as a tablet, both Qt and gtk seem to
ignore the position as reported by the X server, but rather compute
themselves the position from the raw valuator values (In order to achieve
better precision, I imagine). This usually works well because most
tablets use the wacom driver and wacom always report all the valuators at
each event, even the unchanged ones. However, evdev reports only the
valuators that have changed, and it is a source of problems for several
programs when used with a tablet, see bugs
	https://bugs.freedesktop.org/show_bug.cgi?id=82250
and	https://bugs.freedesktop.org/show_bug.cgi?id=82181

This patch makes evdev always report all the valuators for devices with
absolute positionning, which fixes the problems I reported.

Signed-off-by: Éric Brunet <Eric.Brunet at lps.ens.fr>
---
 src/evdev.c | 33 +++++++++++++++++++++++++++------
 1 file changed, 27 insertions(+), 6 deletions(-)

diff --git a/src/evdev.c b/src/evdev.c
index 8eb749a..9fa17b5 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -941,11 +941,26 @@ static void EvdevPostQueuedEvents(InputInfoPtr pInfo)
                                       pEvdev->queue[i].val))
                 break;
 
-            if (pEvdev->abs_queued && pEvdev->in_proximity) {
-                xf86PostButtonEvent(pInfo->dev, Absolute, pEvdev-
>queue[i].detail.key,
-                                     pEvdev->queue[i].val, 0, 0);
-
-            } else
+            /*
+             * We try to report all the valuators with the button events
+             * because both Qt ang gtk seem to expect them to be present
+             * for tablets and similar devices. In fact, the wacom driver
+             * always sends all the valuator, so evdev should do the same.
+             *
+             * However, we only do this if
+             *   a) the device uses absolute values (because sending a
+             *      relative valuator several time would be akin to moving 
the
+             *      cursor twice)
+             *   b) the device is in proximity (because we don't trust 
position
+             *      otherwise)
+             */
+            if ((pEvdev->flags & EVDEV_ABSOLUTE_EVENTS) &&
+                !(pEvdev->flags & EVDEV_RELATIVE_MODE) &&
+                pEvdev->in_proximity && pEvdev->vals)
+                xf86PostButtonEventM(pInfo->dev, Absolute, pEvdev-
>queue[i].detail.key,
+                                     pEvdev->queue[i].val, pEvdev->vals);
+            else
+            /* Either relative or not in proximity */
                 xf86PostButtonEvent(pInfo->dev, Relative, pEvdev-
>queue[i].detail.key,
                                     pEvdev->queue[i].val, 0, 0);
             break;
@@ -993,7 +1008,13 @@ EvdevProcessSyncEvent(InputInfoPtr pInfo, struct 
input_event *ev)
         /* don't reset the touchMask */
     }
 
-    if (pEvdev->vals)
+    /*
+     * Do not reset pEvdev->vals if the device uses absolute events. That
+     * way, all the valuators (even those that didn't change) are always
+     * reported 
+     */
+    if (pEvdev->vals &&
+        (pEvdev->flags & (EVDEV_RELATIVE_EVENTS|EVDEV_RELATIVE_MODE)) )
         valuator_mask_zero(pEvdev->vals);
     pEvdev->num_queue = 0;
     pEvdev->abs_queued = 0;
-- 
1.9.3


More information about the xorg-devel mailing list