summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stone <daniel@fooishbar.org>2011-01-19 20:42:10 +0000
committerPeter Hutterer <peter.hutterer@who-t.net>2011-05-06 13:15:18 +1000
commit70cef8d8baf058bacaff87ef49e3851628269597 (patch)
tree0d29cf05722e5a650f38c06327981ff872cfd8c7
parent00ba884556c675b2b25e116f5ab4eb4590b6dd56 (diff)
Input: Simplify CheckPassiveGrabsOnWindow loop
Instead of a mega never-ending if branch with no else, just continue to the next iteration of the loop if the conditions aren't met - pretty much entirely reindentation. Signed-off-by: Daniel Stone <daniel@fooishbar.org> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--dix/events.c216
1 files changed, 105 insertions, 111 deletions
diff --git a/dix/events.c b/dix/events.c
index 17194b181..895ab4035 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -3430,7 +3430,7 @@ CheckPassiveGrabsOnWindow(
DeviceIntPtr gdev;
XkbSrvInfoPtr xkbi = NULL;
xEvent *xE = NULL;
- xEvent core;
+ int count, rc;
gdev= grab->modifierDevice;
if (grab->grabtype == GRABTYPE_CORE)
@@ -3478,135 +3478,129 @@ CheckPassiveGrabsOnWindow(
match = CORE_MATCH;
}
- if (match && (!grab->confineTo ||
- (grab->confineTo->realized &&
- BorderSizeNotEmpty(device, grab->confineTo))))
- {
- int rc, count = 0;
- xEvent *xE = NULL;
+ if (!match || (grab->confineTo &&
+ (!grab->confineTo->realized ||
+ !BorderSizeNotEmpty(device, grab->confineTo))))
+ continue;
- grabinfo = &device->deviceGrab;
- /* In some cases a passive core grab may exist, but the client
- * already has a core grab on some other device. In this case we
- * must not get the grab, otherwise we may never ungrab the
- * device.
- */
+ grabinfo = &device->deviceGrab;
+ /* In some cases a passive core grab may exist, but the client
+ * already has a core grab on some other device. In this case we
+ * must not get the grab, otherwise we may never ungrab the
+ * device.
+ */
- if (grab->grabtype == GRABTYPE_CORE)
+ 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
+ current state.
+ Since XGrabDeviceButton requires to specify the
+ modifierDevice explicitly, we don't override this choice.
+ */
+ if (tempGrab.type < GenericEvent)
{
- 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
- current state.
- Since XGrabDeviceButton requires to specify the
- modifierDevice explicitly, we don't override this choice.
- */
- if (tempGrab.type < GenericEvent)
- {
- grab->device = device;
- grab->modifierDevice = GetPairedDevice(device);
- }
+ grab->device = device;
+ grab->modifierDevice = GetPairedDevice(device);
+ }
- for (other = inputInfo.devices; other; other = other->next)
+ 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))))
{
- 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;
- }
+ interfering = TRUE;
+ break;
}
- if (interfering)
- continue;
}
+ if (interfering)
+ continue;
+ }
- if (!activate)
- {
- return grab;
- }
- else if (!GetXIType(event) && !GetCoreType(event))
- {
- ErrorF("Event type %d in CheckPassiveGrabsOnWindow is"
- " neither XI 1.x nor core\n", event->any.type);
- return NULL;
- }
+ if (!activate)
+ {
+ return grab;
+ }
+ else if (!GetXIType(event) && !GetCoreType(event))
+ {
+ ErrorF("Event type %d in CheckPassiveGrabsOnWindow is neither"
+ " XI 1.x nor core\n", event->any.type);
+ return NULL;
+ }
- /* The only consumers of corestate are Xi 1.x and core events,
- * which are guaranteed to come from DeviceEvents. */
- if (match & (XI_MATCH | CORE_MATCH))
- {
- event->device_event.corestate &= 0x1f00;
- event->device_event.corestate |=
- tempGrab.modifiersDetail.exact & (~0x1f00);
- }
+ /* The only consumers of corestate are Xi 1.x and core events, which
+ * are guaranteed to come from DeviceEvents. */
+ if (match & (XI_MATCH | CORE_MATCH))
+ {
+ event->device_event.corestate &= 0x1f00;
+ event->device_event.corestate |= tempGrab.modifiersDetail.exact &
+ (~0x1f00);
+ }
- if (match & CORE_MATCH)
+ if (match & CORE_MATCH)
+ {
+ rc = EventToCore(event, &xE, &count);
+ if (rc != Success)
{
- rc = EventToCore((InternalEvent*)event, &xE, &count);
- if (rc != Success)
- {
- if (rc != BadMatch)
- ErrorF("[dix] %s: core conversion failed in CPGFW "
- "(%d, %d).\n", device->name, event->any.type,
- rc);
- continue;
- }
- } else if (match & XI2_MATCH)
+ if (rc != BadMatch)
+ ErrorF("[dix] %s: core conversion failed in CPGFW "
+ "(%d, %d).\n", device->name, event->any.type, rc);
+ continue;
+ }
+ } else if (match & XI2_MATCH)
+ {
+ rc = EventToXI2(event, &xE);
+ if (rc != Success)
{
- rc = EventToXI2(event, &xE);
- if (rc != Success)
- {
- if (rc != BadMatch)
- ErrorF("[dix] %s: XI2 conversion failed in CPGFW "
- "(%d, %d).\n", device->name, event->any.type,
- rc);
- continue;
- }
- count = 1;
- } else
+ if (rc != BadMatch)
+ ErrorF("[dix] %s: XI2 conversion failed in CPGFW "
+ "(%d, %d).\n", device->name, event->any.type, rc);
+ continue;
+ }
+ count = 1;
+ } else
+ {
+ rc = EventToXI(event, &xE, &count);
+ if (rc != Success)
{
- rc = EventToXI(event, &xE, &count);
- if (rc != Success)
- {
- if (rc != BadMatch)
- ErrorF("[dix] %s: XI conversion failed in CPGFW "
- "(%d, %d).\n", device->name, event->any.type,
- rc);
- continue;
- }
+ if (rc != BadMatch)
+ ErrorF("[dix] %s: XI conversion failed in CPGFW "
+ "(%d, %d).\n", device->name, event->any.type, rc);
+ continue;
}
+ }
- (*grabinfo->ActivateGrab)(device, grab, currentTime, TRUE);
+ (*grabinfo->ActivateGrab)(device, grab, currentTime, TRUE);
- if (xE)
- {
- FixUpEventFromWindow(pSprite, xE, grab->window, None, TRUE);
+ if (xE)
+ {
+ FixUpEventFromWindow(pSprite, xE, grab->window, None, TRUE);
- /* XXX: XACE? */
- TryClientEvents(rClient(grab), device, xE, count,
- GetEventFilter(device, xE),
- GetEventFilter(device, xE), grab);
- }
+ /* XXX: XACE? */
+ TryClientEvents(rClient(grab), device, xE, count,
+ GetEventFilter(device, xE),
+ GetEventFilter(device, xE), grab);
+ }
- if (grabinfo->sync.state == FROZEN_NO_EVENT)
- {
- if (!grabinfo->sync.event)
- grabinfo->sync.event = calloc(1, sizeof(DeviceEvent));
- *grabinfo->sync.event = event->device_event;
- grabinfo->sync.state = FROZEN_WITH_EVENT;
- }
+ if (grabinfo->sync.state == FROZEN_NO_EVENT)
+ {
+ if (!grabinfo->sync.event)
+ grabinfo->sync.event = calloc(1, sizeof(DeviceEvent));
+ *grabinfo->sync.event = event->device_event;
+ grabinfo->sync.state = FROZEN_WITH_EVENT;
+ }
- free(xE);
- return grab;
- }
+ free(xE);
+ return grab;
}
return NULL;
#undef CORE_MATCH