From 67ecf846be62d17cbdd755bfc2639d29f933698e Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Thu, 3 Apr 2025 16:26:23 +0200 Subject: [PATCH] dix: write out xGetKeyboardControlReply directly --- dix/devices.c | 18 ++++++++++++------ dix/swaprep.c | 12 ------------ dix/tables.c | 2 +- include/swaprep.h | 5 ----- 4 files changed, 13 insertions(+), 24 deletions(-) diff --git a/dix/devices.c b/dix/devices.c index d184104ad3..cbbd4f9bc6 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -2272,18 +2272,16 @@ ProcChangeKeyboardControl(ClientPtr client) int ProcGetKeyboardControl(ClientPtr client) { - int rc, i; DeviceIntPtr kbd = PickKeyboard(client); KeybdCtrl *ctrl = &kbd->kbdfeed->ctrl; - xGetKeyboardControlReply rep; REQUEST_SIZE_MATCH(xReq); - rc = XaceHookDeviceAccess(client, kbd, DixGetAttrAccess); + int rc = XaceHookDeviceAccess(client, kbd, DixGetAttrAccess); if (rc != Success) return rc; - rep = (xGetKeyboardControlReply) { + xGetKeyboardControlReply rep = { .type = X_Reply, .globalAutoRepeat = ctrl->autoRepeat, .sequenceNumber = client->sequence, @@ -2294,9 +2292,17 @@ ProcGetKeyboardControl(ClientPtr client) .bellPitch = ctrl->bell_pitch, .bellDuration = ctrl->bell_duration }; - for (i = 0; i < 32; i++) + for (int i = 0; i < 32; i++) rep.map[i] = ctrl->autoRepeats[i]; - WriteReplyToClient(client, sizeof(xGetKeyboardControlReply), &rep); + + if (client->swapped) { + swaps(&rep.sequenceNumber); + swapl(&rep.length); + swapl(&rep.ledMask); + swaps(&rep.bellPitch); + swaps(&rep.bellDuration); + } + WriteToClient(client, sizeof(rep), &rep); return Success; } diff --git a/dix/swaprep.c b/dix/swaprep.c index 5588ec0900..e66a2d9f6e 100644 --- a/dix/swaprep.c +++ b/dix/swaprep.c @@ -535,18 +535,6 @@ SListExtensionsReply(ClientPtr pClient, int size, xListExtensionsReply * pRep) WriteToClient(pClient, size, pRep); } -void _X_COLD -SGetKeyboardControlReply(ClientPtr pClient, int size, - xGetKeyboardControlReply * pRep) -{ - swaps(&pRep->sequenceNumber); - swapl(&pRep->length); - swapl(&pRep->ledMask); - swaps(&pRep->bellPitch); - swaps(&pRep->bellDuration); - WriteToClient(pClient, size, pRep); -} - void _X_COLD SGetPointerControlReply(ClientPtr pClient, int size, xGetPointerControlReply * pRep) diff --git a/dix/tables.c b/dix/tables.c index cdc17fbec6..8e43047e0e 100644 --- a/dix/tables.c +++ b/dix/tables.c @@ -819,7 +819,7 @@ ReplySwapPtr ReplySwapVector[256] = { ReplyNotSwappd, /* 100 */ ReplyNotSwappd, ReplyNotSwappd, - (ReplySwapPtr) SGetKeyboardControlReply, + ReplyNotSwappd, ReplyNotSwappd, ReplyNotSwappd, /* 105 */ (ReplySwapPtr) SGetPointerControlReply, diff --git a/include/swaprep.h b/include/swaprep.h index d53547751b..692a80b912 100644 --- a/include/swaprep.h +++ b/include/swaprep.h @@ -154,11 +154,6 @@ extern void SListExtensionsReply(ClientPtr /* pClient */ , int /* size */ , xListExtensionsReply * /* pRep */ ); -extern void SGetKeyboardControlReply(ClientPtr /* pClient */ , - int /* size */ , - xGetKeyboardControlReply * - /* pRep */ ); - extern void SGetPointerControlReply(ClientPtr /* pClient */ , int /* size */ , xGetPointerControlReply *