dix: write out X_AllocColor 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-03 19:43:40 +02:00
parent 725bb2d20d
commit f062333422
4 changed files with 30 additions and 37 deletions

View File

@ -2627,30 +2627,38 @@ ProcAllocColor(ClientPtr client)
REQUEST_SIZE_MATCH(xAllocColorReq);
rc = dixLookupResourceByType((void **) &pmap, stuff->cmap, X11_RESTYPE_COLORMAP,
client, DixAddAccess);
if (rc == Success) {
xAllocColorReply acr = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.red = stuff->red,
.green = stuff->green,
.blue = stuff->blue,
.pixel = 0
};
if ((rc = AllocColor(pmap, &acr.red, &acr.green, &acr.blue,
&acr.pixel, client->index)))
return rc;
#ifdef XINERAMA
if (noPanoramiXExtension || !pmap->pScreen->myNum)
#endif /* XINERAMA */
WriteReplyToClient(client, sizeof(xAllocColorReply), &acr);
return Success;
}
else {
if (rc != Success) {
client->errorValue = stuff->cmap;
return rc;
}
xAllocColorReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.red = stuff->red,
.green = stuff->green,
.blue = stuff->blue,
.pixel = 0
};
if ((rc = AllocColor(pmap, &rep.red, &rep.green, &rep.blue,
&rep.pixel, client->index)))
return rc;
if (client->swapped) {
swaps(&rep.sequenceNumber);
swaps(&rep.red);
swaps(&rep.green);
swaps(&rep.blue);
swapl(&rep.pixel);
}
#ifdef XINERAMA
if (noPanoramiXExtension || !pmap->pScreen->myNum)
#endif /* XINERAMA */
WriteToClient(client, sizeof(rep), &rep);
return Success;
}
int

View File

@ -310,17 +310,6 @@ SGetFontPathReply(ClientPtr pClient, int size, xGetFontPathReply * pRep)
WriteToClient(pClient, size, pRep);
}
void _X_COLD
SAllocColorReply(ClientPtr pClient, int size, xAllocColorReply * pRep)
{
swaps(&pRep->sequenceNumber);
swaps(&pRep->red);
swaps(&pRep->green);
swaps(&pRep->blue);
swapl(&pRep->pixel);
WriteToClient(pClient, size, pRep);
}
void _X_COLD
SAllocNamedColorReply(ClientPtr pClient, int size, xAllocNamedColorReply * pRep)
{

View File

@ -799,7 +799,7 @@ ReplySwapPtr ReplySwapVector[256] = {
ReplyNotSwappd,
ReplyNotSwappd,
ReplyNotSwappd,
(ReplySwapPtr) SAllocColorReply,
ReplyNotSwappd,
(ReplySwapPtr) SAllocNamedColorReply, /* 85 */
(ReplySwapPtr) SAllocColorCellsReply,
(ReplySwapPtr) SAllocColorPlanesReply,

View File

@ -68,10 +68,6 @@ extern void SGetFontPathReply(ClientPtr /* pClient */ ,
int /* size */ ,
xGetFontPathReply * /* pRep */ );
extern void SAllocColorReply(ClientPtr /* pClient */ ,
int /* size */ ,
xAllocColorReply * /* pRep */ );
extern void SAllocNamedColorReply(ClientPtr /* pClient */ ,
int /* size */ ,
xAllocNamedColorReply * /* pRep */