dix: write out X_GetWindowAttributes 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 17:33:46 +02:00
parent 71139c015e
commit f59ffc7c93
5 changed files with 48 additions and 76 deletions

View File

@ -789,25 +789,6 @@ ProcChangeWindowAttributes(ClientPtr client)
stuff->valueMask, (XID *) &stuff[1], client); stuff->valueMask, (XID *) &stuff[1], client);
} }
int
ProcGetWindowAttributes(ClientPtr client)
{
WindowPtr pWin;
REQUEST(xResourceReq);
xGetWindowAttributesReply wa;
int rc;
REQUEST_SIZE_MATCH(xResourceReq);
rc = dixLookupWindow(&pWin, stuff->id, client, DixGetAttrAccess);
if (rc != Success)
return rc;
memset(&wa, 0, sizeof(xGetWindowAttributesReply));
GetWindowAttributes(pWin, client, &wa);
WriteReplyToClient(client, sizeof(xGetWindowAttributesReply), &wa);
return Success;
}
int int
ProcDestroyWindow(ClientPtr client) ProcDestroyWindow(ClientPtr client)
{ {

View File

@ -183,24 +183,6 @@ SGenericReply(ClientPtr pClient, int size, xGenericReply * pRep)
WriteToClient(pClient, size, pRep); WriteToClient(pClient, size, pRep);
} }
/* Extra-large reply */
void _X_COLD
SGetWindowAttributesReply(ClientPtr pClient, int size,
xGetWindowAttributesReply * pRep)
{
swaps(&pRep->sequenceNumber);
swapl(&pRep->length);
swapl(&pRep->visualID);
swaps(&pRep->class);
swapl(&pRep->backingBitPlanes);
swapl(&pRep->backingPixel);
swapl(&pRep->colormap);
swapl(&pRep->allEventMasks);
swapl(&pRep->yourEventMask);
swaps(&pRep->doNotPropagateMask);
WriteToClient(pClient, size, pRep);
}
void _X_COLD void _X_COLD
SQueryTreeReply(ClientPtr pClient, int size, xQueryTreeReply * pRep) SQueryTreeReply(ClientPtr pClient, int size, xQueryTreeReply * pRep)
{ {

View File

@ -718,7 +718,7 @@ ReplySwapPtr ReplySwapVector[256] = {
ReplyNotSwappd, ReplyNotSwappd,
ReplyNotSwappd, ReplyNotSwappd,
ReplyNotSwappd, ReplyNotSwappd,
(ReplySwapPtr) SGetWindowAttributesReply, ReplyNotSwappd,
ReplyNotSwappd, ReplyNotSwappd,
ReplyNotSwappd, /* 5 */ ReplyNotSwappd, /* 5 */
ReplyNotSwappd, ReplyNotSwappd,

View File

@ -100,6 +100,7 @@ Equipment Corporation.
#include "dix/colormap_priv.h" #include "dix/colormap_priv.h"
#include "dix/cursor_priv.h" #include "dix/cursor_priv.h"
#include "dix/dispatch.h"
#include "dix/dix_priv.h" #include "dix/dix_priv.h"
#include "dix/exevents_priv.h" #include "dix/exevents_priv.h"
#include "dix/input_priv.h" #include "dix/input_priv.h"
@ -1582,42 +1583,55 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client)
return error; return error;
} }
/***** int
* GetWindowAttributes ProcGetWindowAttributes(ClientPtr client)
* Notice that this is different than ChangeWindowAttributes
*****/
void
GetWindowAttributes(WindowPtr pWin, ClientPtr client,
xGetWindowAttributesReply * wa)
{ {
wa->type = X_Reply; REQUEST(xResourceReq);
wa->bitGravity = pWin->bitGravity; REQUEST_SIZE_MATCH(xResourceReq);
wa->winGravity = pWin->winGravity;
wa->backingStore = pWin->backingStore;
wa->length = bytes_to_int32(sizeof(xGetWindowAttributesReply) -
sizeof(xGenericReply));
wa->sequenceNumber = client->sequence;
wa->backingBitPlanes = wBackingBitPlanes(pWin);
wa->backingPixel = wBackingPixel(pWin);
wa->saveUnder = (BOOL) pWin->saveUnder;
wa->override = pWin->overrideRedirect;
if (!pWin->mapped)
wa->mapState = IsUnmapped;
else if (pWin->realized)
wa->mapState = IsViewable;
else
wa->mapState = IsUnviewable;
wa->colormap = wColormap(pWin); WindowPtr pWin;
wa->mapInstalled = (wa->colormap == None) ? xFalse int rc = dixLookupWindow(&pWin, stuff->id, client, DixGetAttrAccess);
: IsMapInstalled(wa->colormap, pWin); if (rc != Success)
return rc;
wa->yourEventMask = EventMaskForClient(pWin, client); xGetWindowAttributesReply rep = {
wa->allEventMasks = pWin->eventMask | wOtherEventMasks(pWin); .type = X_Reply,
wa->doNotPropagateMask = wDontPropagateMask(pWin); .bitGravity = pWin->bitGravity,
wa->class = pWin->drawable.class; .winGravity = pWin->winGravity,
wa->visualID = wVisual(pWin); .backingStore = pWin->backingStore,
.length = bytes_to_int32(sizeof(xGetWindowAttributesReply) -
sizeof(xGenericReply)),
.sequenceNumber = client->sequence,
.backingBitPlanes = wBackingBitPlanes(pWin),
.backingPixel = wBackingPixel(pWin),
.saveUnder = (BOOL) pWin->saveUnder,
.override = pWin->overrideRedirect,
.mapState = (!pWin->mapped ? IsUnmapped :
(pWin->realized ? IsViewable : IsUnviewable)),
.colormap = wColormap(pWin),
.mapInstalled = (wColormap(pWin) == None) ? xFalse
: IsMapInstalled(wColormap(pWin), pWin),
.yourEventMask = EventMaskForClient(pWin, client),
.allEventMasks = pWin->eventMask | wOtherEventMasks(pWin),
.doNotPropagateMask = wDontPropagateMask(pWin),
.class = pWin->drawable.class,
.visualID = wVisual(pWin),
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.visualID);
swaps(&rep.class);
swapl(&rep.backingBitPlanes);
swapl(&rep.backingPixel);
swapl(&rep.colormap);
swapl(&rep.allEventMasks);
swapl(&rep.yourEventMask);
swaps(&rep.doNotPropagateMask);
}
WriteToClient(client, sizeof(rep), &rep);
return Success;
} }
WindowPtr WindowPtr

View File

@ -42,11 +42,6 @@ extern void SGenericReply(ClientPtr /* pClient */ ,
int /* size */ , int /* size */ ,
xGenericReply * /* pRep */ ); xGenericReply * /* pRep */ );
extern void SGetWindowAttributesReply(ClientPtr /* pClient */ ,
int /* size */ ,
xGetWindowAttributesReply *
/* pRep */ );
extern void SQueryTreeReply(ClientPtr /* pClient */ , extern void SQueryTreeReply(ClientPtr /* pClient */ ,
int /* size */ , int /* size */ ,
xQueryTreeReply * /* pRep */ ); xQueryTreeReply * /* pRep */ );