From c8ea12d43660e51044aae5590d8ac230486f77b4 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Thu, 3 Apr 2025 16:07:37 +0200 Subject: [PATCH] dix: write out X_GetPointerMapping reply directly No need for using a complex callback machinery, if we just move the little pieces of byte-swapping directly into the request handler. Signed-off-by: Enrico Weigelt, metux IT consult --- dix/devices.c | 15 ++++++++++----- dix/swaprep.c | 9 --------- dix/tables.c | 2 +- include/swaprep.h | 5 ----- 4 files changed, 11 insertions(+), 20 deletions(-) diff --git a/dix/devices.c b/dix/devices.c index 5ce236473..f4232c032 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -1996,7 +1996,6 @@ ProcGetKeyboardMapping(ClientPtr client) int ProcGetPointerMapping(ClientPtr client) { - xGetPointerMappingReply rep; /* Apps may get different values each time they call GetPointerMapping as * the ClientPointer could change. */ @@ -2012,15 +2011,21 @@ ProcGetPointerMapping(ClientPtr client) return rc; nElts = (butc) ? butc->numButtons : 0; - rep = (xGetPointerMappingReply) { + + xGetPointerMappingReply rep = { .type = X_Reply, .nElts = nElts, .sequenceNumber = client->sequence, .length = ((unsigned) nElts + (4 - 1)) / 4 }; - WriteReplyToClient(client, sizeof(xGetPointerMappingReply), &rep); - if (butc) - WriteToClient(client, nElts, &butc->map[1]); + + if (client->swapped) { + swaps(&rep.sequenceNumber); + swapl(&rep.length); + } + + WriteToClient(client, sizeof(rep), &rep); + WriteToClient(client, nElts, &butc->map[1]); return Success; } diff --git a/dix/swaprep.c b/dix/swaprep.c index bd725da29..dad41daef 100644 --- a/dix/swaprep.c +++ b/dix/swaprep.c @@ -544,15 +544,6 @@ SGetKeyboardMappingReply(ClientPtr pClient, int size, WriteToClient(pClient, size, pRep); } -void _X_COLD -SGetPointerMappingReply(ClientPtr pClient, int size, - xGetPointerMappingReply * pRep) -{ - swaps(&pRep->sequenceNumber); - swapl(&pRep->length); - WriteToClient(pClient, size, pRep); -} - void _X_COLD SGetKeyboardControlReply(ClientPtr pClient, int size, xGetKeyboardControlReply * pRep) diff --git a/dix/tables.c b/dix/tables.c index 06421334d..8f6defcb6 100644 --- a/dix/tables.c +++ b/dix/tables.c @@ -832,7 +832,7 @@ ReplySwapPtr ReplySwapVector[256] = { ReplyNotSwappd, ReplyNotSwappd, /* 115 */ ReplyNotSwappd, - (ReplySwapPtr) SGetPointerMappingReply, + ReplyNotSwappd, ReplyNotSwappd, ReplyNotSwappd, /* 119 */ ReplyNotSwappd, /* 120 */ diff --git a/include/swaprep.h b/include/swaprep.h index 5d6b2ef23..df54667b2 100644 --- a/include/swaprep.h +++ b/include/swaprep.h @@ -159,11 +159,6 @@ extern void SGetKeyboardMappingReply(ClientPtr /* pClient */ , xGetKeyboardMappingReply * /* pRep */ ); -extern void SGetPointerMappingReply(ClientPtr /* pClient */ , - int /* size */ , - xGetPointerMappingReply * - /* pRep */ ); - extern void SGetKeyboardControlReply(ClientPtr /* pClient */ , int /* size */ , xGetKeyboardControlReply *