[PATCH 19/27] Input: Don't call positionSprite for non-pointer devices

Daniel Stone daniel at fooishbar.org
Fri Jun 3 07:59:55 PDT 2011


If the device doesn't have any valuators, or if it has less than two of
them, don't bother calling positionSprite.  Users with one-dimensional
pointing devices may be upset.

Signed-off-by: Daniel Stone <daniel at fooishbar.org>
---
 dix/getevents.c |   33 ++++++++++++---------------------
 1 files changed, 12 insertions(+), 21 deletions(-)

diff --git a/dix/getevents.c b/dix/getevents.c
index ca68e42..c05f6bf 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -812,28 +812,19 @@ positionSprite(DeviceIntPtr dev, int mode,
     int old_screenx, old_screeny;
     double val, ret;
 
-    /* scale x&y to screen */
-    if (dev->valuator && dev->valuator->numAxes > 0) {
-        val = *x + x_frac;
-        ret = rescaleValuatorAxis(val, dev->valuator->axes + 0, NULL,
-                                  scr->width);
-        *screenx = round_towards_zero(ret);
-        *screenx_frac = ret - round_towards_zero(ret);
-    } else {
-        *screenx = dev->last.valuators[0];
-        *screenx_frac = dev->last.remainder[0];
-    }
+    if (!dev->valuator || dev->valuator->numAxes < 2)
+        return;
 
-    if (dev->valuator && dev->valuator->numAxes > 1) {
-        val = *y + y_frac;
-        ret = rescaleValuatorAxis(val, dev->valuator->axes + 1, NULL,
-                                  scr->height);
-        *screeny = round_towards_zero(ret);
-        *screeny_frac = ret - round_towards_zero(ret);
-    } else {
-        *screeny = dev->last.valuators[1];
-        *screeny_frac = dev->last.remainder[1];
-    }
+    /* scale x&y to screen */
+    val = *x + x_frac;
+    ret = rescaleValuatorAxis(val, dev->valuator->axes + 0, NULL, scr->width);
+    *screenx = round_towards_zero(ret);
+    *screenx_frac = ret - round_towards_zero(ret);
+
+    val = *y + y_frac;
+    ret = rescaleValuatorAxis(val, dev->valuator->axes + 1, NULL, scr->height);
+    *screeny = round_towards_zero(ret);
+    *screeny_frac = ret - round_towards_zero(ret);
 
     /* Hit the left screen edge? */
     if (*screenx <= 0 && *screenx_frac < 0.0f)
-- 
1.7.5.3



More information about the xorg-devel mailing list