[PATCH 09/20] xfree86: replace two inputInfo.pointer uses with device loops.

Peter Hutterer peter.hutterer at who-t.net
Thu Feb 17 19:52:16 PST 2011


Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 hw/xfree86/common/xf86RandR.c  |   37 ++++++++++++++++++++++++++++++-------
 hw/xfree86/modes/xf86RandR12.c |   36 +++++++++++++++++++++++++++++-------
 2 files changed, 59 insertions(+), 14 deletions(-)

diff --git a/hw/xfree86/common/xf86RandR.c b/hw/xfree86/common/xf86RandR.c
index d7ffff4..4663d03 100644
--- a/hw/xfree86/common/xf86RandR.c
+++ b/hw/xfree86/common/xf86RandR.c
@@ -242,11 +242,20 @@ xf86RandRSetConfig (ScreenPtr		pScreen,
     ScrnInfoPtr		    scrp = XF86SCRNINFO(pScreen);
     XF86RandRInfoPtr	    randrp = XF86RANDRINFO(pScreen);
     DisplayModePtr	    mode;
-    int			    px, py;
+    int			    pos[MAXDEVICES][2];
     Bool		    useVirtual = FALSE;
     Rotation		    oldRotation = randrp->rotation;
+    DeviceIntPtr	    dev;
+    Bool		    view_adjusted = FALSE;
+
+    for (dev = inputInfo.devices; dev; dev = dev->next)
+    {
+	if (!IsMaster(dev) && !IsFloating(dev))
+		continue;
+
+	miPointerGetPosition(dev, &pos[dev->id][0], &pos[dev->id][1]);
+    }
 
-    miPointerGetPosition(inputInfo.pointer, &px, &py);
     for (mode = scrp->modes; ; mode = mode->next)
     {
 	if (mode->HDisplay == pSize->width &&
@@ -303,17 +312,31 @@ xf86RandRSetConfig (ScreenPtr		pScreen,
 	}
 	return FALSE;
     }
+
     /*
      * Move the cursor back where it belongs; SwitchMode repositions it
+     * FIXME: duplicated code, see modes/xf86RandR12.c
      */
-    if (pScreen == miPointerCurrentScreen ())
+    for (dev = inputInfo.devices; dev; dev = dev->next)
     {
-	px = (px >= pScreen->width ? (pScreen->width - 1) : px);
-	py = (py >= pScreen->height ? (pScreen->height - 1) : py);
+	if (!IsMaster(dev) && !IsFloating(dev))
+		continue;
 
-        xf86SetViewport(pScreen, px, py);
+	if (pScreen == miPointerGetScreen(dev)) {
+	    int px = pos[dev->id][0];
+	    int py = pos[dev->id][1];
 
-        (*pScreen->SetCursorPosition) (inputInfo.pointer, pScreen, px, py, FALSE);
+	    px = (px >= pScreen->width ? (pScreen->width - 1) : px);
+	    py = (py >= pScreen->height ? (pScreen->height - 1) : py);
+
+	    /* Setting the viewpoint makes only sense on one device */
+	    if (!view_adjusted && IsMaster(dev)) {
+		xf86SetViewport(pScreen, px, py);
+		view_adjusted = TRUE;
+	    }
+
+	    (*pScreen->SetCursorPosition) (dev, pScreen, px, py, FALSE);
+	}
     }
 
     return TRUE;
diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c
index 407bf35..82d180b 100644
--- a/hw/xfree86/modes/xf86RandR12.c
+++ b/hw/xfree86/modes/xf86RandR12.c
@@ -584,10 +584,12 @@ xf86RandR12SetConfig (ScreenPtr		pScreen,
     ScrnInfoPtr		scrp = XF86SCRNINFO(pScreen);
     XF86RandRInfoPtr	randrp = XF86RANDRINFO(pScreen);
     DisplayModePtr	mode;
-    int			px, py;
+    int			pos[MAXDEVICES][2];
     Bool		useVirtual = FALSE;
     int			maxX = 0, maxY = 0;
     Rotation		oldRotation = randrp->rotation;
+    DeviceIntPtr	dev;
+    Bool		view_adjusted = FALSE;
 
     randrp->rotation = rotation;
 
@@ -597,7 +599,14 @@ xf86RandR12SetConfig (ScreenPtr		pScreen,
 	randrp->virtualY = scrp->virtualY;
     }
 
-    miPointerGetPosition (inputInfo.pointer, &px, &py);
+    for (dev = inputInfo.devices; dev; dev = dev->next)
+    {
+	if (!IsMaster(dev) && !IsFloating(dev))
+		continue;
+
+	miPointerGetPosition(dev, &pos[dev->id][0], &pos[dev->id][1]);
+    }
+
     for (mode = scrp->modes; ; mode = mode->next)
     {
 	if (randrp->maxX == 0 || randrp->maxY == 0)
@@ -643,15 +652,28 @@ xf86RandR12SetConfig (ScreenPtr		pScreen,
 
     /*
      * Move the cursor back where it belongs; SwitchMode repositions it
+     * FIXME: duplicated code, see modes/xf86RandR12.c
      */
-    if (pScreen == miPointerGetScreen(inputInfo.pointer))
+    for (dev = inputInfo.devices; dev; dev = dev->next)
     {
-        px = (px >= pScreen->width ? (pScreen->width - 1) : px);
-        py = (py >= pScreen->height ? (pScreen->height - 1) : py);
+	if (!IsMaster(dev) && !IsFloating(dev))
+		continue;
 
-	xf86SetViewport(pScreen, px, py);
+	if (pScreen == miPointerGetScreen(dev)) {
+	    int px = pos[dev->id][0];
+	    int py = pos[dev->id][1];
 
-	(*pScreen->SetCursorPosition) (inputInfo.pointer, pScreen, px, py, FALSE);
+	    px = (px >= pScreen->width ? (pScreen->width - 1) : px);
+	    py = (py >= pScreen->height ? (pScreen->height - 1) : py);
+
+	    /* Setting the viewpoint makes only sense on one device */
+	    if (!view_adjusted && IsMaster(dev)) {
+		xf86SetViewport(pScreen, px, py);
+		view_adjusted = TRUE;
+	    }
+
+	    (*pScreen->SetCursorPosition) (dev, pScreen, px, py, FALSE);
+	}
     }
 
     return TRUE;
-- 
1.7.4



More information about the xorg-devel mailing list