diff options
author | Daniel Stone <daniel@fooishbar.org> | 2009-08-21 15:15:41 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2009-09-04 12:59:40 +1000 |
commit | 3d988e01e41e98fc5160f825a250522ba274d09f (patch) | |
tree | dd4050da567039f2d80410c7c21c8a3525181ba7 /dix/events.c | |
parent | 6fb01c8286c16968fd07e4a5b78da89cd8768d79 (diff) |
dix: improve code flow in TryClientEvents, better debugging messages.
Instead of a massive if (blah && blah), return early where possible.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'dix/events.c')
-rw-r--r-- | dix/events.c | 118 |
1 files changed, 66 insertions, 52 deletions
diff --git a/dix/events.c b/dix/events.c index de96de3ce..acc1803ef 100644 --- a/dix/events.c +++ b/dix/events.c @@ -1891,70 +1891,84 @@ TryClientEvents (ClientPtr client, DeviceIntPtr dev, xEvent *pEvents, int type; #ifdef DEBUG_EVENTS - ErrorF("[dix] Event([%d, %d], mask=0x%x), client=%d", - pEvents->u.u.type, pEvents->u.u.detail, mask, client->index); + ErrorF("[dix] Event([%d, %d], mask=0x%lx), client=%d%s", + pEvents->u.u.type, pEvents->u.u.detail, mask, + client ? client->index : -1, + (client && client->clientGone) ? " (gone)" : ""); #endif - if ((client) && (client != serverClient) && (!client->clientGone) && - ((filter == CantBeFiltered) || (mask & filter))) - { - if (grab && !SameClient(grab, client)) - return -1; /* don't send, but notify caller */ - type = pEvents->u.u.type; - if (type == MotionNotify) - { - if (mask & PointerMotionHintMask) - { - if (WID(dev->valuator->motionHintWindow) == - pEvents->u.keyButtonPointer.event) - { + + if (!client || client == serverClient || client->clientGone) { #ifdef DEBUG_EVENTS - ErrorF("[dix] \n"); - ErrorF("[dix] motionHintWindow == keyButtonPointer.event\n"); + ErrorF(" not delivered to fake/dead client\n"); #endif - return 1; /* don't send, but pretend we did */ - } - pEvents->u.u.detail = NotifyHint; - } - else - { - pEvents->u.u.detail = NotifyNormal; - } - } - else - { - if ((type == DeviceMotionNotify) && - MaybeSendDeviceMotionNotifyHint - ((deviceKeyButtonPointer*)pEvents, mask) != 0) - return 1; - } - type &= 0177; - if (type != KeymapNotify) - { - /* all extension events must have a sequence number */ - for (i = 0; i < count; i++) - pEvents[i].u.u.sequenceNumber = client->sequence; - } + return 0; + } - if (BitIsOn(criticalEvents, type)) - { - if (client->smart_priority < SMART_MAX_PRIORITY) - client->smart_priority++; - SetCriticalOutputPending(); - } + if (filter != CantBeFiltered && !(mask & filter)) + { + #ifdef DEBUG_EVENTS + ErrorF(" filtered\n"); + #endif + return 0; + } - WriteEventsToClient(client, count, pEvents); + if (grab && !SameClient(grab, client)) + { #ifdef DEBUG_EVENTS - ErrorF("[dix] delivered\n"); + ErrorF(" not delivered due to grab\n"); #endif - return 1; + return -1; /* don't send, but notify caller */ } - else + + type = pEvents->u.u.type; + if (type == MotionNotify) { + if (mask & PointerMotionHintMask) + { + if (WID(dev->valuator->motionHintWindow) == + pEvents->u.keyButtonPointer.event) + { #ifdef DEBUG_EVENTS - ErrorF("[dix] \n"); + ErrorF("[dix] \n"); + ErrorF("[dix] motionHintWindow == keyButtonPointer.event\n"); #endif - return 0; + return 1; /* don't send, but pretend we did */ + } + pEvents->u.u.detail = NotifyHint; + } + else + { + pEvents->u.u.detail = NotifyNormal; + } } + else + { + if ((type == DeviceMotionNotify) && + MaybeSendDeviceMotionNotifyHint + ((deviceKeyButtonPointer*)pEvents, mask) != 0) + return 1; + } + + type &= 0177; + if (type != KeymapNotify) + { + /* all extension events must have a sequence number */ + for (i = 0; i < count; i++) + pEvents[i].u.u.sequenceNumber = client->sequence; + } + + if (BitIsOn(criticalEvents, type)) + { + if (client->smart_priority < SMART_MAX_PRIORITY) + client->smart_priority++; + SetCriticalOutputPending(); + } + + WriteEventsToClient(client, count, pEvents); +#ifdef DEBUG_EVENTS + ErrorF("[dix] delivered\n"); +#endif + return 1; } /** |