Add swapped dispatch for randr 1.2 requests

This commit is contained in:
Julien Cristau 2008-08-21 01:32:03 +02:00
commit 01264f1792
3 changed files with 215 additions and 69 deletions

View file

@ -406,12 +406,13 @@ ProcRRListOutputProperties (ClientPtr client)
int n;
swaps (&rep.sequenceNumber, n);
swapl (&rep.length, n);
swaps (&rep.nAtoms, n);
}
temppAtoms = pAtoms;
for (prop = output->properties; prop; prop = prop->next)
*temppAtoms++ = prop->propertyName;
WriteReplyToClient(client, sizeof(xRRListOutputPropertiesReply), &rep);
WriteToClient(client, sizeof(xRRListOutputPropertiesReply), (char*)&rep);
if (numProps)
{
client->pSwapReplyFunc = (ReplySwapPtr)Swap32Write;
@ -428,6 +429,7 @@ ProcRRQueryOutputProperty (ClientPtr client)
xRRQueryOutputPropertyReply rep;
RROutputPtr output;
RRPropertyPtr prop;
char *extra;
REQUEST_SIZE_MATCH(xRRQueryOutputPropertyReq);
@ -440,6 +442,11 @@ ProcRRQueryOutputProperty (ClientPtr client)
if (!prop)
return BadName;
if (prop->num_valid) {
extra = xalloc(prop->num_valid * sizeof(INT32));
if (!extra)
return BadAlloc;
}
rep.type = X_Reply;
rep.length = prop->num_valid;
rep.sequenceNumber = client->sequence;
@ -452,12 +459,14 @@ ProcRRQueryOutputProperty (ClientPtr client)
swaps (&rep.sequenceNumber, n);
swapl (&rep.length, n);
}
WriteReplyToClient (client, sizeof (xRRQueryOutputPropertyReply), &rep);
WriteToClient (client, sizeof (xRRQueryOutputPropertyReply), (char*)&rep);
if (prop->num_valid)
{
memcpy(extra, prop->valid_values, prop->num_valid * sizeof(INT32));
client->pSwapReplyFunc = (ReplySwapPtr)Swap32Write;
WriteSwappedDataToClient(client, prop->num_valid * sizeof(INT32),
prop->valid_values);
extra);
xfree(extra);
}
return(client->noClientException);
}
@ -572,6 +581,7 @@ ProcRRGetOutputProperty (ClientPtr client)
unsigned long n, len, ind;
RROutputPtr output;
xRRGetOutputPropertyReply reply;
char *extra;
REQUEST_SIZE_MATCH(xRRGetOutputPropertyReq);
if (stuff->delete)
@ -611,7 +621,16 @@ ProcRRGetOutputProperty (ClientPtr client)
reply.bytesAfter = 0;
reply.propertyType = None;
reply.format = 0;
WriteReplyToClient(client, sizeof(xRRGetOutputPropertyReply), &reply);
if (client->swapped) {
int n;
swaps(&reply.sequenceNumber, n);
swapl(&reply.length, n);
swapl(&reply.propertyType, n);
swapl(&reply.bytesAfter, n);
swapl(&reply.nItems, n);
}
WriteToClient(client, sizeof(xRRGetOutputPropertyReply), &reply);
return(client->noClientException);
}
@ -634,7 +653,16 @@ ProcRRGetOutputProperty (ClientPtr client)
reply.length = 0;
reply.nItems = 0;
reply.propertyType = prop_value->type;
WriteReplyToClient(client, sizeof(xRRGetOutputPropertyReply), &reply);
if (client->swapped) {
int n;
swaps(&reply.sequenceNumber, n);
swapl(&reply.length, n);
swapl(&reply.propertyType, n);
swapl(&reply.bytesAfter, n);
swapl(&reply.nItems, n);
}
WriteToClient(client, sizeof(xRRGetOutputPropertyReply), &reply);
return(client->noClientException);
}
@ -655,6 +683,11 @@ ProcRRGetOutputProperty (ClientPtr client)
len = min(n - ind, 4 * stuff->longLength);
if (len) {
extra = xalloc(len);
if (!extra)
return BadAlloc;
}
reply.bytesAfter = n - (ind + len);
reply.format = prop_value->format;
reply.length = (len + 3) >> 2;
@ -677,16 +710,27 @@ ProcRRGetOutputProperty (ClientPtr client)
RRDeliverEvent (output->pScreen, (xEvent *) &event, RROutputPropertyNotifyMask);
}
WriteReplyToClient(client, sizeof(xGenericReply), &reply);
if (client->swapped) {
int n;
swaps(&reply.sequenceNumber, n);
swapl(&reply.length, n);
swapl(&reply.propertyType, n);
swapl(&reply.bytesAfter, n);
swapl(&reply.nItems, n);
}
WriteToClient(client, sizeof(xGenericReply), &reply);
if (len)
{
memcpy(extra, (char *)prop_value->data + ind, len);
switch (reply.format) {
case 32: client->pSwapReplyFunc = (ReplySwapPtr)CopySwap32Write; break;
case 16: client->pSwapReplyFunc = (ReplySwapPtr)CopySwap16Write; break;
default: client->pSwapReplyFunc = (ReplySwapPtr)WriteToClient; break;
}
WriteSwappedDataToClient(client, len,
(char *)prop_value->data + ind);
extra);
xfree(extra);
}
if (stuff->delete && (reply.bytesAfter == 0))