dix: write out X_QueryColors 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 <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2025-04-04 15:52:04 +02:00
parent 6e657b2ca5
commit 707fd2b1d7
4 changed files with 12 additions and 48 deletions

View File

@ -2952,7 +2952,6 @@ ProcQueryColors(ClientPtr client)
if (rc == Success) {
int count;
xrgb *prgbs;
xQueryColorsReply qcr;
count =
bytes_to_int32((client->req_len << 2) - sizeof(xQueryColorsReq));
@ -2964,20 +2963,25 @@ ProcQueryColors(ClientPtr client)
free(prgbs);
return rc;
}
qcr = (xQueryColorsReply) {
xQueryColorsReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = bytes_to_int32(count * sizeof(xrgb)),
.nColors = count
};
WriteReplyToClient(client, sizeof(xQueryColorsReply), &qcr);
if (count) {
client->pSwapReplyFunc = (ReplySwapPtr) SQColorsExtend;
WriteSwappedDataToClient(client, count * sizeof(xrgb), prgbs);
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swaps(&rep.nColors);
SwapShorts((short*)prgbs, count * 4); // xrgb = 4 shorts
}
WriteToClient(client, sizeof(rep), &rep);
WriteToClient(client, count * sizeof(xrgb), prgbs);
free(prgbs);
return Success;
}
else {
client->errorValue = stuff->cmap;

View File

@ -310,38 +310,6 @@ SGetFontPathReply(ClientPtr pClient, int size, xGetFontPathReply * pRep)
WriteToClient(pClient, size, pRep);
}
static void _X_COLD
SwapRGB(xrgb * prgb)
{
swaps(&prgb->red);
swaps(&prgb->green);
swaps(&prgb->blue);
}
void _X_COLD
SQColorsExtend(ClientPtr pClient, int size, xrgb * prgb)
{
int i, n;
xrgb *prgbT;
n = size / sizeof(xrgb);
prgbT = prgb;
for (i = 0; i < n; i++) {
SwapRGB(prgbT);
prgbT++;
}
WriteToClient(pClient, size, prgb);
}
void _X_COLD
SQueryColorsReply(ClientPtr pClient, int size, xQueryColorsReply * pRep)
{
swaps(&pRep->sequenceNumber);
swapl(&pRep->length);
swaps(&pRep->nColors);
WriteToClient(pClient, size, pRep);
}
void _X_COLD
SLookupColorReply(ClientPtr pClient, int size, xLookupColorReply * pRep)
{

View File

@ -806,7 +806,7 @@ ReplySwapPtr ReplySwapVector[256] = {
ReplyNotSwappd,
ReplyNotSwappd,
ReplyNotSwappd, /* 90 */
(ReplySwapPtr) SQueryColorsReply,
ReplyNotSwappd,
(ReplySwapPtr) SLookupColorReply,
ReplyNotSwappd,
ReplyNotSwappd,

View File

@ -68,14 +68,6 @@ extern void SGetFontPathReply(ClientPtr /* pClient */ ,
int /* size */ ,
xGetFontPathReply * /* pRep */ );
extern void SQColorsExtend(ClientPtr /* pClient */ ,
int /* size */ ,
xrgb * /* prgb */ );
extern void SQueryColorsReply(ClientPtr /* pClient */ ,
int /* size */ ,
xQueryColorsReply * /* pRep */ );
extern void SLookupColorReply(ClientPtr /* pClient */ ,
int /* size */ ,
xLookupColorReply * /* pRep */ );