[PATCH 3/4] Move replay-window check from ComputeFreezes to CheckDeviceGrabs.

Jamey Sharp jamey at minilop.net
Wed Aug 4 14:23:04 PDT 2010


This just simplifies ComputeFreezes, eliminating some duplicated code
and a goto.

Signed-off-by: Jamey Sharp <jamey at minilop.net>
Cc: Peter Hutterer <peter.hutterer at who-t.net>
---
 dix/events.c  |   43 ++++++++++++++++++-------------------------
 include/dix.h |    2 +-
 2 files changed, 19 insertions(+), 26 deletions(-)

diff --git a/dix/events.c b/dix/events.c
index 51a04d5..89619b3 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -1276,7 +1276,6 @@ static void
 ComputeFreezes(void)
 {
     DeviceIntPtr replayDev = syncEvents.replayDev;
-    int i;
     WindowPtr w;
     GrabPtr grab;
     DeviceIntPtr dev;
@@ -1294,29 +1293,15 @@ ComputeFreezes(void)
 	syncEvents.replayDev = (DeviceIntPtr)NULL;
 
         w = XYToWindow(replayDev, event->root_x, event->root_y);
-	for (i = 0; i < replayDev->spriteInfo->sprite->spriteTraceGood; i++)
-	{
-	    if (syncEvents.replayWin ==
-		replayDev->spriteInfo->sprite->spriteTrace[i])
-	    {
-		if (!CheckDeviceGrabs(replayDev, event, i+1)) {
-		    if (replayDev->focus && !IsPointerEvent((InternalEvent*)event))
-			DeliverFocusedEvent(replayDev, (InternalEvent*)event, w);
-		    else
-			DeliverDeviceEvents(w, (InternalEvent*)event, NullGrab,
-                                            NullWindow, replayDev);
-		}
-		goto playmore;
-	    }
-	}
-	/* must not still be in the same stack */
-	if (replayDev->focus && !IsPointerEvent((InternalEvent*)event))
-	    DeliverFocusedEvent(replayDev, (InternalEvent*)event, w);
-	else
-	    DeliverDeviceEvents(w, (InternalEvent*)event, NullGrab,
-                                NullWindow, replayDev);
+        if (!CheckDeviceGrabs(replayDev, event, syncEvents.replayWin))
+        {
+            if (replayDev->focus && !IsPointerEvent((InternalEvent*)event))
+                DeliverFocusedEvent(replayDev, (InternalEvent*)event, w);
+            else
+                DeliverDeviceEvents(w, (InternalEvent*)event, NullGrab,
+                                    NullWindow, replayDev);
+        }
     }
-playmore:
     for (dev = inputInfo.devices; dev; dev = dev->next)
     {
 	if (!dev->deviceGrab.sync.frozen)
@@ -3611,7 +3596,7 @@ CheckPassiveGrabsOnWindow(
 */
 
 Bool
-CheckDeviceGrabs(DeviceIntPtr device, DeviceEvent *event, int checkFirst)
+CheckDeviceGrabs(DeviceIntPtr device, DeviceEvent *event, WindowPtr ancestor)
 {
     int i;
     WindowPtr pWin = NULL;
@@ -3629,7 +3614,15 @@ CheckDeviceGrabs(DeviceIntPtr device, DeviceEvent *event, int checkFirst)
     if (device->deviceGrab.grab)
         return FALSE;
 
-    i = checkFirst;
+    i = 0;
+    if (ancestor)
+    {
+        while (i < device->spriteInfo->sprite->spriteTraceGood)
+            if (device->spriteInfo->sprite->spriteTrace[i++] == ancestor)
+                break;
+        if (i == device->spriteInfo->sprite->spriteTraceGood)
+            return FALSE;
+    }
 
     if (focus)
     {
diff --git a/include/dix.h b/include/dix.h
index a282a08..7485e8e 100644
--- a/include/dix.h
+++ b/include/dix.h
@@ -401,7 +401,7 @@ extern _X_EXPORT void WindowHasNewCursor(
 extern Bool CheckDeviceGrabs(
     DeviceIntPtr /* device */,
     DeviceEvent* /* event */,
-    int /* checkFirst */);
+    WindowPtr /* ancestor */);
 
 extern void DeliverFocusedEvent(
     DeviceIntPtr /* keybd */,
-- 
1.7.0



More information about the xorg-devel mailing list