summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stone <daniel@fooishbar.org>2011-03-02 17:18:48 +0000
committerPeter Hutterer <peter.hutterer@who-t.net>2011-09-29 12:24:34 +1000
commit3b7fb0f68dc0d40c968c2cfc9bb74b1d0fb48bc8 (patch)
treedd83f0afaafb359a05562bfde95ce2b2864b8ab1
parent629a575261c08ca67324fea4c975636a1a95dc75 (diff)
Input: Modify mask in-place in positionSprite
Instead of taking pointers to x and y values to modify in positionSprite, just modify the mask (as well as dev->last) in place. Signed-off-by: Daniel Stone <daniel@fooishbar.org> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--dix/getevents.c67
1 files changed, 30 insertions, 37 deletions
diff --git a/dix/getevents.c b/dix/getevents.c
index a9409b4cc..ec79fcffe 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -774,26 +774,34 @@ accelPointer(DeviceIntPtr dev, ValuatorMask* valuators, CARD32 ms)
*
* @param dev The device to be moved.
* @param mode Movement mode (Absolute or Relative)
- * @param x Pointer to current x-axis value, may be modified.
- * @param y Pointer to current y-axis value, may be modified.
* @param scr Screen the device's sprite is currently on.
+ * @param mask Mask of axis values for this event
* @param screenx Screen x coordinate the sprite is on after the update.
* @param screeny Screen y coordinate the sprite is on after the update.
*/
static void
-positionSprite(DeviceIntPtr dev, int mode, double *x, double *y, ScreenPtr scr,
+positionSprite(DeviceIntPtr dev, int mode, ScreenPtr scr, ValuatorMask *mask,
double *screenx, double *screeny)
{
int isx, isy; /* screen {x, y}, in int */
+ double x, y;
if (!dev->valuator || dev->valuator->numAxes < 2)
return;
+ if (valuator_mask_isset(mask, 0))
+ x = valuator_mask_get_double(mask, 0);
+ else
+ x = dev->last.valuators[0] + dev->last.remainder[0];
+ if (valuator_mask_isset(mask, 1))
+ y = valuator_mask_get_double(mask, 1);
+ else
+ y = dev->last.valuators[1] + dev->last.remainder[1];
+
/* scale x&y to screen */
- *screenx = rescaleValuatorAxis(*x, dev->valuator->axes + 0, NULL,
+ *screenx = rescaleValuatorAxis(x, dev->valuator->axes + 0, NULL,
scr->width);
-
- *screeny = rescaleValuatorAxis(*y, dev->valuator->axes + 1, NULL,
+ *screeny = rescaleValuatorAxis(y, dev->valuator->axes + 1, NULL,
scr->height);
/* miPointerSetPosition takes care of crossing screens for us, as well as
@@ -807,14 +815,14 @@ positionSprite(DeviceIntPtr dev, int mode, double *x, double *y, ScreenPtr scr,
if (isx != trunc(*screenx))
{
*screenx -= trunc(*screenx) - isx;
- *x = rescaleValuatorAxis(*screenx, NULL, dev->valuator->axes + 0,
- scr->width);
+ x = rescaleValuatorAxis(*screenx, NULL, dev->valuator->axes + 0,
+ scr->width);
}
if (isy != trunc(*screeny))
{
*screeny -= trunc(*screeny) - isy;
- *y = rescaleValuatorAxis(*screeny, NULL, dev->valuator->axes + 1,
- scr->height);
+ y = rescaleValuatorAxis(*screeny, NULL, dev->valuator->axes + 1,
+ scr->height);
}
/* Update the MD's co-ordinates, which are always in screen space. */
@@ -827,10 +835,15 @@ positionSprite(DeviceIntPtr dev, int mode, double *x, double *y, ScreenPtr scr,
}
/* dropy x/y (device coordinates) back into valuators for next event */
- dev->last.valuators[0] = trunc(*x);
- dev->last.valuators[1] = trunc(*y);
- dev->last.remainder[0] = *x - trunc(*x);
- dev->last.remainder[1] = *y - trunc(*y);
+ dev->last.valuators[0] = trunc(x);
+ dev->last.valuators[1] = trunc(y);
+ dev->last.remainder[0] = x - trunc(x);
+ dev->last.remainder[1] = y - trunc(y);
+
+ if (valuator_mask_isset(mask, 0))
+ valuator_mask_set_double(mask, 0, x);
+ if (valuator_mask_isset(mask, 1))
+ valuator_mask_set_double(mask, 1, y);
}
/**
@@ -1076,8 +1089,7 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, int buttons
CARD32 ms;
DeviceEvent *event;
RawDeviceEvent *raw;
- double x = 0.0, y = 0.0; /* device coords */
- double screenx = 0.0, screeny = 0.0; /* screen coords */
+ double screenx = 0.0, screeny = 0.0;
ScreenPtr scr = miPointerGetScreen(pDev);
ValuatorMask mask;
@@ -1154,29 +1166,10 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, int buttons
set_raw_valuators(raw, &mask, raw->valuators.data,
raw->valuators.data_frac);
- if (valuator_mask_isset(&mask, 0))
- x = valuator_mask_get_double(&mask, 0);
- else
- x = pDev->last.valuators[0] + pDev->last.remainder[0];
- if (valuator_mask_isset(&mask, 1))
- y = valuator_mask_get_double(&mask, 1);
- else
- y = pDev->last.valuators[1] + pDev->last.remainder[1];
-
- positionSprite(pDev, (flags & POINTER_ABSOLUTE) ? Absolute : Relative,
- &x, &y, scr, &screenx, &screeny);
- if (valuator_mask_isset(&mask, 0))
- valuator_mask_set_double(&mask, 0, x);
- if (valuator_mask_isset(&mask, 1))
- valuator_mask_set_double(&mask, 1, y);
+ positionSprite(pDev, (flags & POINTER_ABSOLUTE) ? Absolute : Relative, scr,
+ &mask, &screenx, &screeny);
updateHistory(pDev, &mask, ms);
- /* Update the valuators with the true value sent to the client*/
- if (valuator_mask_isset(&mask, 0))
- valuator_mask_set(&mask, 0, x);
- if (valuator_mask_isset(&mask, 1))
- valuator_mask_set(&mask, 1, y);
-
clipValuators(pDev, &mask);
event = &events->device_event;