Blame SOURCES/0001-dix-leave-last.valuators-alone-on-slave-switch.patch

62abe7
From 13f9b07039484927532d913dbccc664679235bf6 Mon Sep 17 00:00:00 2001
62abe7
From: Peter Hutterer <peter.hutterer@who-t.net>
62abe7
Date: Mon, 25 Mar 2019 13:19:41 +1000
62abe7
Subject: [PATCH xserver] dix: leave last.valuators alone on slave switch
62abe7
62abe7
Terms:
62abe7
dev->last.valuator[] is the last value given to us by the driver
62abe7
dev->valuator.axisVal[] is the last value sent to the client
62abe7
dev->last.scroll[] is the abs value of the scroll axis as given by the driver,
62abe7
        used for button emulation calculation (and the remainder)
62abe7
62abe7
This function updates the device's last.valuator state based on the current
62abe7
master axis state. This way, relative motion continues fluidly when switching
62abe7
between devices. Before mouse 2 comes into effect, it's valuator state is
62abe7
updated to wherever the pointer currently is so the relative event applies on
62abe7
top of that.
62abe7
62abe7
This can only work for x/y axes, all other axes aren't guaranteed to have the
62abe7
same meaning and/or may not be present:
62abe7
- xtest device: no valuator 2
62abe7
- mouse: valuator 2 is horizontal scroll axis
62abe7
- tablet: valuator 2 is pressure
62abe7
62abe7
Scaling the current value from the pressure range into the range for
62abe7
horizontal scrolling makes no sense. And it causes scroll jumps:
62abe7
62abe7
- scroll down, last.valuator == axisVal == 20
62abe7
- xdotool click 1, the XTest device doesn't have that valuator
62abe7
- scroll up
62abe7
  - updateSlaveDeviceCoords reset last.valuator to 0 (axisVal == 20)
62abe7
  - DeviceClassesChangedEvent includes value 20 for the axis
62abe7
  - event is processed, last.value changes from 0 to -1
62abe7
  - axisVal is updated to -1, causing a jump of -21
62abe7
62abe7
The same applies when we switch from tablet to mouse wheel if the pressure
62abe7
value is 0 on proximity out (basically guaranteed). So let's drop this code
62abe7
altogether and only leave the scaling for the relative x/y motion.
62abe7
62abe7
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
62abe7
---
62abe7
 dix/getevents.c | 25 +------------------------
62abe7
 1 file changed, 1 insertion(+), 24 deletions(-)
62abe7
62abe7
diff --git a/dix/getevents.c b/dix/getevents.c
62abe7
index d8955969a..f83dac709 100644
62abe7
--- a/dix/getevents.c
62abe7
+++ b/dix/getevents.c
62abe7
@@ -331,9 +331,6 @@ rescaleValuatorAxis(double coord, AxisInfoPtr from, AxisInfoPtr to,
62abe7
 static void
62abe7
 updateSlaveDeviceCoords(DeviceIntPtr master, DeviceIntPtr pDev)
62abe7
 {
62abe7
-    int i;
62abe7
-    DeviceIntPtr lastSlave;
62abe7
-
62abe7
     /* master->last.valuators[0]/[1] is in desktop-wide coords and the actual
62abe7
      * position of the pointer */
62abe7
     pDev->last.valuators[0] = master->last.valuators[0];
62abe7
@@ -358,27 +355,7 @@ updateSlaveDeviceCoords(DeviceIntPtr master, DeviceIntPtr pDev)
62abe7
                                                       screenInfo.height);
62abe7
     }
62abe7
62abe7
-    /* calculate the other axis as well based on info from the old
62abe7
-     * slave-device. If the old slave had less axes than this one,
62abe7
-     * last.valuators is reset to 0.
62abe7
-     */
62abe7
-    if ((lastSlave = master->last.slave) && lastSlave->valuator) {
62abe7
-        for (i = 2; i < pDev->valuator->numAxes; i++) {
62abe7
-            if (i >= lastSlave->valuator->numAxes) {
62abe7
-                pDev->last.valuators[i] = 0;
62abe7
-                valuator_mask_set_double(pDev->last.scroll, i, 0);
62abe7
-            }
62abe7
-            else {
62abe7
-                double val = pDev->last.valuators[i];
62abe7
-
62abe7
-                val = rescaleValuatorAxis(val, lastSlave->valuator->axes + i,
62abe7
-                                          pDev->valuator->axes + i, 0, 0);
62abe7
-                pDev->last.valuators[i] = val;
62abe7
-                valuator_mask_set_double(pDev->last.scroll, i, val);
62abe7
-            }
62abe7
-        }
62abe7
-    }
62abe7
-
62abe7
+    /* other axes are left as-is */
62abe7
 }
62abe7
62abe7
 /**
62abe7
--
62abe7
2.20.1