[PATCH 2/5] dix: let positionScreen take an x/y axis number

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


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

diff --git a/dix/getevents.c b/dix/getevents.c
index 9d7dfcb..bc532ca 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -804,6 +804,8 @@ scale_from_screen(DeviceIntPtr dev, ValuatorMask *mask, int xaxis, int yaxis)
  * @param mode Movement mode (Absolute or Relative)
  * @param[in,out] mask Mask of axis values for this event, returns the
  * per-screen device coordinates after confinement
+ * @param xaxis axis number for x axis (0-indexed)
+ * @param yaxis axis number for y axis (0-indexed)
  * @param[out] devx x desktop-wide coordinate in device coordinate system
  * @param[out] devy y desktop-wide coordinate in device coordinate system
  * @param[out] screenx x coordinate in desktop coordinate system
@@ -811,6 +813,7 @@ scale_from_screen(DeviceIntPtr dev, ValuatorMask *mask, int xaxis, int yaxis)
  */
 static ScreenPtr
 positionSprite(DeviceIntPtr dev, int mode, ValuatorMask *mask,
+               int xaxis, int yaxis,
                double *devx, double *devy,
                double *screenx, double *screeny)
 {
@@ -821,19 +824,19 @@ positionSprite(DeviceIntPtr dev, int mode, ValuatorMask *mask,
     if (!dev->valuator || dev->valuator->numAxes < 2)
         return scr;
 
-    if (valuator_mask_isset(mask, 0))
-        x = valuator_mask_get_double(mask, 0);
+    if (valuator_mask_isset(mask, xaxis))
+        x = valuator_mask_get_double(mask, xaxis);
     else
-        x = dev->last.valuators[0];
-    if (valuator_mask_isset(mask, 1))
-        y = valuator_mask_get_double(mask, 1);
+        x = dev->last.valuators[xaxis];
+    if (valuator_mask_isset(mask, yaxis))
+        y = valuator_mask_get_double(mask, yaxis);
     else
-        y = dev->last.valuators[1];
+        y = dev->last.valuators[yaxis];
 
     /* scale x&y to desktop coordinates */
-    *screenx = rescaleValuatorAxis(x, dev->valuator->axes + 0, NULL,
+    *screenx = rescaleValuatorAxis(x, dev->valuator->axes + xaxis, NULL,
                                    screenInfo.x, screenInfo.width);
-    *screeny = rescaleValuatorAxis(y, dev->valuator->axes + 1, NULL,
+    *screeny = rescaleValuatorAxis(y, dev->valuator->axes + yaxis, NULL,
                                    screenInfo.y, screenInfo.height);
 
     tmpx = *screenx;
@@ -851,23 +854,23 @@ positionSprite(DeviceIntPtr dev, int mode, ValuatorMask *mask,
      * crossing this doesn't matter much, the coords would be 0 or max.
      */
     if (tmpx != *screenx)
-        *devx = rescaleValuatorAxis(*screenx, NULL, dev->valuator->axes + 0,
+        *devx = rescaleValuatorAxis(*screenx, NULL, dev->valuator->axes + xaxis,
                                     screenInfo.x, screenInfo.width);
 
     if (tmpy != *screeny)
-        *devy = rescaleValuatorAxis(*screeny, NULL, dev->valuator->axes + 1,
+        *devy = rescaleValuatorAxis(*screeny, NULL, dev->valuator->axes + yaxis,
                                     screenInfo.y, screenInfo.height);
 
     /* Recalculate the per-screen device coordinates */
-    if (valuator_mask_isset(mask, 0)) {
-        x = rescaleValuatorAxis(*screenx - scr->x, NULL, dev->valuator->axes + 0,
+    if (valuator_mask_isset(mask, xaxis)) {
+        x = rescaleValuatorAxis(*screenx - scr->x, NULL, dev->valuator->axes + xaxis,
                                 0, scr->width);
-        valuator_mask_set_double(mask, 0, x);
+        valuator_mask_set_double(mask, xaxis, x);
     }
-    if (valuator_mask_isset(mask, 1)) {
-        y = rescaleValuatorAxis(*screeny - scr->y, NULL, dev->valuator->axes + 1,
+    if (valuator_mask_isset(mask, yaxis)) {
+        y = rescaleValuatorAxis(*screeny - scr->y, NULL, dev->valuator->axes + yaxis,
                                 0, scr->height);
-        valuator_mask_set_double(mask, 1, y);
+        valuator_mask_set_double(mask, yaxis, y);
     }
 
     return scr;
@@ -1230,7 +1233,7 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type,
         set_raw_valuators(raw, &mask, raw->valuators.data);
 
     scr = positionSprite(pDev, (flags & POINTER_ABSOLUTE) ? Absolute : Relative,
-                         &mask, &devx, &devy, &screenx, &screeny);
+                         &mask, 0, 1, &devx, &devy, &screenx, &screeny);
 
     /* screenx, screeny are in desktop coordinates,
        mask is in device coordinates per-screen (the event data)
-- 
1.7.7.1



More information about the xorg-devel mailing list