From 3d8faecd1992f77d10c2a073bb10b932224b92a5 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 3 Oct 2011 12:49:49 +1000 Subject: mi: return the screen from miPointerSetPosition miPointerSetPosition may switch screens. Always return the screen the sprite is on instead of relying on callers to call miPointerGetScreen(). Signed-off-by: Peter Hutterer Reviewed-by: Jamey Sharp Reviewed-by: Daniel Stone (cherry picked from commit adb28f7103623fa640a300c4aa495024b343130c) RHEL6: minor conflicts caused by _miPointerSetPosition Conflicts: dix/getevents.c mi/mipointer.c mi/mipointer.h Signed-off-by: Peter Hutterer --- dix/getevents.c | 3 +-- mi/mipointer.c | 30 +++++++++++++++++++++++------- mi/mipointer.h | 2 +- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/dix/getevents.c b/dix/getevents.c index 0d99f38b8..a05b8d20e 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -846,8 +846,7 @@ positionSprite(DeviceIntPtr dev, int mode, ValuatorMask *mask, * screenx back into device co-ordinates. */ isx = trunc(*screenx); isy = trunc(*screeny); - _miPointerSetPosition(dev, mode, &isx, &isy); - scr = miPointerGetScreen(dev); + scr = _miPointerSetPosition(dev, mode, &isx, &isy); if (isx != trunc(*screenx)) { *screenx -= trunc(*screenx) - isx; diff --git a/mi/mipointer.c b/mi/mipointer.c index 867c660b9..e805dfaa7 100644 --- a/mi/mipointer.c +++ b/mi/mipointer.c @@ -487,7 +487,23 @@ miPointerMoveNoEvent (DeviceIntPtr pDev, ScreenPtr pScreen, pPointer->pScreen = pScreen; } -void +/** + * Set the devices' cursor position to the given x/y position. + * + * This function is called during the pointer update path in + * GetPointerEvents and friends (and the same in the xwin DDX). + * + * The coordinates provided are always absolute. The parameter mode whether + * it was relative or absolute movement that landed us at those coordinates. + * + * @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) + */ +ScreenPtr _miPointerSetPosition(DeviceIntPtr pDev, int mode, int *x, int *y) { miPointerScreenPtr pScreenPriv; @@ -497,12 +513,12 @@ _miPointerSetPosition(DeviceIntPtr pDev, int mode, int *x, int *y) miPointerPtr pPointer; if (!pDev || !pDev->coreEvents) - return; + return NULL; pPointer = MIPOINTER(pDev); pScreen = pPointer->pScreen; if (!pScreen) - return; /* called before ready */ + return NULL; /* called before ready */ if (*x < 0 || *x >= pScreen->width || *y < 0 || *y >= pScreen->height) { @@ -535,11 +551,11 @@ _miPointerSetPosition(DeviceIntPtr pDev, int mode, int *x, int *y) if (pScreen->ConstrainCursorHarder) pScreen->ConstrainCursorHarder(pDev, pScreen, mode, x, y); - if (pPointer->x == *x && pPointer->y == *y && - pPointer->pScreen == pScreen) - return; + if (pPointer->x != *x || pPointer->y != *y || + pPointer->pScreen != pScreen) + miPointerMoveNoEvent(pDev, pScreen, *x, *y); - miPointerMoveNoEvent(pDev, pScreen, *x, *y); + return pScreen; } /* ABI hack */ diff --git a/mi/mipointer.h b/mi/mipointer.h index 6b6010cb1..507139518 100644 --- a/mi/mipointer.h +++ b/mi/mipointer.h @@ -131,7 +131,7 @@ extern _X_EXPORT void miPointerGetPosition( /* Moves the cursor to the specified position. May clip the co-ordinates: * x and y are modified in-place. */ -extern _X_EXPORT void _miPointerSetPosition( +extern _X_EXPORT ScreenPtr _miPointerSetPosition( DeviceIntPtr pDev, int mode, int *x, -- cgit v1.2.3