From 731ace6c13e2a48dd535787d632c8d951943a073 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Wed, 16 Jul 2025 11:47:23 +0200 Subject: [PATCH] dix: ProcGetMotionEvents(): simplify writing out xTimecoord The swapping is so trivial, we don't need several extra functions for that - just do it right where the header fields are swapped. Signed-off-by: Enrico Weigelt, metux IT consult --- dix/devices.c | 16 +++++++++------- dix/swaprep.c | 24 ------------------------ include/swaprep.h | 4 ---- 3 files changed, 9 insertions(+), 35 deletions(-) diff --git a/dix/devices.c b/dix/devices.c index a91914be2f..df7ed7d83b 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -2477,7 +2477,7 @@ ProcGetMotionEvents(ClientPtr client) { WindowPtr pWin; xTimecoord *coords = (xTimecoord *) NULL; - int i, count, xmin, xmax, ymin, ymax, rc; + int count, xmin, xmax, ymin, ymax, rc; unsigned long nEvents; DeviceIntPtr mouse = PickPointer(client); TimeStamp start, stop; @@ -2513,7 +2513,7 @@ ProcGetMotionEvents(ClientPtr client) ymin = pWin->drawable.y - wBorderWidth(pWin); ymax = pWin->drawable.y + (int) pWin->drawable.height + wBorderWidth(pWin); - for (i = 0; i < count; i++) + for (int i = 0; i < count; i++) if ((xmin <= coords[i].x) && (coords[i].x < xmax) && (ymin <= coords[i].y) && (coords[i].y < ymax)) { coords[nEvents].time = coords[i].time; @@ -2534,13 +2534,15 @@ ProcGetMotionEvents(ClientPtr client) swaps(&rep.sequenceNumber); swapl(&rep.length); swapl(&rep.nEvents); + for (int i = 0; i < nEvents; i++) { + swapl(&coords[i].time); + swaps(&coords[i].x); + swaps(&coords[i].y); + } } + WriteToClient(client, sizeof(xGetMotionEventsReply), &rep); - if (nEvents) { - client->pSwapReplyFunc = (ReplySwapPtr) SwapTimeCoordWrite; - WriteSwappedDataToClient(client, nEvents * sizeof(xTimecoord), - (char *) coords); - } + WriteToClient(client, nEvents * sizeof(xTimecoord), coords); free(coords); return Success; } diff --git a/dix/swaprep.c b/dix/swaprep.c index 77897bfecf..4301df6047 100644 --- a/dix/swaprep.c +++ b/dix/swaprep.c @@ -181,30 +181,6 @@ SGenericReply(ClientPtr pClient, int size, xGenericReply * pRep) WriteToClient(pClient, size, pRep); } -static void _X_COLD -SwapTimecoord(xTimecoord * pCoord) -{ - swapl(&pCoord->time); - swaps(&pCoord->x); - swaps(&pCoord->y); -} - -void _X_COLD -SwapTimeCoordWrite(ClientPtr pClient, int size, xTimecoord * pRep) -{ - int i, n; - xTimecoord *pRepT; - - n = size / sizeof(xTimecoord); - pRepT = pRep; - for (i = 0; i < n; i++) { - SwapTimecoord(pRepT); - pRepT++; - } - WriteToClient(pClient, size, pRep); - -} - static void _X_COLD SwapCharInfo(xCharInfo * pInfo) { diff --git a/include/swaprep.h b/include/swaprep.h index c0f167b0df..ff47c07248 100644 --- a/include/swaprep.h +++ b/include/swaprep.h @@ -44,10 +44,6 @@ extern void SGenericReply(ClientPtr /* pClient */ , int /* size */ , xGenericReply * /* pRep */ ); -extern void SwapTimeCoordWrite(ClientPtr /* pClient */ , - int /* size */ , - xTimecoord * /* pRep */ ); - extern void SErrorEvent(xError * /* from */ , xError * /* to */ );