[PATCH 09/12] mi: return the screen from miPointerSetPosition

Peter Hutterer peter.hutterer at who-t.net
Mon Oct 3 22:24:05 PDT 2011


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 <peter.hutterer at who-t.net>
---
 dix/getevents.c |    3 +--
 mi/mipointer.c  |   14 +++++++-------
 mi/mipointer.h  |    2 +-
 3 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/dix/getevents.c b/dix/getevents.c
index 450792b..8b7ffeb 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -833,8 +833,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 670f63b..4901d13 100644
--- a/mi/mipointer.c
+++ b/mi/mipointer.c
@@ -574,7 +574,7 @@ miPointerMoveNoEvent (DeviceIntPtr pDev, ScreenPtr pScreen,
  * @param[in,out] y The y coordinate in screen coordinates (in regards to total
  * desktop size)
  */
-void
+ScreenPtr
 miPointerSetPosition(DeviceIntPtr pDev, int mode, int *x, int *y)
 {
     miPointerScreenPtr	pScreenPriv;
@@ -584,12 +584,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)
     {
@@ -622,11 +622,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;
 }
 
 /**
diff --git a/mi/mipointer.h b/mi/mipointer.h
index c4265f9..35428df 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,
-- 
1.7.6.4



More information about the xorg-devel mailing list