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

Daniel Stone daniel at fooishbar.org
Fri Dec 17 09:13:29 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>
Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
---
 dix/events.c    |   18 +++++-------------
 include/input.h |    1 +
 2 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/dix/events.c b/dix/events.c
index 4aa71c1..8e3e1d3 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,7 @@ ComputeFreezes(void)
 
 	syncEvents.replayDev = (DeviceIntPtr)NULL;
 
-        w = XYToWindow(replayDev, event->root_x, event->root_y);
+        w = XYToWindow(pSprite, event->root_x, event->root_y);
         if (!CheckDeviceGrabs(replayDev, event, syncEvents.replayWin))
         {
             if (replayDev->focus && !IsPointerEvent((InternalEvent*)event))
@@ -2564,16 +2558,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 = RootWindow(pDev)->firstChild;
+    pWin = pSprite->spriteTrace[0]->firstChild;
     while (pWin)
     {
 	if ((pWin->mapped) &&
@@ -2785,7 +2777,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 31fdc52..ef7ef04 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);
 
 /* Implemented by the DDX. */
 extern _X_EXPORT int NewInputDeviceRequest(
-- 
1.7.2.3



More information about the xorg-devel mailing list