From d253a262c2c690357a4db7e235c48ab5dd0b77f8 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 7 Dec 2011 13:57:25 +1000 Subject: [PATCH] dix: split core grab interference check into helper function No functional changes. Signed-off-by: Peter Hutterer Reviewed-by: Chase Douglas --- dix/events.c | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/dix/events.c b/dix/events.c index 349d9b4e7..4d80358b5 100644 --- a/dix/events.c +++ b/dix/events.c @@ -3727,6 +3727,30 @@ ActivatePassiveGrab(DeviceIntPtr device, GrabPtr grab, InternalEvent *event) return TRUE; } +static BOOL +CoreGrabInterferes(DeviceIntPtr device, GrabPtr grab) +{ + DeviceIntPtr other; + BOOL interfering = FALSE; + + for (other = inputInfo.devices; other; other = other->next) + { + GrabPtr othergrab = other->deviceGrab.grab; + if (othergrab && othergrab->grabtype == GRABTYPE_CORE && + SameClient(grab, rClient(othergrab)) && + ((IsPointerDevice(grab->device) && + IsPointerDevice(othergrab->device)) || + (IsKeyboardDevice(grab->device) && + IsKeyboardDevice(othergrab->device)))) + { + interfering = TRUE; + break; + } + } + + return interfering; +} + /** * Check an individual grab against an event to determine if a passive grab * should be activated. @@ -3806,9 +3830,6 @@ CheckPassiveGrab(DeviceIntPtr device, GrabPtr grab, InternalEvent *event, if (grab->grabtype == GRABTYPE_CORE) { - DeviceIntPtr other; - BOOL interfering = FALSE; - /* A passive grab may have been created for a different device than it is assigned to at this point in time. Update the grab's device and modifier device to reflect the @@ -3822,21 +3843,7 @@ CheckPassiveGrab(DeviceIntPtr device, GrabPtr grab, InternalEvent *event, grab->modifierDevice = GetMaster(device, MASTER_KEYBOARD); } - for (other = inputInfo.devices; other; other = other->next) - { - GrabPtr othergrab = other->deviceGrab.grab; - if (othergrab && othergrab->grabtype == GRABTYPE_CORE && - SameClient(grab, rClient(othergrab)) && - ((IsPointerDevice(grab->device) && - IsPointerDevice(othergrab->device)) || - (IsKeyboardDevice(grab->device) && - IsKeyboardDevice(othergrab->device)))) - { - interfering = TRUE; - break; - } - } - if (interfering) + if (CoreGrabInterferes(device, grab)) return FALSE; }