[PATCH] dix: fix scale_to_desktop for edge ABS events

Yufeng Shen miletus at chromium.org
Fri Sep 7 16:41:33 PDT 2012


Scale_to_desktop() converts ABS events from device coordinates
to screen coordinates:
[dev_X_min, dev_X_max]  -> [screen_X_min, screen_X_max]
[dev_Y_min, dev_Y_max]  -> [screen_Y_min, screen_Y_max]

An edge ABS event with X = dev_X_max (e.g., generated from the
edge of a touchscreen) will be converted to have screen X value
= screen_X_max, which, however, will be filterd out when xserver
tries to find proper Window to receive the event, because the
range check for a Window to receive events is
       window_X_min <= event_screen_X < window_X_max
Events with event_screen_X = screen_X_max will fail the test get
and rejected by the Window.

To fix this, we change the device to screen coordinates mapping to
[dev_X_min, dev_X_max]  -> [screen_X_min, screen_X_max-1]
[dev_Y_min, dev_Y_max]  -> [screen_Y_min, screen_Y_max-1]

Reviewed-by: Chase Douglas <chase.douglas at canonical.com>
Reviewed-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Signed-off-by: Yufeng Shen <miletus at chromium.org>
---
 dix/getevents.c |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/dix/getevents.c b/dix/getevents.c
index fade40c..f46b018 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -346,14 +346,14 @@ updateSlaveDeviceCoords(DeviceIntPtr master, DeviceIntPtr pDev)
                                                       NULL,
                                                       pDev->valuator->axes + 0,
                                                       screenInfo.x,
-                                                      screenInfo.width);
+                                                      screenInfo.x + screenInfo.width);
     }
     if (pDev->valuator->numAxes > 1) {
         pDev->last.valuators[1] = rescaleValuatorAxis(pDev->last.valuators[1],
                                                       NULL,
                                                       pDev->valuator->axes + 1,
                                                       screenInfo.y,
-                                                      screenInfo.height);
+                                                      screenInfo.y + screenInfo.height);
     }
 
     /* calculate the other axis as well based on info from the old
@@ -890,9 +890,11 @@ scale_to_desktop(DeviceIntPtr dev, ValuatorMask *mask,
 
     /* scale x&y to desktop coordinates */
     *screenx = rescaleValuatorAxis(x, dev->valuator->axes + 0, NULL,
-                                   screenInfo.x, screenInfo.width);
+                                   screenInfo.x,
+                                   screenInfo.x + screenInfo.width - 1);
     *screeny = rescaleValuatorAxis(y, dev->valuator->axes + 1, NULL,
-                                   screenInfo.y, screenInfo.height);
+                                   screenInfo.y,
+                                   screenInfo.y + screenInfo.height - 1);
 
     *devx = x;
     *devy = y;
@@ -946,11 +948,13 @@ positionSprite(DeviceIntPtr dev, int mode, ValuatorMask *mask,
      */
     if (tmpx != *screenx)
         *devx = rescaleValuatorAxis(*screenx, NULL, dev->valuator->axes + 0,
-                                    screenInfo.x, screenInfo.width);
+                                    screenInfo.x,
+                                    screenInfo.x + screenInfo.width);
 
     if (tmpy != *screeny)
         *devy = rescaleValuatorAxis(*screeny, NULL, dev->valuator->axes + 1,
-                                    screenInfo.y, screenInfo.height);
+                                    screenInfo.y,
+                                    screenInfo.y + screenInfo.height);
 
     /* Recalculate the per-screen device coordinates */
     if (valuator_mask_isset(mask, 0)) {
-- 
1.7.7.3



More information about the xorg-devel mailing list