From 13bec61739045b56cb17f011c18ddbaba31cb0ac Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Thu, 3 Apr 2025 16:41:29 +0200 Subject: [PATCH] dix: write out X_GetPointerControl 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 | 23 +++++++++++++++-------- dix/swaprep.c | 9 --------- dix/tables.c | 2 +- include/swaprep.h | 5 ----- 4 files changed, 16 insertions(+), 23 deletions(-) diff --git a/dix/devices.c b/dix/devices.c index 31f6b1590..5cf4dce69 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -2473,7 +2473,6 @@ ProcGetMotionEvents(ClientPtr client) { WindowPtr pWin; xTimecoord *coords = (xTimecoord *) NULL; - xGetMotionEventsReply rep; int i, count, xmin, xmax, ymin, ymax, rc; unsigned long nEvents; DeviceIntPtr mouse = PickPointer(client); @@ -2492,10 +2491,7 @@ ProcGetMotionEvents(ClientPtr client) UpdateCurrentTimeIf(); if (mouse->valuator->motionHintWindow) MaybeStopHint(mouse, client); - rep = (xGetMotionEventsReply) { - .type = X_Reply, - .sequenceNumber = client->sequence - }; + nEvents = 0; start = ClientTimeToServerTime(stuff->start); stop = ClientTimeToServerTime(stuff->stop); @@ -2522,9 +2518,20 @@ ProcGetMotionEvents(ClientPtr client) nEvents++; } } - rep.length = nEvents * bytes_to_int32(sizeof(xTimecoord)); - rep.nEvents = nEvents; - WriteReplyToClient(client, sizeof(xGetMotionEventsReply), &rep); + + xGetMotionEventsReply rep = { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = nEvents * bytes_to_int32(sizeof(xTimecoord)), + .nEvents = nEvents, + }; + + if (client->swapped) { + swaps(&rep.sequenceNumber); + swapl(&rep.length); + swapl(&rep.nEvents); + } + WriteToClient(client, sizeof(xGetMotionEventsReply), &rep); if (nEvents) { client->pSwapReplyFunc = (ReplySwapPtr) SwapTimeCoordWrite; WriteSwappedDataToClient(client, nEvents * sizeof(xTimecoord), diff --git a/dix/swaprep.c b/dix/swaprep.c index 71bf0cf69..ab98c5006 100644 --- a/dix/swaprep.c +++ b/dix/swaprep.c @@ -287,15 +287,6 @@ SwapTimeCoordWrite(ClientPtr pClient, int size, xTimecoord * pRep) } -void _X_COLD -SGetMotionEventsReply(ClientPtr pClient, int size, xGetMotionEventsReply * pRep) -{ - swaps(&pRep->sequenceNumber); - swapl(&pRep->length); - swapl(&pRep->nEvents); - WriteToClient(pClient, size, pRep); -} - void _X_COLD SGetInputFocusReply(ClientPtr pClient, int size, xGetInputFocusReply * pRep) { diff --git a/dix/tables.c b/dix/tables.c index e42a5e45a..abfa6f108 100644 --- a/dix/tables.c +++ b/dix/tables.c @@ -754,7 +754,7 @@ ReplySwapPtr ReplySwapVector[256] = { ReplyNotSwappd, ReplyNotSwappd, (ReplySwapPtr) SQueryPointerReply, - (ReplySwapPtr) SGetMotionEventsReply, + ReplyNotSwappd, ReplyNotSwappd, /* 40 */ ReplyNotSwappd, ReplyNotSwappd, diff --git a/include/swaprep.h b/include/swaprep.h index 7d4e8597f..61f5a234b 100644 --- a/include/swaprep.h +++ b/include/swaprep.h @@ -75,11 +75,6 @@ extern void SwapTimeCoordWrite(ClientPtr /* pClient */ , int /* size */ , xTimecoord * /* pRep */ ); -extern void SGetMotionEventsReply(ClientPtr /* pClient */ , - int /* size */ , - xGetMotionEventsReply * /* pRep */ - ); - extern void SGetInputFocusReply(ClientPtr /* pClient */ , int /* size */ , xGetInputFocusReply * /* pRep */ );