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

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