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>
This commit is contained in:
parent
629a575261
commit
3b7fb0f68d
|
@ -774,26 +774,34 @@ accelPointer(DeviceIntPtr dev, ValuatorMask* valuators, CARD32 ms)
|
||||||
*
|
*
|
||||||
* @param dev The device to be moved.
|
* @param dev The device to be moved.
|
||||||
* @param mode Movement mode (Absolute or Relative)
|
* @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 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 screenx Screen x coordinate the sprite is on after the update.
|
||||||
* @param screeny Screen y coordinate the sprite is on after the update.
|
* @param screeny Screen y coordinate the sprite is on after the update.
|
||||||
*/
|
*/
|
||||||
static void
|
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)
|
double *screenx, double *screeny)
|
||||||
{
|
{
|
||||||
int isx, isy; /* screen {x, y}, in int */
|
int isx, isy; /* screen {x, y}, in int */
|
||||||
|
double x, y;
|
||||||
|
|
||||||
if (!dev->valuator || dev->valuator->numAxes < 2)
|
if (!dev->valuator || dev->valuator->numAxes < 2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* scale x&y to screen */
|
if (valuator_mask_isset(mask, 0))
|
||||||
*screenx = rescaleValuatorAxis(*x, dev->valuator->axes + 0, NULL,
|
x = valuator_mask_get_double(mask, 0);
|
||||||
scr->width);
|
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];
|
||||||
|
|
||||||
*screeny = rescaleValuatorAxis(*y, dev->valuator->axes + 1, NULL,
|
/* scale x&y to screen */
|
||||||
|
*screenx = rescaleValuatorAxis(x, dev->valuator->axes + 0, NULL,
|
||||||
|
scr->width);
|
||||||
|
*screeny = rescaleValuatorAxis(y, dev->valuator->axes + 1, NULL,
|
||||||
scr->height);
|
scr->height);
|
||||||
|
|
||||||
/* miPointerSetPosition takes care of crossing screens for us, as well as
|
/* 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))
|
if (isx != trunc(*screenx))
|
||||||
{
|
{
|
||||||
*screenx -= trunc(*screenx) - isx;
|
*screenx -= trunc(*screenx) - isx;
|
||||||
*x = rescaleValuatorAxis(*screenx, NULL, dev->valuator->axes + 0,
|
x = rescaleValuatorAxis(*screenx, NULL, dev->valuator->axes + 0,
|
||||||
scr->width);
|
scr->width);
|
||||||
}
|
}
|
||||||
if (isy != trunc(*screeny))
|
if (isy != trunc(*screeny))
|
||||||
{
|
{
|
||||||
*screeny -= trunc(*screeny) - isy;
|
*screeny -= trunc(*screeny) - isy;
|
||||||
*y = rescaleValuatorAxis(*screeny, NULL, dev->valuator->axes + 1,
|
y = rescaleValuatorAxis(*screeny, NULL, dev->valuator->axes + 1,
|
||||||
scr->height);
|
scr->height);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update the MD's co-ordinates, which are always in screen space. */
|
/* 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 */
|
/* dropy x/y (device coordinates) back into valuators for next event */
|
||||||
dev->last.valuators[0] = trunc(*x);
|
dev->last.valuators[0] = trunc(x);
|
||||||
dev->last.valuators[1] = trunc(*y);
|
dev->last.valuators[1] = trunc(y);
|
||||||
dev->last.remainder[0] = *x - trunc(*x);
|
dev->last.remainder[0] = x - trunc(x);
|
||||||
dev->last.remainder[1] = *y - trunc(*y);
|
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;
|
CARD32 ms;
|
||||||
DeviceEvent *event;
|
DeviceEvent *event;
|
||||||
RawDeviceEvent *raw;
|
RawDeviceEvent *raw;
|
||||||
double x = 0.0, y = 0.0; /* device coords */
|
double screenx = 0.0, screeny = 0.0;
|
||||||
double screenx = 0.0, screeny = 0.0; /* screen coords */
|
|
||||||
ScreenPtr scr = miPointerGetScreen(pDev);
|
ScreenPtr scr = miPointerGetScreen(pDev);
|
||||||
ValuatorMask mask;
|
ValuatorMask mask;
|
||||||
|
|
||||||
|
@ -1154,29 +1166,10 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, int buttons
|
||||||
set_raw_valuators(raw, &mask, raw->valuators.data,
|
set_raw_valuators(raw, &mask, raw->valuators.data,
|
||||||
raw->valuators.data_frac);
|
raw->valuators.data_frac);
|
||||||
|
|
||||||
if (valuator_mask_isset(&mask, 0))
|
positionSprite(pDev, (flags & POINTER_ABSOLUTE) ? Absolute : Relative, scr,
|
||||||
x = valuator_mask_get_double(&mask, 0);
|
&mask, &screenx, &screeny);
|
||||||
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);
|
|
||||||
updateHistory(pDev, &mask, ms);
|
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);
|
clipValuators(pDev, &mask);
|
||||||
|
|
||||||
event = &events->device_event;
|
event = &events->device_event;
|
||||||
|
|
Loading…
Reference in New Issue