summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stone <daniel@fooishbar.org>2011-03-02 16:50:55 +0000
committerPeter Hutterer <peter.hutterer@who-t.net>2011-09-29 12:24:34 +1000
commit51437995a5041a8c53c33b508b1607c78a5fa463 (patch)
treee65571beee2afbd2dd85a09610ec93ba44bf3b5d
parent4c364a312daf2b743a0a60b9907f671804a1b1b6 (diff)
Input: Don't call positionSprite for non-pointer devices
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@fooishbar.org> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--dix/getevents.c33
1 files changed, 12 insertions, 21 deletions
diff --git a/dix/getevents.c b/dix/getevents.c
index 2c5138809..94da143e3 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -792,28 +792,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 = trunc(ret);
- *screenx_frac = ret - trunc(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 = trunc(ret);
- *screeny_frac = ret - trunc(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 = trunc(ret);
+ *screenx_frac = ret - trunc(ret);
+
+ val = *y + y_frac;
+ ret = rescaleValuatorAxis(val, dev->valuator->axes + 1, NULL, scr->height);
+ *screeny = trunc(ret);
+ *screeny_frac = ret - trunc(ret);
/* Hit the left screen edge? */
if (*screenx <= 0 && *screenx_frac < 0.0f)