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>
This commit is contained in:
Daniel Stone 2009-08-21 15:15:41 +10:00 committed by Peter Hutterer
parent 6fb01c8286
commit 3d988e01e4

View File

@ -1891,14 +1891,35 @@ TryClientEvents (ClientPtr client, DeviceIntPtr dev, xEvent *pEvents,
int type; int type;
#ifdef DEBUG_EVENTS #ifdef DEBUG_EVENTS
ErrorF("[dix] Event([%d, %d], mask=0x%x), client=%d", ErrorF("[dix] Event([%d, %d], mask=0x%lx), client=%d%s",
pEvents->u.u.type, pEvents->u.u.detail, mask, client->index); pEvents->u.u.type, pEvents->u.u.detail, mask,
client ? client->index : -1,
(client && client->clientGone) ? " (gone)" : "");
#endif #endif
if ((client) && (client != serverClient) && (!client->clientGone) &&
((filter == CantBeFiltered) || (mask & filter))) if (!client || client == serverClient || client->clientGone) {
#ifdef DEBUG_EVENTS
ErrorF(" not delivered to fake/dead client\n");
#endif
return 0;
}
if (filter != CantBeFiltered && !(mask & filter))
{ {
#ifdef DEBUG_EVENTS
ErrorF(" filtered\n");
#endif
return 0;
}
if (grab && !SameClient(grab, client)) if (grab && !SameClient(grab, client))
{
#ifdef DEBUG_EVENTS
ErrorF(" not delivered due to grab\n");
#endif
return -1; /* don't send, but notify caller */ return -1; /* don't send, but notify caller */
}
type = pEvents->u.u.type; type = pEvents->u.u.type;
if (type == MotionNotify) if (type == MotionNotify)
{ {
@ -1927,6 +1948,7 @@ TryClientEvents (ClientPtr client, DeviceIntPtr dev, xEvent *pEvents,
((deviceKeyButtonPointer*)pEvents, mask) != 0) ((deviceKeyButtonPointer*)pEvents, mask) != 0)
return 1; return 1;
} }
type &= 0177; type &= 0177;
if (type != KeymapNotify) if (type != KeymapNotify)
{ {
@ -1947,14 +1969,6 @@ TryClientEvents (ClientPtr client, DeviceIntPtr dev, xEvent *pEvents,
ErrorF("[dix] delivered\n"); ErrorF("[dix] delivered\n");
#endif #endif
return 1; return 1;
}
else
{
#ifdef DEBUG_EVENTS
ErrorF("[dix] \n");
#endif
return 0;
}
} }
/** /**