diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2011-10-03 13:10:53 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2011-10-11 12:06:56 +1000 |
commit | 3b36fd1b49030ead44358945f62e5abe7f4609ce (patch) | |
tree | d35339e0b8f872ec68e5ae31097efb94ed136791 /dix/getevents.c | |
parent | 81cfe44b1ed0de84ad1941fe2ca74bebef3fc58d (diff) |
mi: switch miPointerSetPosition to take doubles
Don't switch between doubles and ints in the caller, instead take doubles in
miPointerSetPosition and do the conversion there. For full feature we should
change everything down from here for doubles too.
Functional change: previously we'd restore the remainder regardless of
screen switching/confinement (despite what the comment said). Now,
screen changing or cursor constraints will cause the remainder be clipped
off. This should happen for cursor constraints but arguably not for screen
crossing.
This also corrects a currently wrong comment about miPointerSetPosition's
input coordinates.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Diffstat (limited to 'dix/getevents.c')
-rw-r--r-- | dix/getevents.c | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/dix/getevents.c b/dix/getevents.c index bb1f5c96d..ade3ca132 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -805,8 +805,8 @@ static ScreenPtr positionSprite(DeviceIntPtr dev, int mode, ValuatorMask *mask, double *screenx, double *screeny) { - int isx, isy; /* screen {x, y}, in int */ double x, y; + double tmpx, tmpy; ScreenPtr scr = miPointerGetScreen(dev); if (!dev->valuator || dev->valuator->numAxes < 2) @@ -827,25 +827,22 @@ positionSprite(DeviceIntPtr dev, int mode, ValuatorMask *mask, *screeny = rescaleValuatorAxis(y, dev->valuator->axes + 1, NULL, scr->height); + tmpx = *screenx; + tmpy = *screeny; /* miPointerSetPosition takes care of crossing screens for us, as well as - * clipping to the current screen. In the event we actually change screen, - * we just drop the float component on the floor, then convert from - * screenx back into device co-ordinates. */ - isx = trunc(*screenx); - isy = trunc(*screeny); - scr = miPointerSetPosition(dev, mode, &isx, &isy); - if (isx != trunc(*screenx)) - { - *screenx -= trunc(*screenx) - isx; + * clipping to the current screen. */ + scr = miPointerSetPosition(dev, mode, screenx, screeny); + + /* If we were constrained, rescale x/y from the screen coordinates so + * the device valuators reflect the correct position. For screen + * crossing this doesn't matter much, the coords would be 0 or max. + */ + if (tmpx != *screenx) x = rescaleValuatorAxis(*screenx, NULL, dev->valuator->axes + 0, scr->width); - } - if (isy != trunc(*screeny)) - { - *screeny -= trunc(*screeny) - isy; + if (tmpy != *screeny) y = rescaleValuatorAxis(*screeny, NULL, dev->valuator->axes + 1, scr->height); - } /* Update the MD's co-ordinates, which are always in screen space. */ if (!IsMaster(dev) || !IsFloating(dev)) { |