From 5bf2f662cc10baf5666c703c06bff388d8c0f17c Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Tue, 1 Apr 2025 13:46:43 +0200 Subject: [PATCH] XI: directly write out X_XIQueryDevice reply Write out the X_XIQueryDevice 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 --- Xi/extinit.c | 4 +--- Xi/xiquerydevice.c | 20 +++++++------------- Xi/xiquerydevice.h | 1 - 3 files changed, 8 insertions(+), 17 deletions(-) diff --git a/Xi/extinit.c b/Xi/extinit.c index 1aba852eb..19ad68bec 100644 --- a/Xi/extinit.c +++ b/Xi/extinit.c @@ -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_XIQueryDevice) - SRepXIQueryDevice(client, len, (xXIQueryDeviceReply *) rep); - else if (rep->RepType == X_XIGrabDevice) + if (rep->RepType == X_XIGrabDevice) SRepXIGrabDevice(client, len, (xXIGrabDeviceReply *) rep); else if (rep->RepType == X_XIPassiveGrabDevice) SRepXIPassiveGrabDevice(client, len, (xXIPassiveGrabDeviceReply *) rep); diff --git a/Xi/xiquerydevice.c b/Xi/xiquerydevice.c index 43b93b8c9..e8caa61f4 100644 --- a/Xi/xiquerydevice.c +++ b/Xi/xiquerydevice.c @@ -149,25 +149,19 @@ ProcXIQueryDevice(ClientPtr client) } len = rep.length * 4; - WriteReplyToClient(client, sizeof(xXIQueryDeviceReply), &rep); + + if (client->swapped) { + swaps(&rep.sequenceNumber); + swapl(&rep.length); + swaps(&rep.num_devices); + } + WriteToClient(client, sizeof(xXIQueryDeviceReply), &rep); WriteToClient(client, len, ptr); free(ptr); free(skip); return rc; } -void -SRepXIQueryDevice(ClientPtr client, int size, xXIQueryDeviceReply * rep) -{ - swaps(&rep->sequenceNumber); - swapl(&rep->length); - swaps(&rep->num_devices); - - /* Device info is already swapped, see ProcXIQueryDevice */ - - WriteToClient(client, size, rep); -} - /** * @return Whether the device should be included in the returned list. */ diff --git a/Xi/xiquerydevice.h b/Xi/xiquerydevice.h index 8a180bf39..5f6fee3db 100644 --- a/Xi/xiquerydevice.h +++ b/Xi/xiquerydevice.h @@ -35,7 +35,6 @@ int SProcXIQueryDevice(ClientPtr client); int ProcXIQueryDevice(ClientPtr client); -void SRepXIQueryDevice(ClientPtr client, int size, xXIQueryDeviceReply * rep); int SizeDeviceClasses(DeviceIntPtr dev); int ListDeviceClasses(ClientPtr client, DeviceIntPtr dev, char *any, uint16_t * nclasses);