Add swapped dispatch for randr 1.2 requests

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

View File

@ -894,6 +894,7 @@ ProcRRGetCrtcGamma (ClientPtr client)
RRCrtcPtr crtc; RRCrtcPtr crtc;
int n; int n;
unsigned long len; unsigned long len;
char *extra;
REQUEST_SIZE_MATCH(xRRGetCrtcGammaReq); REQUEST_SIZE_MATCH(xRRGetCrtcGammaReq);
crtc = LookupCrtc (client, stuff->crtc, DixReadAccess); crtc = LookupCrtc (client, stuff->crtc, DixReadAccess);
@ -902,6 +903,12 @@ ProcRRGetCrtcGamma (ClientPtr client)
len = crtc->gammaSize * 3 * 2; len = crtc->gammaSize * 3 * 2;
if (crtc->gammaSize) {
extra = xalloc(len);
if (!extra)
return BadAlloc;
}
reply.type = X_Reply; reply.type = X_Reply;
reply.sequenceNumber = client->sequence; reply.sequenceNumber = client->sequence;
reply.length = (len + 3) >> 2; reply.length = (len + 3) >> 2;
@ -914,8 +921,10 @@ ProcRRGetCrtcGamma (ClientPtr client)
WriteToClient (client, sizeof (xRRGetCrtcGammaReply), (char *) &reply); WriteToClient (client, sizeof (xRRGetCrtcGammaReply), (char *) &reply);
if (crtc->gammaSize) if (crtc->gammaSize)
{ {
memcpy(extra, crtc->gammaRed, len);
client->pSwapReplyFunc = (ReplySwapPtr)CopySwap16Write; client->pSwapReplyFunc = (ReplySwapPtr)CopySwap16Write;
WriteSwappedDataToClient (client, len, (char *) crtc->gammaRed); WriteSwappedDataToClient (client, len, extra);
xfree(extra);
} }
return client->noClientException; return client->noClientException;
} }

View File

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

View File

