summaryrefslogtreecommitdiff
path: root/randr/rrproperty.c
diff options
context:
space:
mode:
authorJulien Cristau <jcristau@debian.org>2008-08-21 01:32:03 +0200
committerJulien Cristau <jcristau@debian.org>2008-08-21 09:24:02 +0200
commit01264f17925005969c3b71ca945fc1014bcd8c8e (patch)
tree7caeee6cafbbd138380b6c257677a5f54239a90a /randr/rrproperty.c
parente02f864fdf19a5ab1682336be343c57fdb69ef43 (diff)
Add swapped dispatch for randr 1.2 requests
Diffstat (limited to 'randr/rrproperty.c')
-rw-r--r--randr/rrproperty.c58
1 files changed, 51 insertions, 7 deletions
diff --git a/randr/rrproperty.c b/randr/rrproperty.c
index 9bb7081ca..ceb1340eb 100644
--- a/randr/rrproperty.c
+++ b/randr/rrproperty.c
@@ -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))