[PATCH v2 16/28] Input: Remove x and y from moveAbsolute/moveRelative
Daniel Stone
daniel at fooishbar.org
Thu Jun 9 10:17:24 PDT 2011
Both these functions modify the mask and
pDev->last.{valuators,remainder} in-place now, so there's no need to
pass in pointers to local x and y values.
Signed-off-by: Daniel Stone <daniel at fooishbar.org>
Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
---
dix/getevents.c | 42 ++++++++++++++++++++----------------------
1 files changed, 20 insertions(+), 22 deletions(-)
v2: Get x and y from the mask if we can, else fall back to DeviceIntRec::last.
diff --git a/dix/getevents.c b/dix/getevents.c
index 87a84d2..3b81eb2 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -714,12 +714,10 @@ UpdateFromMaster(InternalEvent* events, DeviceIntPtr dev, int type, int *num_eve
* Move the device's pointer to the position given in the valuators.
*
* @param dev The device whose pointer is to be moved.
- * @param x Returns the x position of the pointer after the move.
- * @param y Returns the y position of the pointer after the move.
* @param mask Valuator data for this event.
*/
static void
-moveAbsolute(DeviceIntPtr dev, int *x_out, int *y_out, ValuatorMask *mask)
+moveAbsolute(DeviceIntPtr dev, ValuatorMask *mask)
{
int i;
@@ -735,21 +733,16 @@ moveAbsolute(DeviceIntPtr dev, int *x_out, int *y_out, ValuatorMask *mask)
dev->last.remainder[i] = val - trunc(val);
valuator_mask_set_double(mask, i, val);
}
-
- *x_out = dev->last.valuators[0];
- *y_out = dev->last.valuators[1];
}
/**
* Move the device's pointer by the values given in @valuators.
*
* @param dev The device whose pointer is to be moved.
- * @param x Returns the x position of the pointer after the move.
- * @param y Returns the y position of the pointer after the move.
* @param mask Valuator data for this event.
*/
static void
-moveRelative(DeviceIntPtr dev, int *x_out, int *y_out, ValuatorMask *mask)
+moveRelative(DeviceIntPtr dev, ValuatorMask *mask)
{
int i;
Bool clip_xy = IsMaster(dev) || !IsFloating(dev);
@@ -771,9 +764,6 @@ moveRelative(DeviceIntPtr dev, int *x_out, int *y_out, ValuatorMask *mask)
dev->last.remainder[i] = val - trunc(val);
valuator_mask_set_double(mask, i, val);
}
-
- *x_out = dev->last.valuators[0];
- *y_out = dev->last.valuators[1];
}
/**
@@ -1198,22 +1188,30 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, int buttons
}
transformAbsolute(pDev, &mask);
- moveAbsolute(pDev, &x, &y, &mask);
+ moveAbsolute(pDev, &mask);
} else {
if (flags & POINTER_ACCELERATE)
accelPointer(pDev, &mask, ms);
- moveRelative(pDev, &x, &y, &mask);
+ moveRelative(pDev, &mask);
}
- if (valuator_mask_isset(&mask, 0))
- {
- x_frac = valuator_mask_get_double(&mask, 0);
- x_frac -= trunc(x_frac);
+ if (valuator_mask_isset(&mask, 0)) {
+ double tmp = valuator_mask_get_double(&mask, 0);
+ x = trunc(tmp);
+ x_frac = tmp - x;
}
- if (valuator_mask_isset(&mask, 1))
- {
- y_frac = valuator_mask_get_double(&mask, 1);
- y_frac -= trunc(y_frac);
+ else {
+ x = pDev->last.valuators[0];
+ x_frac = pDev->last.remainder[0];
+ }
+ if (valuator_mask_isset(&mask, 1)) {
+ double tmp = valuator_mask_get_double(&mask, 1);
+ y = trunc(tmp);
+ y_frac = tmp - y;
+ }
+ else {
+ y = pDev->last.valuators[1];
+ y_frac = pDev->last.remainder[1];
}
set_raw_valuators(raw, &mask, raw->valuators.data,
--
1.7.5.3
More information about the xorg-devel
mailing list