From c37c82e3f2aefce0fa31688ff9b29c4e5490cb01 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Tue, 1 Apr 2025 11:38:58 +0200 Subject: [PATCH] XI: directly write out X_SetDeviceModifierMapping reply Write out X_SetDeviceModifierMapping the 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/setmmap.c | 32 ++++++++------------------------ Xi/setmmap.h | 5 ----- 3 files changed, 9 insertions(+), 33 deletions(-) diff --git a/Xi/extinit.c b/Xi/extinit.c index 6523dcb6f..74d7a9c92 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_SetDeviceModifierMapping) - SRepXSetDeviceModifierMapping(client, len, - (xSetDeviceModifierMappingReply *) rep); - else if (rep->RepType == X_GetDeviceButtonMapping) + if (rep->RepType == X_GetDeviceButtonMapping) SRepXGetDeviceButtonMapping(client, len, (xGetDeviceButtonMappingReply *) rep); else if (rep->RepType == X_SetDeviceButtonMapping) diff --git a/Xi/setmmap.c b/Xi/setmmap.c index fb7e1315a..b8e703cc1 100644 --- a/Xi/setmmap.c +++ b/Xi/setmmap.c @@ -91,35 +91,19 @@ ProcXSetDeviceModifierMapping(ClientPtr client) if (ret == Success) ret = MappingSuccess; + if (ret != MappingSuccess && ret != MappingBusy && ret != MappingFailed) + return ret; + xSetDeviceModifierMappingReply rep = { .repType = X_Reply, .RepType = X_SetDeviceModifierMapping, .sequenceNumber = client->sequence, - .length = 0 + .success = ret, }; - if (ret == MappingSuccess || ret == MappingBusy || ret == MappingFailed) { - rep.success = ret; - WriteReplyToClient(client, sizeof(xSetDeviceModifierMappingReply), - &rep); - return Success; + if (client->swapped) { + swaps(&rep.sequenceNumber); } - - return ret; -} - -/*********************************************************************** - * - * This procedure writes the reply for the XSetDeviceModifierMapping function, - * if the client and server have a different byte ordering. - * - */ - -void _X_COLD -SRepXSetDeviceModifierMapping(ClientPtr client, int size, - xSetDeviceModifierMappingReply * rep) -{ - swaps(&rep->sequenceNumber); - swapl(&rep->length); - WriteToClient(client, size, rep); + WriteToClient(client, sizeof(xSetDeviceModifierMappingReply), &rep); + return Success; } diff --git a/Xi/setmmap.h b/Xi/setmmap.h index f8b96a875..a7de58d3a 100644 --- a/Xi/setmmap.h +++ b/Xi/setmmap.h @@ -33,9 +33,4 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. int ProcXSetDeviceModifierMapping(ClientPtr /* client */ ); -void SRepXSetDeviceModifierMapping(ClientPtr /* client */ , - int /* size */ , - xSetDeviceModifierMappingReply * /* rep */ - ); - #endif /* SETMMAP_H */