From 1f2cf6fe4b9e5b8c48538c21b037ba1a31b154ae Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Thu, 3 Apr 2025 19:23:22 +0200 Subject: [PATCH] dix: write out X_QueryTextExtents 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/dispatch.c | 17 ++++++++++++++--- dix/swaprep.c | 15 --------------- dix/tables.c | 2 +- include/swaprep.h | 5 ----- 4 files changed, 15 insertions(+), 24 deletions(-) diff --git a/dix/dispatch.c b/dix/dispatch.c index 3a88640f6..e9bec35f7 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -1375,7 +1375,6 @@ ProcQueryFont(ClientPtr client) int ProcQueryTextExtents(ClientPtr client) { - xQueryTextExtentsReply reply; FontPtr pFont; ExtentInfoRec info; unsigned long length; @@ -1397,7 +1396,8 @@ ProcQueryTextExtents(ClientPtr client) } if (!xfont2_query_text_extents(pFont, length, (unsigned char *) &stuff[1], &info)) return BadAlloc; - reply = (xQueryTextExtentsReply) { + + xQueryTextExtentsReply rep = { .type = X_Reply, .drawDirection = info.drawDirection, .sequenceNumber = client->sequence, @@ -1410,7 +1410,18 @@ ProcQueryTextExtents(ClientPtr client) .overallLeft = info.overallLeft, .overallRight = info.overallRight }; - WriteReplyToClient(client, sizeof(xQueryTextExtentsReply), &reply); + + if (client->swapped) { + swaps(&rep.sequenceNumber); + swaps(&rep.fontAscent); + swaps(&rep.fontDescent); + swaps(&rep.overallAscent); + swaps(&rep.overallDescent); + swapl(&rep.overallWidth); + swapl(&rep.overallLeft); + swapl(&rep.overallRight); + } + WriteToClient(client, sizeof(rep), &rep); return Success; } diff --git a/dix/swaprep.c b/dix/swaprep.c index 017a901e8..790261b27 100644 --- a/dix/swaprep.c +++ b/dix/swaprep.c @@ -301,21 +301,6 @@ SwapFont(xQueryFontReply * pr, Bool hasGlyphs) } } -void _X_COLD -SQueryTextExtentsReply(ClientPtr pClient, int size, - xQueryTextExtentsReply * pRep) -{ - swaps(&pRep->sequenceNumber); - swaps(&pRep->fontAscent); - swaps(&pRep->fontDescent); - swaps(&pRep->overallAscent); - swaps(&pRep->overallDescent); - swapl(&pRep->overallWidth); - swapl(&pRep->overallLeft); - swapl(&pRep->overallRight); - WriteToClient(pClient, size, pRep); -} - void _X_COLD SGetFontPathReply(ClientPtr pClient, int size, xGetFontPathReply * pRep) { diff --git a/dix/tables.c b/dix/tables.c index 0dc04c41c..9def465f1 100644 --- a/dix/tables.c +++ b/dix/tables.c @@ -763,7 +763,7 @@ ReplySwapPtr ReplySwapVector[256] = { ReplyNotSwappd, /* 45 */ ReplyNotSwappd, ReplyNotSwappd, - (ReplySwapPtr) SQueryTextExtentsReply, + ReplyNotSwappd, ReplyNotSwappd, ReplyNotSwappd, /* 50 */ ReplyNotSwappd, diff --git a/include/swaprep.h b/include/swaprep.h index 78ead5c5f..ba0475510 100644 --- a/include/swaprep.h +++ b/include/swaprep.h @@ -64,11 +64,6 @@ extern void SGetInputFocusReply(ClientPtr /* pClient */ , int /* size */ , xGetInputFocusReply * /* pRep */ ); -extern void SQueryTextExtentsReply(ClientPtr /* pClient */ , - int /* size */ , - xQueryTextExtentsReply * /* pRep */ - ); - extern void SGetFontPathReply(ClientPtr /* pClient */ , int /* size */ , xGetFontPathReply * /* pRep */ );