From 13cc0cdf09b87b63f1a2bd68ea517eb8ece7bbb6 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Tue, 1 Apr 2025 11:51:52 +0200 Subject: [PATCH] XI: directly write out X_SetDeviceButtonMapping reply Write out the X_SetDeviceButtonMapping 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 | 5 +---- Xi/setbmap.c | 41 +++++++++++++---------------------------- Xi/setbmap.h | 5 ----- 3 files changed, 14 insertions(+), 37 deletions(-) diff --git a/Xi/extinit.c b/Xi/extinit.c index 7e97fa4b2..f62ce07c2 100644 --- a/Xi/extinit.c +++ b/Xi/extinit.c @@ -421,10 +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_SetDeviceButtonMapping) - SRepXSetDeviceButtonMapping(client, len, - (xSetDeviceButtonMappingReply *) rep); - else if (rep->RepType == X_QueryDeviceState) + if (rep->RepType == X_QueryDeviceState) SRepXQueryDeviceState(client, len, (xQueryDeviceStateReply *) rep); else if (rep->RepType == X_SetDeviceValuators) SRepXSetDeviceValuators(client, len, (xSetDeviceValuatorsReply *) rep); diff --git a/Xi/setbmap.c b/Xi/setbmap.c index 61befcf1c..c235fbb4f 100644 --- a/Xi/setbmap.c +++ b/Xi/setbmap.c @@ -85,41 +85,26 @@ ProcXSetDeviceButtonMapping(ClientPtr client) if (ret != Success) return ret; - xSetDeviceButtonMappingReply rep = { - .repType = X_Reply, - .RepType = X_SetDeviceButtonMapping, - .sequenceNumber = client->sequence, - .length = 0, - .status = MappingSuccess - }; - ret = ApplyPointerMapping(dev, (CARD8 *) &stuff[1], stuff->map_length, client); if (ret == -1) return BadValue; - else if (ret == MappingBusy) - rep.status = ret; - else if (ret != Success) + + if ((ret != Success) && (ret != MappingBusy)) return ret; - WriteReplyToClient(client, sizeof(xSetDeviceButtonMappingReply), &rep); + xSetDeviceButtonMappingReply rep = { + .repType = X_Reply, + .RepType = X_SetDeviceButtonMapping, + .sequenceNumber = client->sequence, + .status = (ret == Success ? MappingSuccess : MappingBusy), + }; + + if (client->swapped) { + swaps(&rep.sequenceNumber); + } + WriteToClient(client, sizeof(xSetDeviceButtonMappingReply), &rep); return Success; } - -/*********************************************************************** - * - * This procedure writes the reply for the XSetDeviceButtonMapping function, - * if the client and server have a different byte ordering. - * - */ - -void _X_COLD -SRepXSetDeviceButtonMapping(ClientPtr client, int size, - xSetDeviceButtonMappingReply * rep) -{ - swaps(&rep->sequenceNumber); - swapl(&rep->length); - WriteToClient(client, size, rep); -} diff --git a/Xi/setbmap.h b/Xi/setbmap.h index b402692ce..f4bb22cb7 100644 --- a/Xi/setbmap.h +++ b/Xi/setbmap.h @@ -33,9 +33,4 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. int ProcXSetDeviceButtonMapping(ClientPtr /* client */ ); -void SRepXSetDeviceButtonMapping(ClientPtr /* client */ , - int /* size */ , - xSetDeviceButtonMappingReply * /* rep */ - ); - #endif /* SETBMAP_H */