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 */ /* All we look at is the type field */
/* This is common to all replies */ /* This is common to all replies */
if (rep->RepType == X_XIGetSelectedEvents) if (rep->RepType == X_XIGetFocus)
SRepXIGetSelectedEvents(client, len, (xXIGetSelectedEventsReply *) rep);
else if (rep->RepType == X_XIGetFocus)
SRepXIGetFocus(client, len, (xXIGetFocusReply *) rep); SRepXIGetFocus(client, len, (xXIGetFocusReply *) rep);
else { else {
FatalError("XINPUT confused sending swapped reply"); FatalError("XINPUT confused sending swapped reply");

View File

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