@ -84,191 +84,284 @@ SProcRRSelectInput (ClientPtr client)
static int static int
SProcRRGetScreenSizeRange (ClientPtr client) SProcRRGetScreenSizeRange (ClientPtr client)
{ {
int n;
REQUEST(xRRGetScreenSizeRangeReq); REQUEST(xRRGetScreenSizeRangeReq);
REQUEST_SIZE_MATCH(xRRGetScreenSizeRangeReq); REQUEST_SIZE_MATCH(xRRGetScreenSizeRangeReq);
(void) stuff; swaps(&stuff->length, n);
return BadImplementation; swapl(&stuff->window, n);
return (*ProcRandrVector[stuff->randrReqType]) (client);
} }
static int static int
SProcRRSetScreenSize (ClientPtr client) SProcRRSetScreenSize (ClientPtr client)
{ {
int n;
REQUEST(xRRSetScreenSizeReq); REQUEST(xRRSetScreenSizeReq);
REQUEST_SIZE_MATCH(xRRSetScreenSizeReq); REQUEST_SIZE_MATCH(xRRSetScreenSizeReq);
(void) stuff; swaps(&stuff->length, n);
return BadImplementation; swapl(&stuff->window, n);
swaps(&stuff->width, n);
swaps(&stuff->height, n);
swapl(&stuff->widthInMillimeters, n);
swapl(&stuff->heightInMillimeters, n);
return (*ProcRandrVector[stuff->randrReqType]) (client);
} }
static int static int
SProcRRGetScreenResources (ClientPtr client) SProcRRGetScreenResources (ClientPtr client)
{ {
int n;
REQUEST(xRRGetScreenResourcesReq); REQUEST(xRRGetScreenResourcesReq);
REQUEST_SIZE_MATCH(xRRGetScreenResourcesReq); REQUEST_SIZE_MATCH(xRRGetScreenResourcesReq);
(void) stuff; swaps(&stuff->length, n);
return BadImplementation; swapl(&stuff->window, n);
return (*ProcRandrVector[stuff->randrReqType]) (client);
} }
static int static int
SProcRRGetOutputInfo (ClientPtr client) SProcRRGetOutputInfo (ClientPtr client)
{ {
int n;
REQUEST(xRRGetOutputInfoReq);; REQUEST(xRRGetOutputInfoReq);;
REQUEST_SIZE_MATCH(xRRGetOutputInfoReq); REQUEST_SIZE_MATCH(xRRGetOutputInfoReq);
(void) stuff; swaps(&stuff->length, n);
return BadImplementation; swapl(&stuff->output, n);
swapl(&stuff->configTimestamp, n);
return (*ProcRandrVector[stuff->randrReqType]) (client);
} }
static int static int
SProcRRListOutputProperties (ClientPtr client) SProcRRListOutputProperties (ClientPtr client)
{ {
int n;
REQUEST(xRRListOutputPropertiesReq); REQUEST(xRRListOutputPropertiesReq);
REQUEST_SIZE_MATCH(xRRListOutputPropertiesReq); REQUEST_SIZE_MATCH(xRRListOutputPropertiesReq);
(void) stuff; swaps(&stuff->length, n);
return BadImplementation; swapl(&stuff->output, n);
return (*ProcRandrVector[stuff->randrReqType]) (client);
} }
static int static int
SProcRRQueryOutputProperty (ClientPtr client) SProcRRQueryOutputProperty (ClientPtr client)
{ {
int n;
REQUEST(xRRQueryOutputPropertyReq); REQUEST(xRRQueryOutputPropertyReq);
REQUEST_SIZE_MATCH(xRRQueryOutputPropertyReq); REQUEST_SIZE_MATCH(xRRQueryOutputPropertyReq);
(void) stuff; swaps(&stuff->length, n);
return BadImplementation; swapl(&stuff->output, n);
swapl(&stuff->property, n);
return (*ProcRandrVector[stuff->randrReqType]) (client);
} }
static int static int
SProcRRConfigureOutputProperty (ClientPtr client) SProcRRConfigureOutputProperty (ClientPtr client)
{ {
int n;
REQUEST(xRRConfigureOutputPropertyReq); REQUEST(xRRConfigureOutputPropertyReq);
REQUEST_SIZE_MATCH(xRRConfigureOutputPropertyReq); swaps(&stuff->length, n);
(void) stuff; swapl(&stuff->output, n);
return BadImplementation; swapl(&stuff->property, n);
SwapRestL(stuff);
return (*ProcRandrVector[stuff->randrReqType]) (client);
} }
static int static int
SProcRRChangeOutputProperty (ClientPtr client) SProcRRChangeOutputProperty (ClientPtr client)
{ {
int n;
REQUEST(xRRChangeOutputPropertyReq); REQUEST(xRRChangeOutputPropertyReq);
REQUEST_SIZE_MATCH(xRRChangeOutputPropertyReq); REQUEST_AT_LEAST_SIZE (xRRChangeOutputPropertyReq);
(void) stuff; swaps(&stuff->length, n);
return BadImplementation; swapl(&stuff->output, n);
swapl(&stuff->property, n);
swapl(&stuff->type, n);
swapl(&stuff->nUnits, n);
switch(stuff->format) {
case 8:
break;
case 16:
SwapRestS(stuff);
break;
case 32:
SwapRestL(stuff);
break;
default:
client->errorValue = stuff->format;
return BadValue;
}
return (*ProcRandrVector[stuff->randrReqType]) (client);
} }
static int static int
SProcRRDeleteOutputProperty (ClientPtr client) SProcRRDeleteOutputProperty (ClientPtr client)
{ {
int n;
REQUEST(xRRDeleteOutputPropertyReq); REQUEST(xRRDeleteOutputPropertyReq);
REQUEST_SIZE_MATCH(xRRDeleteOutputPropertyReq); REQUEST_SIZE_MATCH(xRRDeleteOutputPropertyReq);
(void) stuff; swaps(&stuff->length, n);
return BadImplementation; swapl(&stuff->output, n);
swapl(&stuff->property, n);
return (*ProcRandrVector[stuff->randrReqType]) (client);
} }
static int static int
SProcRRGetOutputProperty (ClientPtr client) SProcRRGetOutputProperty (ClientPtr client)
{ {
int n;
REQUEST(xRRGetOutputPropertyReq); REQUEST(xRRGetOutputPropertyReq);
REQUEST_SIZE_MATCH(xRRGetOutputPropertyReq); REQUEST_SIZE_MATCH(xRRGetOutputPropertyReq);
(void) stuff; swaps(&stuff->length, n);
return BadImplementation; swapl(&stuff->output, n);
swapl(&stuff->property, n);
swapl(&stuff->type, n);
swapl(&stuff->longOffset, n);
swapl(&stuff->longLength, n);
return (*ProcRandrVector[stuff->randrReqType]) (client);
} }
static int static int
SProcRRCreateMode (ClientPtr client) SProcRRCreateMode (ClientPtr client)
{ {
int n;
xRRModeInfo *modeinfo;
REQUEST(xRRCreateModeReq); REQUEST(xRRCreateModeReq);
REQUEST_SIZE_MATCH(xRRCreateModeReq); REQUEST_AT_LEAST_SIZE(xRRCreateModeReq);
(void) stuff; swaps(&stuff->length, n);
return BadImplementation; swapl(&stuff->window, n);
modeinfo = &stuff->modeInfo;
swapl(&modeinfo->id, n);
swaps(&modeinfo->width, n);
swaps(&modeinfo->height, n);
swapl(&modeinfo->dotClock, n);
swaps(&modeinfo->hSyncStart, n);
swaps(&modeinfo->hSyncEnd, n);
swaps(&modeinfo->hTotal, n);
swaps(&modeinfo->vSyncStart, n);
swaps(&modeinfo->vSyncEnd, n);
swaps(&modeinfo->vTotal, n);
swaps(&modeinfo->nameLength, n);
swapl(&modeinfo->modeFlags, n);
return (*ProcRandrVector[stuff->randrReqType]) (client);
} }
static int static int
SProcRRDestroyMode (ClientPtr client) SProcRRDestroyMode (ClientPtr client)
{ {
int n;
REQUEST(xRRDestroyModeReq); REQUEST(xRRDestroyModeReq);
REQUEST_SIZE_MATCH(xRRDestroyModeReq); REQUEST_SIZE_MATCH(xRRDestroyModeReq);
(void) stuff; swaps(&stuff->length, n);
return BadImplementation; swapl(&stuff->mode, n);
return (*ProcRandrVector[stuff->randrReqType]) (client);
} }
static int static int
SProcRRAddOutputMode (ClientPtr client) SProcRRAddOutputMode (ClientPtr client)
{ {
int n;
REQUEST(xRRAddOutputModeReq); REQUEST(xRRAddOutputModeReq);
REQUEST_SIZE_MATCH(xRRAddOutputModeReq); REQUEST_SIZE_MATCH(xRRAddOutputModeReq);
(void) stuff; swaps(&stuff->length, n);
return BadImplementation; swapl(&stuff->output, n);
swapl(&stuff->mode, n);
return (*ProcRandrVector[stuff->randrReqType]) (client);
} }
static int static int
SProcRRDeleteOutputMode (ClientPtr client) SProcRRDeleteOutputMode (ClientPtr client)
{ {
int n;
REQUEST(xRRDeleteOutputModeReq); REQUEST(xRRDeleteOutputModeReq);
REQUEST_SIZE_MATCH(xRRDeleteOutputModeReq); REQUEST_SIZE_MATCH(xRRDeleteOutputModeReq);
(void) stuff; swaps(&stuff->length, n);
return BadImplementation; swapl(&stuff->output, n);
swapl(&stuff->mode, n);
return (*ProcRandrVector[stuff->randrReqType]) (client);
} }
static int static int
SProcRRGetCrtcInfo (ClientPtr client) SProcRRGetCrtcInfo (ClientPtr client)
{ {
int n;
REQUEST(xRRGetCrtcInfoReq); REQUEST(xRRGetCrtcInfoReq);
REQUEST_SIZE_MATCH(xRRGetCrtcInfoReq); REQUEST_SIZE_MATCH(xRRGetCrtcInfoReq);
(void) stuff; swaps(&stuff->length, n);
return BadImplementation; swapl(&stuff->crtc, n);
swapl(&stuff->configTimestamp, n);
return (*ProcRandrVector[stuff->randrReqType]) (client);
} }
static int static int
SProcRRSetCrtcConfig (ClientPtr client) SProcRRSetCrtcConfig (ClientPtr client)
{ {
int n;
REQUEST(xRRSetCrtcConfigReq); REQUEST(xRRSetCrtcConfigReq);
REQUEST_SIZE_MATCH(xRRSetCrtcConfigReq); REQUEST_AT_LEAST_SIZE(xRRSetCrtcConfigReq);
(void) stuff; swaps(&stuff->length, n);
return BadImplementation; swapl(&stuff->crtc, n);
swapl(&stuff->timestamp, n);
swapl(&stuff->configTimestamp, n);
swaps(&stuff->x, n);
swaps(&stuff->y, n);
swapl(&stuff->mode, n);
swaps(&stuff->rotation, n);
SwapRestL(stuff);
return (*ProcRandrVector[stuff->randrReqType]) (client);
} }
static int static int
SProcRRGetCrtcGammaSize (ClientPtr client) SProcRRGetCrtcGammaSize (ClientPtr client)
{ {
int n;
REQUEST(xRRGetCrtcGammaSizeReq); REQUEST(xRRGetCrtcGammaSizeReq);
REQUEST_SIZE_MATCH(xRRGetCrtcGammaSizeReq); REQUEST_SIZE_MATCH(xRRGetCrtcGammaSizeReq);
(void) stuff; swaps(&stuff->length, n);
return BadImplementation; swapl(&stuff->crtc, n);
return (*ProcRandrVector[stuff->randrReqType]) (client);
} }
static int static int
SProcRRGetCrtcGamma (ClientPtr client) SProcRRGetCrtcGamma (ClientPtr client)
{ {
int n;
REQUEST(xRRGetCrtcGammaReq); REQUEST(xRRGetCrtcGammaReq);
REQUEST_SIZE_MATCH(xRRGetCrtcGammaReq); REQUEST_SIZE_MATCH(xRRGetCrtcGammaReq);
(void) stuff; swaps(&stuff->length, n);
return BadImplementation; swapl(&stuff->crtc, n);
return (*ProcRandrVector[stuff->randrReqType]) (client);
} }
static int static int
SProcRRSetCrtcGamma (ClientPtr client) SProcRRSetCrtcGamma (ClientPtr client)
{ {
int n;
REQUEST(xRRSetCrtcGammaReq); REQUEST(xRRSetCrtcGammaReq);
REQUEST_SIZE_MATCH(xRRSetCrtcGammaReq); REQUEST_AT_LEAST_SIZE(xRRSetCrtcGammaReq);
(void) stuff; swaps(&stuff->length, n);
return BadImplementation; swapl(&stuff->crtc, n);
swaps(&stuff->size, n);
SwapRestS(stuff);
return (*ProcRandrVector[stuff->randrReqType]) (client);
} }
int (*SProcRandrVector[RRNumberRequests])(ClientPtr) = { int (*SProcRandrVector[RRNumberRequests])(ClientPtr) = {