XI: directly write out X_XIGetSelectedEvents reply

Write out the X_XIGetSelectedEvents reply directly (and do the swapping
within the request handler) instead of going through separate callback
that's having demux the replies again.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2025-04-01 14:14:03 +02:00
parent d61c357891
commit bd8e1dc6b8
3 changed files with 12 additions and 25 deletions

View File

@ -421,9 +421,7 @@ SReplyIDispatch(ClientPtr client, int len, xGrabDeviceReply * rep)
{
/* All we look at is the type field */
/* This is common to all replies */
if (rep->RepType == X_XIGetSelectedEvents)
SRepXIGetSelectedEvents(client, len, (xXIGetSelectedEventsReply *) rep);
else if (rep->RepType == X_XIGetFocus)
if (rep->RepType == X_XIGetFocus)
SRepXIGetFocus(client, len, (xXIGetFocusReply *) rep);
else {
FatalError("XINPUT confused sending swapped reply");

View File

@ -347,7 +347,6 @@ ProcXIGetSelectedEvents(ClientPtr client)
InputClientsPtr others = NULL;
xXIEventMask *evmask = NULL;
DeviceIntPtr dev;
uint32_t length;
REQUEST(xXIGetSelectedEventsReq);
REQUEST_SIZE_MATCH(xXIGetSelectedEventsReq);
@ -374,10 +373,8 @@ ProcXIGetSelectedEvents(ClientPtr client)
}
}
if (!others) {
WriteReplyToClient(client, sizeof(xXIGetSelectedEventsReply), &rep);
return Success;
}
if (!others)
goto finish;
buffer =
calloc(MAXDEVICES, sizeof(xXIEventMask) + pad_to_int32(XI2MASKSIZE));
@ -417,23 +414,17 @@ ProcXIGetSelectedEvents(ClientPtr client)
}
}
/* save the value before SRepXIGetSelectedEvents swaps it */
length = rep.length;
WriteReplyToClient(client, sizeof(xXIGetSelectedEventsReply), &rep);
finish: ;
uint32_t length = rep.length; /* save before swapping it */
if (rep.num_masks)
WriteToClient(client, length * 4, buffer);
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swaps(&rep.num_masks);
}
WriteToClient(client, sizeof(xXIGetSelectedEventsReply), &rep);
WriteToClient(client, length * 4, buffer);
free(buffer);
return Success;
}
void
SRepXIGetSelectedEvents(ClientPtr client,
int len, xXIGetSelectedEventsReply * rep)
{
swaps(&rep->sequenceNumber);
swapl(&rep->length);
swaps(&rep->num_masks);
WriteToClient(client, len, rep);
}

View File

@ -34,7 +34,5 @@ int SProcXISelectEvents(ClientPtr client);
int ProcXISelectEvents(ClientPtr client);
int SProcXIGetSelectedEvents(ClientPtr client);
int ProcXIGetSelectedEvents(ClientPtr client);
void SRepXIGetSelectedEvents(ClientPtr client,
int len, xXIGetSelectedEventsReply * rep);
#endif /* _XISELECTEVENTS_H_ */