[PATCH xserver 09/17] Input: Pass sprite instead of device to XYToWindow, make non-static

Daniel Stone daniel at fooishbar.org
Tue Dec 28 09:58:00 PST 2010


XYToWindow calculates the position of the cursor and updates the sprite
trace, but does nothing else with the device.  Pass a SpritePtr instead
so we can update an alternate focus instead of hardcoding the device's
sprite.  Also make this function non-static, so we can use it elsewhere.

Signed-off-by: Daniel Stone <daniel at fooishbar.org>
Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
Reviewed-by: Chase Douglas <chase.douglas at canonical.com>
---
 dix/events.c    |   19 ++++++-------------
 include/input.h |    1 +
 2 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/dix/events.c b/dix/events.c
index df59a4e..29033e2 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -332,12 +332,6 @@ IsMaster(DeviceIntPtr dev)
     return dev->type == MASTER_POINTER || dev->type == MASTER_KEYBOARD;
 }
 
-static WindowPtr XYToWindow(
-    DeviceIntPtr pDev,
-    int x,
-    int y
-);
-
 /**
  * Max event opcode.
  */
@@ -1290,7 +1284,8 @@ ComputeFreezes(void)
 
 	syncEvents.replayDev = (DeviceIntPtr)NULL;
 
-        w = XYToWindow(replayDev, event->root_x, event->root_y);
+        w = XYToWindow(replayDev->spriteInfo->sprite,
+                       event->root_x, event->root_y);
         if (!CheckDeviceGrabs(replayDev, event, syncEvents.replayWin))
         {
             if (replayDev->focus && !IsPointerEvent((InternalEvent*)event))
@@ -2553,16 +2548,14 @@ PointInBorderSize(WindowPtr pWin, int x, int y)
  *
  * @returns the window at the given coordinates.
  */
-static WindowPtr
-XYToWindow(DeviceIntPtr pDev, int x, int y)
+WindowPtr
+XYToWindow(SpritePtr pSprite, int x, int y)
 {
     WindowPtr  pWin;
     BoxRec		box;
-    SpritePtr pSprite;
 
-    pSprite = pDev->spriteInfo->sprite;
     pSprite->spriteTraceGood = 1;	/* root window still there */
-    pWin = GetCurrentRootWindow(pDev)->firstChild;
+    pWin = RootWindow(pSprite)->firstChild;
     while (pWin)
     {
 	if ((pWin->mapped) &&
@@ -2775,7 +2768,7 @@ CheckMotion(DeviceEvent *ev, DeviceIntPtr pDev)
 	ev->root_y = pSprite->hot.y;
     }
 
-    newSpriteWin = XYToWindow(pDev, pSprite->hot.x, pSprite->hot.y);
+    newSpriteWin = XYToWindow(pSprite, pSprite->hot.x, pSprite->hot.y);
 
     if (newSpriteWin != prevSpriteWin)
     {
diff --git a/include/input.h b/include/input.h
index a20f8a0..c1db544 100644
--- a/include/input.h
+++ b/include/input.h
@@ -533,6 +533,7 @@ void FixUpEventFromWindow(SpritePtr pSprite,
                           WindowPtr pWin,
                           Window child,
                           Bool calcChild);
+extern WindowPtr XYToWindow(SpritePtr pSprite, int x, int y);
 extern int EventIsDeliverable(DeviceIntPtr dev, InternalEvent* event,
                               WindowPtr win);
 /**
-- 
1.7.2.3



More information about the xorg-devel mailing list