From df63401d6dab81adfadbc4ea3dc46c483c51ddab Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Wed, 2 Apr 2025 20:15:21 +0200 Subject: [PATCH] dix: write out X_TranslateCoords 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 --- Xext/panoramiXprocs.c | 12 +++++++++--- dix/dispatch.c | 12 +++++++++--- dix/swaprep.c | 10 ---------- dix/tables.c | 2 +- include/swaprep.h | 5 ----- 5 files changed, 19 insertions(+), 22 deletions(-) diff --git a/Xext/panoramiXprocs.c b/Xext/panoramiXprocs.c index d93eedaba..b84cf930c 100644 --- a/Xext/panoramiXprocs.c +++ b/Xext/panoramiXprocs.c @@ -622,7 +622,6 @@ PanoramiXTranslateCoords(ClientPtr client) REQUEST(xTranslateCoordsReq); int rc; WindowPtr pWin, pDst; - xTranslateCoordsReply rep; REQUEST_SIZE_MATCH(xTranslateCoordsReq); rc = dixLookupWindow(&pWin, stuff->srcWid, client, DixReadAccess); @@ -631,7 +630,8 @@ PanoramiXTranslateCoords(ClientPtr client) rc = dixLookupWindow(&pDst, stuff->dstWid, client, DixReadAccess); if (rc != Success) return rc; - rep = (xTranslateCoordsReply) { + + xTranslateCoordsReply rep = { .type = X_Reply, .sequenceNumber = client->sequence, .length = 0, @@ -682,7 +682,13 @@ PanoramiXTranslateCoords(ClientPtr client) rep.dstY += screenInfo.screens[0]->y; } - WriteReplyToClient(client, sizeof(xTranslateCoordsReply), &rep); + if (client->swapped) { + swaps(&rep.sequenceNumber); + swapl(&rep.child); + swaps(&rep.dstX); + swaps(&rep.dstY); + } + WriteToClient(client, sizeof(rep), &rep); return Success; } diff --git a/dix/dispatch.c b/dix/dispatch.c index 9988c069d..91f1075ff 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -1219,7 +1219,6 @@ ProcTranslateCoords(ClientPtr client) REQUEST(xTranslateCoordsReq); WindowPtr pWin, pDst; - xTranslateCoordsReply rep; int rc; REQUEST_SIZE_MATCH(xTranslateCoordsReq); @@ -1230,7 +1229,7 @@ ProcTranslateCoords(ClientPtr client) if (rc != Success) return rc; - rep = (xTranslateCoordsReply) { + xTranslateCoordsReply rep = { .type = X_Reply, .sequenceNumber = client->sequence, .length = 0 @@ -1281,7 +1280,14 @@ ProcTranslateCoords(ClientPtr client) rep.dstX = x - pDst->drawable.x; rep.dstY = y - pDst->drawable.y; } - WriteReplyToClient(client, sizeof(xTranslateCoordsReply), &rep); + + if (client->swapped) { + swaps(&rep.sequenceNumber); + swapl(&rep.child); + swaps(&rep.dstX); + swaps(&rep.dstY); + } + WriteToClient(client, sizeof(rep), &rep); return Success; } diff --git a/dix/swaprep.c b/dix/swaprep.c index 8cf6555e1..1bfc8b647 100644 --- a/dix/swaprep.c +++ b/dix/swaprep.c @@ -305,16 +305,6 @@ SGetMotionEventsReply(ClientPtr pClient, int size, xGetMotionEventsReply * pRep) WriteToClient(pClient, size, pRep); } -void _X_COLD -STranslateCoordsReply(ClientPtr pClient, int size, xTranslateCoordsReply * pRep) -{ - swaps(&pRep->sequenceNumber); - swapl(&pRep->child); - swaps(&pRep->dstX); - swaps(&pRep->dstY); - 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 468d691ce..bb06d77d2 100644 --- a/dix/tables.c +++ b/dix/tables.c @@ -755,7 +755,7 @@ ReplySwapPtr ReplySwapVector[256] = { ReplyNotSwappd, (ReplySwapPtr) SQueryPointerReply, (ReplySwapPtr) SGetMotionEventsReply, - (ReplySwapPtr) STranslateCoordsReply, /* 40 */ + ReplyNotSwappd, /* 40 */ ReplyNotSwappd, ReplyNotSwappd, (ReplySwapPtr) SGetInputFocusReply, diff --git a/include/swaprep.h b/include/swaprep.h index db3e37ae1..03e17fa47 100644 --- a/include/swaprep.h +++ b/include/swaprep.h @@ -85,11 +85,6 @@ extern void SGetMotionEventsReply(ClientPtr /* pClient */ , xGetMotionEventsReply * /* pRep */ ); -extern void STranslateCoordsReply(ClientPtr /* pClient */ , - int /* size */ , - xTranslateCoordsReply * /* pRep */ - ); - extern void SGetInputFocusReply(ClientPtr /* pClient */ , int /* size */ , xGetInputFocusReply * /* pRep */ );