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 /mi | |
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 'mi')
-rw-r--r-- | mi/mipointer.c | 47 | ||||
-rw-r--r-- | mi/mipointer.h | 4 |
2 files changed, 31 insertions, 20 deletions
diff --git a/mi/mipointer.c b/mi/mipointer.c index 4901d139b..55e4081f2 100644 --- a/mi/mipointer.c +++ b/mi/mipointer.c @@ -569,17 +569,16 @@ miPointerMoveNoEvent (DeviceIntPtr pDev, ScreenPtr pScreen, * * @param pDev The device to move * @param mode Movement mode (Absolute or Relative) - * @param[in,out] x The x coordinate in screen coordinates (in regards to total - * desktop size) - * @param[in,out] y The y coordinate in screen coordinates (in regards to total - * desktop size) + * @param[in,out] screenx The x coordinate in screen coordinates + * @param[in,out] screeny The y coordinate in screen coordinates */ ScreenPtr -miPointerSetPosition(DeviceIntPtr pDev, int mode, int *x, int *y) +miPointerSetPosition(DeviceIntPtr pDev, int mode, double *screenx, double *screeny) { miPointerScreenPtr pScreenPriv; ScreenPtr pScreen; ScreenPtr newScreen; + int x, y; miPointerPtr pPointer; @@ -591,13 +590,16 @@ miPointerSetPosition(DeviceIntPtr pDev, int mode, int *x, int *y) if (!pScreen) return NULL; /* called before ready */ - if (*x < 0 || *x >= pScreen->width || *y < 0 || *y >= pScreen->height) + x = trunc(*screenx); + y = trunc(*screeny); + + if (x < 0 || x >= pScreen->width || y < 0 || y >= pScreen->height) { pScreenPriv = GetScreenPrivate (pScreen); if (!pPointer->confined) { newScreen = pScreen; - (*pScreenPriv->screenFuncs->CursorOffScreen) (&newScreen, x, y); + (*pScreenPriv->screenFuncs->CursorOffScreen) (&newScreen, &x, &y); if (newScreen != pScreen) { pScreen = newScreen; @@ -610,21 +612,30 @@ miPointerSetPosition(DeviceIntPtr pDev, int mode, int *x, int *y) } } /* Constrain the sprite to the current limits. */ - if (*x < pPointer->limits.x1) - *x = pPointer->limits.x1; - if (*x >= pPointer->limits.x2) - *x = pPointer->limits.x2 - 1; - if (*y < pPointer->limits.y1) - *y = pPointer->limits.y1; - if (*y >= pPointer->limits.y2) - *y = pPointer->limits.y2 - 1; + if (x < pPointer->limits.x1) + x = pPointer->limits.x1; + if (x >= pPointer->limits.x2) + x = pPointer->limits.x2 - 1; + if (y < pPointer->limits.y1) + y = pPointer->limits.y1; + if (y >= pPointer->limits.y2) + y = pPointer->limits.y2 - 1; if (pScreen->ConstrainCursorHarder) - pScreen->ConstrainCursorHarder(pDev, pScreen, mode, x, y); + pScreen->ConstrainCursorHarder(pDev, pScreen, mode, &x, &y); - if (pPointer->x != *x || pPointer->y != *y || + if (pPointer->x != x || pPointer->y != y || pPointer->pScreen != pScreen) - miPointerMoveNoEvent(pDev, pScreen, *x, *y); + miPointerMoveNoEvent(pDev, pScreen, x, y); + + /* In the event we actually change screen or we get confined, we just + * drop the float component on the floor + * FIXME: only drop remainder for ConstrainCursorHarder, not for screen + * crossings */ + if (x != trunc(*screenx)) + *screenx = x; + if (y != trunc(*screeny)) + *screeny = y; return pScreen; } diff --git a/mi/mipointer.h b/mi/mipointer.h index 35428df32..45abb5b56 100644 --- a/mi/mipointer.h +++ b/mi/mipointer.h @@ -134,8 +134,8 @@ extern _X_EXPORT void miPointerGetPosition( extern _X_EXPORT ScreenPtr miPointerSetPosition( DeviceIntPtr pDev, int mode, - int *x, - int *y); + double *x, + double *y); extern _X_EXPORT void miPointerUpdateSprite( DeviceIntPtr pDev); |