Xext: shape: use REPLY_*() macros for preparing / sending replies

Use the new macros for preparing and sending replies to clients.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2024-07-04 02:38:50 +02:00
parent 7c92bf3937
commit 87c9317714

View File

@ -620,7 +620,6 @@ ProcShapeQueryExtents(ClientPtr client)
REQUEST_FIELD_CARD32(window); REQUEST_FIELD_CARD32(window);
WindowPtr pWin; WindowPtr pWin;
xShapeQueryExtentsReply rep;
BoxRec extents, *pExtents; BoxRec extents, *pExtents;
int rc; int rc;
RegionPtr region; RegionPtr region;
@ -628,13 +627,12 @@ ProcShapeQueryExtents(ClientPtr client)
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success) if (rc != Success)
return rc; return rc;
rep = (xShapeQueryExtentsReply) {
.type = X_Reply, xShapeQueryExtentsReply rep = {
.sequenceNumber = client->sequence,
.length = 0,
.boundingShaped = (wBoundingShape(pWin) != 0), .boundingShaped = (wBoundingShape(pWin) != 0),
.clipShaped = (wClipShape(pWin) != 0) .clipShaped = (wClipShape(pWin) != 0)
}; };
if ((region = wBoundingShape(pWin))) { if ((region = wBoundingShape(pWin))) {
/* this is done in two steps because of a compiler bug on SunOS 4.1.3 */ /* this is done in two steps because of a compiler bug on SunOS 4.1.3 */
pExtents = RegionExtents(region); pExtents = RegionExtents(region);
@ -665,20 +663,16 @@ ProcShapeQueryExtents(ClientPtr client)
rep.yClipShape = extents.y1; rep.yClipShape = extents.y1;
rep.widthClipShape = extents.x2 - extents.x1; rep.widthClipShape = extents.x2 - extents.x1;
rep.heightClipShape = extents.y2 - extents.y1; rep.heightClipShape = extents.y2 - extents.y1;
if (client->swapped) {
swaps(&rep.sequenceNumber); REPLY_FIELD_CARD16(xBoundingShape);
swapl(&rep.length); REPLY_FIELD_CARD16(yBoundingShape);
swaps(&rep.xBoundingShape); REPLY_FIELD_CARD16(widthBoundingShape);
swaps(&rep.yBoundingShape); REPLY_FIELD_CARD16(heightBoundingShape);
swaps(&rep.widthBoundingShape); REPLY_FIELD_CARD16(xClipShape);
swaps(&rep.heightBoundingShape); REPLY_FIELD_CARD16(yClipShape);
swaps(&rep.xClipShape); REPLY_FIELD_CARD16(widthClipShape);
swaps(&rep.yClipShape); REPLY_FIELD_CARD16(heightClipShape);
swaps(&rep.widthClipShape); REPLY_SEND_RET_SUCCESS();
swaps(&rep.heightClipShape);
}
WriteToClient(client, sizeof(xShapeQueryExtentsReply), &rep);
return Success;
} }
/*ARGSUSED*/ static int /*ARGSUSED*/ static int
@ -904,7 +898,6 @@ ProcShapeInputSelected(ClientPtr client)
WindowPtr pWin; WindowPtr pWin;
ShapeEventPtr pShapeEvent, *pHead; ShapeEventPtr pShapeEvent, *pHead;
int enabled, rc; int enabled, rc;
xShapeInputSelectedReply rep;
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success) if (rc != Success)
@ -922,18 +915,12 @@ ProcShapeInputSelected(ClientPtr client)
} }
} }
} }
rep = (xShapeInputSelectedReply) {
.type = X_Reply, xShapeInputSelectedReply rep = {
.enabled = enabled, .enabled = enabled,
.sequenceNumber = client->sequence,
.length = 0
}; };
if (client->swapped) {
swaps(&rep.sequenceNumber); REPLY_SEND_RET_SUCCESS();
swapl(&rep.length);
}
WriteToClient(client, sizeof(xShapeInputSelectedReply), &rep);
return Success;
} }
static int static int
@ -943,7 +930,6 @@ ProcShapeGetRectangles(ClientPtr client)
REQUEST_FIELD_CARD32(window); REQUEST_FIELD_CARD32(window);
WindowPtr pWin; WindowPtr pWin;
xShapeGetRectanglesReply rep;
xRectangle *rects = NULL; xRectangle *rects = NULL;
int nrects, i, rc; int nrects, i, rc;
RegionPtr region; RegionPtr region;
@ -1008,21 +994,15 @@ ProcShapeGetRectangles(ClientPtr client)
} }
} }
} }
rep = (xShapeGetRectanglesReply) {
.type = X_Reply, xShapeGetRectanglesReply rep = {
.ordering = YXBanded, .ordering = YXBanded,
.sequenceNumber = client->sequence,
.length = bytes_to_int32(nrects * sizeof(xRectangle)),
.nrects = nrects .nrects = nrects
}; };
if (client->swapped) {
swaps(&rep.sequenceNumber); REPLY_BUF_CARD16(rects, (unsigned long) nrects * 4);
swapl(&rep.length); REPLY_FIELD_CARD32(nrects);
swapl(&rep.nrects); REPLY_SEND_EXTRA(rects, nrects * sizeof(xRectangle));
SwapShorts((short *) rects, (unsigned long) nrects * 4);
}
WriteToClient(client, sizeof(rep), &rep);
WriteToClient(client, nrects * sizeof(xRectangle), rects);
free(rects); free(rects);
return Success; return Success;
} }