From 71139c015e93adbbdda3b69ad48f606d2dc3f9ec Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Thu, 3 Apr 2025 17:12:58 +0200 Subject: [PATCH] dix: write out X_QueryKeymap 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 | 10 +++++++--- dix/swaprep.c | 9 --------- dix/tables.c | 2 +- include/swaprep.h | 4 ---- 4 files changed, 8 insertions(+), 17 deletions(-) diff --git a/dix/devices.c b/dix/devices.c index 5cf4dce69..c59ea8b3b 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -2544,13 +2544,13 @@ ProcGetMotionEvents(ClientPtr client) int ProcQueryKeymap(ClientPtr client) { - xQueryKeymapReply rep; int rc, i; DeviceIntPtr keybd = PickKeyboard(client); CARD8 *down = keybd->key->down; REQUEST_SIZE_MATCH(xReq); - rep = (xQueryKeymapReply) { + + xQueryKeymapReply rep = { .type = X_Reply, .sequenceNumber = client->sequence, .length = 2 @@ -2567,7 +2567,11 @@ ProcQueryKeymap(ClientPtr client) else if (rc != BadAccess) return rc; - WriteReplyToClient(client, sizeof(xQueryKeymapReply), &rep); + if (client->swapped) { + swaps(&rep.sequenceNumber); + swapl(&rep.length); + } + WriteToClient(client, sizeof(rep), &rep); return Success; } diff --git a/dix/swaprep.c b/dix/swaprep.c index ab98c5006..892d55b10 100644 --- a/dix/swaprep.c +++ b/dix/swaprep.c @@ -295,15 +295,6 @@ SGetInputFocusReply(ClientPtr pClient, int size, xGetInputFocusReply * pRep) WriteToClient(pClient, size, pRep); } -/* extra long reply */ -void _X_COLD -SQueryKeymapReply(ClientPtr pClient, int size, xQueryKeymapReply * pRep) -{ - swaps(&pRep->sequenceNumber); - swapl(&pRep->length); - WriteToClient(pClient, size, pRep); -} - static void _X_COLD SwapCharInfo(xCharInfo * pInfo) { diff --git a/dix/tables.c b/dix/tables.c index abfa6f108..faa391f61 100644 --- a/dix/tables.c +++ b/dix/tables.c @@ -759,7 +759,7 @@ ReplySwapPtr ReplySwapVector[256] = { ReplyNotSwappd, ReplyNotSwappd, (ReplySwapPtr) SGetInputFocusReply, - (ReplySwapPtr) SQueryKeymapReply, + ReplyNotSwappd, ReplyNotSwappd, /* 45 */ ReplyNotSwappd, (ReplySwapPtr) SQueryFontReply, diff --git a/include/swaprep.h b/include/swaprep.h index 61f5a234b..92032f6d1 100644 --- a/include/swaprep.h +++ b/include/swaprep.h @@ -79,10 +79,6 @@ extern void SGetInputFocusReply(ClientPtr /* pClient */ , int /* size */ , xGetInputFocusReply * /* pRep */ ); -extern void SQueryKeymapReply(ClientPtr /* pClient */ , - int /* size */ , - xQueryKeymapReply * /* pRep */ ); - extern void SQueryFontReply(ClientPtr /* pClient */ , int /* size */ , xQueryFontReply * /* pRep */ );