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:
parent
6fb01c8286
commit
3d988e01e4
124
dix/events.c
124
dix/events.c
|
@ -1891,70 +1891,84 @@ 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))
|
||||||
{
|
{
|
||||||
if (grab && !SameClient(grab, client))
|
#ifdef DEBUG_EVENTS
|
||||||
return -1; /* don't send, but notify caller */
|
ErrorF(" filtered\n");
|
||||||
type = pEvents->u.u.type;
|
#endif
|
||||||
if (type == MotionNotify)
|
return 0;
|
||||||
{
|
}
|
||||||
if (mask & PointerMotionHintMask)
|
|
||||||
{
|
|
||||||
if (WID(dev->valuator->motionHintWindow) ==
|
|
||||||
pEvents->u.keyButtonPointer.event)
|
|
||||||
{
|
|
||||||
#ifdef DEBUG_EVENTS
|
|
||||||
ErrorF("[dix] \n");
|
|
||||||
ErrorF("[dix] motionHintWindow == keyButtonPointer.event\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;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (BitIsOn(criticalEvents, type))
|
if (grab && !SameClient(grab, client))
|
||||||
{
|
{
|
||||||
if (client->smart_priority < SMART_MAX_PRIORITY)
|
|
||||||
client->smart_priority++;
|
|
||||||
SetCriticalOutputPending();
|
|
||||||
}
|
|
||||||
|
|
||||||
WriteEventsToClient(client, count, pEvents);
|
|
||||||
#ifdef DEBUG_EVENTS
|
#ifdef DEBUG_EVENTS
|
||||||
ErrorF("[dix] delivered\n");
|
ErrorF(" not delivered due to grab\n");
|
||||||
#endif
|
#endif
|
||||||
return 1;
|
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)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_EVENTS
|
||||||
|
ErrorF("[dix] \n");
|
||||||
|
ErrorF("[dix] motionHintWindow == keyButtonPointer.event\n");
|
||||||
|
#endif
|
||||||
|
return 1; /* don't send, but pretend we did */
|
||||||
|
}
|
||||||
|
pEvents->u.u.detail = NotifyHint;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pEvents->u.u.detail = NotifyNormal;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_EVENTS
|
if ((type == DeviceMotionNotify) &&
|
||||||
ErrorF("[dix] \n");
|
MaybeSendDeviceMotionNotifyHint
|
||||||
#endif
|
((deviceKeyButtonPointer*)pEvents, mask) != 0)
|
||||||
return 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue