summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2010-12-08 14:52:19 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2010-12-10 10:57:55 +1000
commit0d440a1c6e219cd39dbddd2b7e813c6431aac6ea (patch)
tree4a95636cddb12dadabd3f75e50a2d3edbc48d0de
parent9cf055892dd413932e54b43cc2dfea70bafd525f (diff)
dix: allow for button-only input devices (#21457)
Add a few checks for the existence of a valuator class on the device to avoid null-pointer dereferences for button events from devices without a valuator class. X.Org Bug 21457 <http://bugs.freedesktop.org/show_bug.cgi?id=21457> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Chase Douglas <chase.douglas@canonical.com> Reviewed-by: Daniel Stone <daniel@fooishbar.org>
-rw-r--r--dix/getevents.c36
1 files changed, 21 insertions, 15 deletions
diff --git a/dix/getevents.c b/dix/getevents.c
index 9feb2166b..794df420b 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -767,7 +767,7 @@ moveRelative(DeviceIntPtr dev, int *x, int *y, ValuatorMask *mask)
/* if attached, clip both x and y to the defined limits (usually
* co-ord space limit). If it is attached, we need x/y to go over the
* limits to be able to change screens. */
- if(dev->u.master) {
+ if(dev->u.master && dev->valuator) {
if (valuator_get_mode(dev, 0) == Absolute)
clipAxis(dev, 0, x);
if (valuator_get_mode(dev, 1) == Absolute)
@@ -830,7 +830,7 @@ positionSprite(DeviceIntPtr dev, int *x, int *y, float x_frac, float y_frac,
int old_screenx, old_screeny;
/* scale x&y to screen */
- if (dev->valuator->numAxes > 0) {
+ if (dev->valuator && dev->valuator->numAxes > 0) {
*screenx = rescaleValuatorAxis(*x, x_frac, screenx_frac,
dev->valuator->axes + 0, NULL, scr->width);
} else {
@@ -838,7 +838,7 @@ positionSprite(DeviceIntPtr dev, int *x, int *y, float x_frac, float y_frac,
*screenx_frac = dev->last.remainder[0];
}
- if (dev->valuator->numAxes > 1) {
+ if (dev->valuator && dev->valuator->numAxes > 1) {
*screeny = rescaleValuatorAxis(*y, y_frac, screeny_frac,
dev->valuator->axes + 1, NULL, scr->height);
} else {
@@ -872,18 +872,21 @@ positionSprite(DeviceIntPtr dev, int *x, int *y, float x_frac, float y_frac,
dev->u.master->last.remainder[1] = *screeny_frac;
}
- /* Crossed screen? Scale back to device coordiantes */
- if(*screenx != old_screenx)
+ if (dev->valuator)
{
- scr = miPointerGetScreen(dev);
- *x = rescaleValuatorAxis(*screenx, *screenx_frac, &x_frac, NULL,
- dev->valuator->axes + 0, scr->width);
- }
- if(*screeny != old_screeny)
- {
- scr = miPointerGetScreen(dev);
- *y = rescaleValuatorAxis(*screeny, *screeny_frac, &y_frac, NULL,
- dev->valuator->axes + 1, scr->height);
+ /* Crossed screen? Scale back to device coordiantes */
+ if(*screenx != old_screenx)
+ {
+ scr = miPointerGetScreen(dev);
+ *x = rescaleValuatorAxis(*screenx, *screenx_frac, &x_frac, NULL,
+ dev->valuator->axes + 0, scr->width);
+ }
+ if(*screeny != old_screeny)
+ {
+ scr = miPointerGetScreen(dev);
+ *y = rescaleValuatorAxis(*screeny, *screeny_frac, &y_frac, NULL,
+ dev->valuator->axes + 1, scr->height);
+ }
}
/* dropy x/y (device coordinates) back into valuators for next event */
@@ -904,6 +907,9 @@ positionSprite(DeviceIntPtr dev, int *x, int *y, float x_frac, float y_frac,
static void
updateHistory(DeviceIntPtr dev, ValuatorMask *mask, CARD32 ms)
{
+ if (!dev->valuator)
+ return;
+
updateMotionHistory(dev, ms, mask, dev->last.valuators);
if (dev->u.master)
{
@@ -1104,7 +1110,7 @@ GetPointerEvents(EventList *events, DeviceIntPtr pDev, int type, int buttons,
if (!pDev->enabled)
return 0;
- if (!scr || !pDev->valuator)
+ if (!scr)
return 0;
switch (type)