[PATCH 1/6] Input: Store passive-activating key in CheckDeviceGrabs

Daniel Stone daniel at fooishbar.org
Tue Feb 15 03:27:57 PST 2011


CheckDeviceGrabs will activate a passive grab for KeyPress and
ButtonPress events.  GrabInfoRec::activatingKey contains the keycode
which activated the passive grab, so we can deactivate it later in
ProcessOtherEvents.

Previously, CheckDeviceGrabs relied on its callers to set
activatingKey, which not all callers were doing (I'm looking at you,
ComputeFreezes).  Just set it in CheckDeviceGrabs instead.

Signed-off-by: Daniel Stone <daniel at fooishbar.org>
---
 Xi/exevents.c |    4 +---
 dix/events.c  |   20 +++++++++++++++-----
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/Xi/exevents.c b/Xi/exevents.c
index 327873e..5131167 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -1047,10 +1047,8 @@ ProcessOtherEvent(InternalEvent *ev, DeviceIntPtr device)
     switch(event->type)
     {
         case ET_KeyPress:
-            if (!grab && CheckDeviceGrabs(device, event, 0)) {
-                device->deviceGrab.activatingKey = key;
+            if (!grab && CheckDeviceGrabs(device, event, 0))
                 return;
-            }
             break;
         case ET_KeyRelease:
             if (grab && device->deviceGrab.fromPassiveGrab &&
diff --git a/dix/events.c b/dix/events.c
index 07f8b05..5e8166d 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -3582,6 +3582,7 @@ CheckDeviceGrabs(DeviceIntPtr device, DeviceEvent *event, WindowPtr ancestor)
     WindowPtr pWin = NULL;
     FocusClassPtr focus = IsPointerEvent((InternalEvent*)event) ? NULL : device->focus;
     BOOL sendCore = (IsMaster(device) && device->coreEvents);
+    Bool ret = FALSE;
 
     if (event->type != ET_ButtonPress &&
         event->type != ET_KeyPress)
@@ -3601,7 +3602,7 @@ CheckDeviceGrabs(DeviceIntPtr device, DeviceEvent *event, WindowPtr ancestor)
             if (device->spriteInfo->sprite->spriteTrace[i++] == ancestor)
                 break;
         if (i == device->spriteInfo->sprite->spriteTraceGood)
-            return FALSE;
+            goto out;
     }
 
     if (focus)
@@ -3610,23 +3611,32 @@ CheckDeviceGrabs(DeviceIntPtr device, DeviceEvent *event, WindowPtr ancestor)
 	{
 	    pWin = focus->trace[i];
 	    if (CheckPassiveGrabsOnWindow(pWin, device, event, sendCore, TRUE))
-		return TRUE;
+	    {
+		ret = TRUE;
+		goto out;
+	    }
 	}
 
 	if ((focus->win == NoneWin) ||
 	    (i >= device->spriteInfo->sprite->spriteTraceGood) ||
 	    (pWin && pWin != device->spriteInfo->sprite->spriteTrace[i-1]))
-	    return FALSE;
+	    goto out;
     }
 
     for (; i < device->spriteInfo->sprite->spriteTraceGood; i++)
     {
 	pWin = device->spriteInfo->sprite->spriteTrace[i];
 	if (CheckPassiveGrabsOnWindow(pWin, device, event, sendCore, TRUE))
-	    return TRUE;
+	{
+	    ret = TRUE;
+	    goto out;
+	}
     }
 
-    return FALSE;
+out:
+    if (ret == TRUE && event->type == ET_KeyPress)
+        device->deviceGrab.activatingKey = event->detail.key;
+    return ret;
 }
 
 /**
-- 
1.7.2.3



More information about the xorg-devel mailing list