[PATCH 1/5] dix: let scale_from_screen take the x/y axis numbers

Peter Hutterer peter.hutterer at who-t.net
Fri Dec 9 23:54:05 PST 2011


Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 dix/getevents.c |   22 ++++++++++++----------
 1 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/dix/getevents.c b/dix/getevents.c
index 8798f64..9d7dfcb 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -759,28 +759,30 @@ accelPointer(DeviceIntPtr dev, ValuatorMask* valuators, CARD32 ms)
  * @param dev The device to scale for.
  * @param[in, out] mask The mask in desktop coordinates, modified in place
  * to contain device coordinate range.
+ * @param xaxis Axis number for x axis (0-indexed)
+ * @param yaxis Axis number for y axis (0-indexed)
  */
 static void
-scale_from_screen(DeviceIntPtr dev, ValuatorMask *mask)
+scale_from_screen(DeviceIntPtr dev, ValuatorMask *mask, int xaxis, int yaxis)
 {
     double scaled;
     ScreenPtr scr = miPointerGetScreen(dev);
 
-    if (valuator_mask_isset(mask, 0))
+    if (valuator_mask_isset(mask, xaxis))
     {
-        scaled = valuator_mask_get_double(mask, 0) + scr->x;
+        scaled = valuator_mask_get_double(mask, xaxis) + scr->x;
         scaled = rescaleValuatorAxis(scaled,
-                                     NULL, dev->valuator->axes + 0,
+                                     NULL, dev->valuator->axes + xaxis,
                                      0, scr->width);
-        valuator_mask_set_double(mask, 0, scaled);
+        valuator_mask_set_double(mask, xaxis, scaled);
     }
-    if (valuator_mask_isset(mask, 1))
+    if (valuator_mask_isset(mask, yaxis))
     {
-        scaled = valuator_mask_get_double(mask, 1) + scr->y;
+        scaled = valuator_mask_get_double(mask, yaxis) + scr->y;
         scaled = rescaleValuatorAxis(scaled,
-                                     NULL, dev->valuator->axes + 1,
+                                     NULL, dev->valuator->axes + yaxis,
                                      0, scr->height);
-        valuator_mask_set_double(mask, 1, scaled);
+        valuator_mask_set_double(mask, yaxis, scaled);
     }
 }
 
@@ -1212,7 +1214,7 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type,
     if (flags & POINTER_ABSOLUTE)
     {
         if (flags & POINTER_SCREEN) /* valuators are in screen coords */
-            scale_from_screen(pDev, &mask);
+            scale_from_screen(pDev, &mask, 0, 1);
 
         transformAbsolute(pDev, &mask);
         clipAbsolute(pDev, &mask);
-- 
1.7.7.1



More information about the xorg-devel mailing list