From e7751e06a5177c5a94fdbc0caef263b107fa9388 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 xGetPointerControlReply directly --- 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 f55b60afab..7c591797c1 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -2481,7 +2481,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); @@ -2500,10 +2499,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); @@ -2530,9 +2526,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 0b0b11a214..aca971d902 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 2de8f2e6de..7b9857ada6 100644 --- a/dix/tables.c +++ b/dix/tables.c @@ -755,7 +755,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 7d4e8597fe..61f5a234bd 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 */ );