Skip to content
Snippets Groups Projects

xfixes: clean up request handling

1 unresolved thread
7 files
+ 200
148
Compare changes
  • Side-by-side
  • Inline
Files
7
+ 83
98
@@ -229,11 +229,10 @@ XFixesSelectCursorInput(ClientPtr pClient, WindowPtr pWindow, CARD32 eventMask)
return Success;
}
if (!e) {
e = (CursorEventPtr) malloc(sizeof(CursorEventRec));
e = (CursorEventPtr) calloc(1, sizeof(CursorEventRec));
if (!e)
return BadAlloc;
e->next = 0;
e->pClient = pClient;
e->pWindow = pWindow;
e->clientResource = FakeClientID(pClient->index);
@@ -302,7 +301,7 @@ SProcXFixesSelectCursorInput(ClientPtr client)
REQUEST_SIZE_MATCH(xXFixesSelectCursorInputReq);
swapl(&stuff->window);
swapl(&stuff->eventMask);
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
return ProcXFixesSelectCursorInput(client);
}
void _X_COLD
@@ -361,9 +360,7 @@ int
ProcXFixesGetCursorImage(ClientPtr client)
{
/* REQUEST(xXFixesGetCursorImageReq); */
xXFixesGetCursorImageReply *rep;
CursorPtr pCursor;
CARD32 *image;
int npixels, width, height, rc, x, y;
REQUEST_SIZE_MATCH(xXFixesGetCursorImageReq);
@@ -378,49 +375,44 @@ ProcXFixesGetCursorImage(ClientPtr client)
width = pCursor->bits->width;
height = pCursor->bits->height;
npixels = width * height;
rep = calloc(1,
sizeof(xXFixesGetCursorImageReply) + npixels * sizeof(CARD32));
if (!rep)
CARD32 *image = calloc(npixels, sizeof(CARD32));
if (!image)
return BadAlloc;
rep->type = X_Reply;
rep->sequenceNumber = client->sequence;
rep->length = npixels;
rep->width = width;
rep->height = height;
rep->x = x;
rep->y = y;
rep->xhot = pCursor->bits->xhot;
rep->yhot = pCursor->bits->yhot;
rep->cursorSerial = pCursor->serialNumber;
image = (CARD32 *) (rep + 1);
CopyCursorToImage(pCursor, image);
xXFixesGetCursorImageReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = npixels,
.width = width,
.height = height,
.x = x,
.y = y,
.xhot = pCursor->bits->xhot,
.yhot = pCursor->bits->yhot,
.cursorSerial = pCursor->serialNumber,
};
if (client->swapped) {
swaps(&rep->sequenceNumber);
swapl(&rep->length);
swaps(&rep->x);
swaps(&rep->y);
swaps(&rep->width);
swaps(&rep->height);
swaps(&rep->xhot);
swaps(&rep->yhot);
swapl(&rep->cursorSerial);
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swaps(&rep.x);
swaps(&rep.y);
swaps(&rep.width);
swaps(&rep.height);
swaps(&rep.xhot);
swaps(&rep.yhot);
swapl(&rep.cursorSerial);
SwapLongs(image, npixels);
}
WriteToClient(client,
sizeof(xXFixesGetCursorImageReply) + (npixels << 2), rep);
free(rep);
WriteToClient(client, sizeof(xXFixesGetCursorImageReply), &rep);
WriteToClient(client, npixels * sizeof(CARD32), image);
free(image);
return Success;
}
int _X_COLD
SProcXFixesGetCursorImage(ClientPtr client)
{
REQUEST(xXFixesGetCursorImageReq);
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}
int
ProcXFixesSetCursorName(ClientPtr client)
{
@@ -448,16 +440,15 @@ SProcXFixesSetCursorName(ClientPtr client)
REQUEST_AT_LEAST_SIZE(xXFixesSetCursorNameReq);
swapl(&stuff->cursor);
swaps(&stuff->nbytes);
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
return ProcXFixesSetCursorName(client);
}
int
ProcXFixesGetCursorName(ClientPtr client)
{
CursorPtr pCursor;
xXFixesGetCursorNameReply reply;
REQUEST(xXFixesGetCursorNameReq);
CursorPtr pCursor;
const char *str;
int len;
@@ -469,7 +460,7 @@ ProcXFixesGetCursorName(ClientPtr client)
str = "";
len = strlen(str);
reply = (xXFixesGetCursorNameReply) {
xXFixesGetCursorNameReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = bytes_to_int32(len),
@@ -477,12 +468,12 @@ ProcXFixesGetCursorName(ClientPtr client)
.nbytes = len
};
if (client->swapped) {
swaps(&reply.sequenceNumber);
swapl(&reply.length);
swapl(&reply.atom);
swaps(&reply.nbytes);
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.atom);
swaps(&rep.nbytes);
}
WriteReplyToClient(client, sizeof(xXFixesGetCursorNameReply), &reply);
WriteReplyToClient(client, sizeof(xXFixesGetCursorNameReply), &rep);
WriteToClient(client, len, str);
return Success;
@@ -494,19 +485,17 @@ SProcXFixesGetCursorName(ClientPtr client)
REQUEST(xXFixesGetCursorNameReq);
REQUEST_SIZE_MATCH(xXFixesGetCursorNameReq);
swapl(&stuff->cursor);
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
return ProcXFixesGetCursorName(client);
}
int
ProcXFixesGetCursorImageAndName(ClientPtr client)
{
/* REQUEST(xXFixesGetCursorImageAndNameReq); */
xXFixesGetCursorImageAndNameReply *rep;
CursorPtr pCursor;
CARD32 *image;
int npixels;
const char *name;
int nbytes, nbytesRound;
int nbytes;
int width, height;
int rc, x, y;
@@ -524,55 +513,51 @@ ProcXFixesGetCursorImageAndName(ClientPtr client)
npixels = width * height;
name = pCursor->name ? NameForAtom(pCursor->name) : "";
nbytes = strlen(name);
nbytesRound = pad_to_int32(nbytes);
rep = calloc(1, sizeof(xXFixesGetCursorImageAndNameReply) +
npixels * sizeof(CARD32) + nbytesRound);
if (!rep)
// pixmap plus name (padded to 4 bytes)
const size_t image_size = (npixels + bytes_to_int32(nbytes)) * sizeof(CARD32);
CARD32 *image = calloc(1, image_size);
if (!image)
return BadAlloc;
rep->type = X_Reply;
rep->sequenceNumber = client->sequence;
rep->length = npixels + bytes_to_int32(nbytesRound);
rep->width = width;
rep->height = height;
rep->x = x;
rep->y = y;
rep->xhot = pCursor->bits->xhot;
rep->yhot = pCursor->bits->yhot;
rep->cursorSerial = pCursor->serialNumber;
rep->cursorName = pCursor->name;
rep->nbytes = nbytes;
image = (CARD32 *) (rep + 1);
CopyCursorToImage(pCursor, image);
memcpy((image + npixels), name, nbytes);
xXFixesGetCursorImageAndNameReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = bytes_to_int32(image_size),
.width = width,
.height = height,
.x = x,
.y = y,
.xhot = pCursor->bits->xhot,
.yhot = pCursor->bits->yhot,
.cursorSerial = pCursor->serialNumber,
.cursorName = pCursor->name,
.nbytes = nbytes,
};
if (client->swapped) {
swaps(&rep->sequenceNumber);
swapl(&rep->length);
swaps(&rep->x);
swaps(&rep->y);
swaps(&rep->width);
swaps(&rep->height);
swaps(&rep->xhot);
swaps(&rep->yhot);
swapl(&rep->cursorSerial);
swapl(&rep->cursorName);
swaps(&rep->nbytes);
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swaps(&rep.x);
swaps(&rep.y);
swaps(&rep.width);
swaps(&rep.height);
swaps(&rep.xhot);
swaps(&rep.yhot);
swapl(&rep.cursorSerial);
swapl(&rep.cursorName);
swaps(&rep.nbytes);
SwapLongs(image, npixels);
}
WriteToClient(client, sizeof(xXFixesGetCursorImageAndNameReply) +
(npixels << 2) + nbytesRound, rep);
free(rep);
WriteToClient(client, sizeof(xXFixesGetCursorImageAndNameReply), &rep);
WriteToClient(client, image_size, image);
free(image);
return Success;
}
int _X_COLD
SProcXFixesGetCursorImageAndName(ClientPtr client)
{
REQUEST(xXFixesGetCursorImageAndNameReq);
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}
/*
* Find every cursor reference in the system, ask testCursor
* whether it should be replaced with a reference to pCursor.
@@ -699,7 +684,7 @@ SProcXFixesChangeCursor(ClientPtr client)
REQUEST_SIZE_MATCH(xXFixesChangeCursorReq);
swapl(&stuff->source);
swapl(&stuff->destination);
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
return ProcXFixesChangeCursor(client);
}
static Bool
@@ -736,7 +721,7 @@ SProcXFixesChangeCursorByName(ClientPtr client)
REQUEST_AT_LEAST_SIZE(xXFixesChangeCursorByNameReq);
swapl(&stuff->source);
swaps(&stuff->nbytes);
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
return ProcXFixesChangeCursorByName(client);
}
/*
@@ -892,7 +877,7 @@ SProcXFixesHideCursor(ClientPtr client)
REQUEST(xXFixesHideCursorReq);
REQUEST_SIZE_MATCH(xXFixesHideCursorReq);
swapl(&stuff->window);
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
return ProcXFixesHideCursor(client);
}
int
@@ -940,7 +925,7 @@ SProcXFixesShowCursor(ClientPtr client)
REQUEST(xXFixesShowCursorReq);
REQUEST_SIZE_MATCH(xXFixesShowCursorReq);
swapl(&stuff->window);
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
return ProcXFixesShowCursor(client);
}
static int
@@ -1026,7 +1011,7 @@ SProcXFixesCreatePointerBarrier(ClientPtr client)
swaps(in_devices + i);
}
return ProcXFixesVector[stuff->xfixesReqType] (client);
return ProcXFixesCreatePointerBarrier(client);
}
int
@@ -1045,7 +1030,7 @@ SProcXFixesDestroyPointerBarrier(ClientPtr client)
REQUEST(xXFixesDestroyPointerBarrierReq);
REQUEST_SIZE_MATCH(xXFixesDestroyPointerBarrierReq);
swapl(&stuff->barrier);
return ProcXFixesVector[stuff->xfixesReqType] (client);
return ProcXFixesDestroyPointerBarrier(client);
}
Bool
Loading