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 <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult
2025-07-16 11:47:23 +02:00
committed by Enrico Weigelt
parent dcf7890076
commit 731ace6c13
3 changed files with 9 additions and 35 deletions

View File

@@ -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;
}

View File

@@ -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)
{

View File

@@ -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 */ );