diff options
author | marha <marha@users.sourceforge.net> | 2012-03-23 10:05:55 +0100 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2012-03-23 10:05:55 +0100 |
commit | 0f834b91a4768673833ab4917e87d86c237bb1a6 (patch) | |
tree | 363489504ed4b2d360259b8de4c9e392918e5d02 /xorg-server/randr/rroutput.c | |
parent | fc72edebf875378459368c5383d9023730cbca54 (diff) | |
download | vcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.tar.gz vcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.tar.bz2 vcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.zip |
libX11 xserver fontconfig mesa pixman xkbcomp xkeyboard-config git update
23 Mar 2012
Diffstat (limited to 'xorg-server/randr/rroutput.c')
-rw-r--r-- | xorg-server/randr/rroutput.c | 527 |
1 files changed, 245 insertions, 282 deletions
diff --git a/xorg-server/randr/rroutput.c b/xorg-server/randr/rroutput.c index b57be198f..0890c55b5 100644 --- a/xorg-server/randr/rroutput.c +++ b/xorg-server/randr/rroutput.c @@ -23,23 +23,22 @@ #include "randrstr.h" -RESTYPE RROutputType; +RESTYPE RROutputType; /* * Notify the output of some change */ void -RROutputChanged (RROutputPtr output, Bool configChanged) +RROutputChanged(RROutputPtr output, Bool configChanged) { - ScreenPtr pScreen = output->pScreen; - + ScreenPtr pScreen = output->pScreen; + output->changed = TRUE; - if (pScreen) - { - rrScrPriv (pScreen); - pScrPriv->changed = TRUE; - if (configChanged) - pScrPriv->configChanged = TRUE; + if (pScreen) { + rrScrPriv(pScreen); + pScrPriv->changed = TRUE; + if (configChanged) + pScrPriv->configChanged = TRUE; } } @@ -48,38 +47,36 @@ RROutputChanged (RROutputPtr output, Bool configChanged) */ RROutputPtr -RROutputCreate (ScreenPtr pScreen, - const char *name, - int nameLength, - void *devPrivate) +RROutputCreate(ScreenPtr pScreen, + const char *name, int nameLength, void *devPrivate) { - RROutputPtr output; - RROutputPtr *outputs; - rrScrPrivPtr pScrPriv; + RROutputPtr output; + RROutputPtr *outputs; + rrScrPrivPtr pScrPriv; if (!RRInit()) - return NULL; - + return NULL; + pScrPriv = rrGetScrPriv(pScreen); if (pScrPriv->numOutputs) - outputs = realloc(pScrPriv->outputs, - (pScrPriv->numOutputs + 1) * sizeof (RROutputPtr)); + outputs = realloc(pScrPriv->outputs, + (pScrPriv->numOutputs + 1) * sizeof(RROutputPtr)); else - outputs = malloc(sizeof (RROutputPtr)); + outputs = malloc(sizeof(RROutputPtr)); if (!outputs) - return FALSE; + return FALSE; pScrPriv->outputs = outputs; - - output = malloc(sizeof (RROutputRec) + nameLength + 1); + + output = malloc(sizeof(RROutputRec) + nameLength + 1); if (!output) - return NULL; - output->id = FakeClientID (0); + return NULL; + output->id = FakeClientID(0); output->pScreen = pScreen; output->name = (char *) (output + 1); output->nameLength = nameLength; - memcpy (output->name, name, nameLength); + memcpy(output->name, name, nameLength); output->name[nameLength] = '\0'; output->connection = RR_UnknownConnection; output->subpixelOrder = SubPixelUnknown; @@ -99,9 +96,9 @@ RROutputCreate (ScreenPtr pScreen, output->pendingProperties = FALSE; output->changed = FALSE; output->devPrivate = devPrivate; - - if (!AddResource (output->id, RROutputType, (pointer) output)) - return NULL; + + if (!AddResource(output->id, RROutputType, (pointer) output)) + return NULL; pScrPriv->outputs[pScrPriv->numOutputs++] = output; return output; @@ -111,300 +108,273 @@ RROutputCreate (ScreenPtr pScreen, * Notify extension that output parameters have been changed */ Bool -RROutputSetClones (RROutputPtr output, - RROutputPtr *clones, - int numClones) +RROutputSetClones(RROutputPtr output, RROutputPtr * clones, int numClones) { - RROutputPtr *newClones; - int i; - - if (numClones == output->numClones) - { - for (i = 0; i < numClones; i++) - if (output->clones[i] != clones[i]) - break; - if (i == numClones) - return TRUE; + RROutputPtr *newClones; + int i; + + if (numClones == output->numClones) { + for (i = 0; i < numClones; i++) + if (output->clones[i] != clones[i]) + break; + if (i == numClones) + return TRUE; } - if (numClones) - { - newClones = malloc(numClones * sizeof (RROutputPtr)); - if (!newClones) - return FALSE; + if (numClones) { + newClones = malloc(numClones * sizeof(RROutputPtr)); + if (!newClones) + return FALSE; } else - newClones = NULL; + newClones = NULL; free(output->clones); - memcpy (newClones, clones, numClones * sizeof (RROutputPtr)); + memcpy(newClones, clones, numClones * sizeof(RROutputPtr)); output->clones = newClones; output->numClones = numClones; - RROutputChanged (output, TRUE); + RROutputChanged(output, TRUE); return TRUE; } Bool -RROutputSetModes (RROutputPtr output, - RRModePtr *modes, - int numModes, - int numPreferred) +RROutputSetModes(RROutputPtr output, + RRModePtr * modes, int numModes, int numPreferred) { - RRModePtr *newModes; - int i; - - if (numModes == output->numModes && numPreferred == output->numPreferred) - { - for (i = 0; i < numModes; i++) - if (output->modes[i] != modes[i]) - break; - if (i == numModes) - { - for (i = 0; i < numModes; i++) - RRModeDestroy (modes[i]); - return TRUE; - } + RRModePtr *newModes; + int i; + + if (numModes == output->numModes && numPreferred == output->numPreferred) { + for (i = 0; i < numModes; i++) + if (output->modes[i] != modes[i]) + break; + if (i == numModes) { + for (i = 0; i < numModes; i++) + RRModeDestroy(modes[i]); + return TRUE; + } } - if (numModes) - { - newModes = malloc(numModes * sizeof (RRModePtr)); - if (!newModes) - return FALSE; + if (numModes) { + newModes = malloc(numModes * sizeof(RRModePtr)); + if (!newModes) + return FALSE; } else - newModes = NULL; - if (output->modes) - { - for (i = 0; i < output->numModes; i++) - RRModeDestroy (output->modes[i]); - free(output->modes); + newModes = NULL; + if (output->modes) { + for (i = 0; i < output->numModes; i++) + RRModeDestroy(output->modes[i]); + free(output->modes); } - memcpy (newModes, modes, numModes * sizeof (RRModePtr)); + memcpy(newModes, modes, numModes * sizeof(RRModePtr)); output->modes = newModes; output->numModes = numModes; output->numPreferred = numPreferred; - RROutputChanged (output, TRUE); + RROutputChanged(output, TRUE); return TRUE; } int -RROutputAddUserMode (RROutputPtr output, - RRModePtr mode) +RROutputAddUserMode(RROutputPtr output, RRModePtr mode) { - int m; - ScreenPtr pScreen = output->pScreen; + int m; + ScreenPtr pScreen = output->pScreen; + rrScrPriv(pScreen); - RRModePtr *newModes; + RRModePtr *newModes; /* Check to see if this mode is already listed for this output */ - for (m = 0; m < output->numModes + output->numUserModes; m++) - { - RRModePtr e = (m < output->numModes ? - output->modes[m] : - output->userModes[m - output->numModes]); - if (mode == e) - return Success; + for (m = 0; m < output->numModes + output->numUserModes; m++) { + RRModePtr e = (m < output->numModes ? + output->modes[m] : + output->userModes[m - output->numModes]); + if (mode == e) + return Success; } /* Check with the DDX to see if this mode is OK */ if (pScrPriv->rrOutputValidateMode) - if (!pScrPriv->rrOutputValidateMode (pScreen, output, mode)) - return BadMatch; + if (!pScrPriv->rrOutputValidateMode(pScreen, output, mode)) + return BadMatch; if (output->userModes) - newModes = realloc(output->userModes, - (output->numUserModes + 1) * sizeof (RRModePtr)); + newModes = realloc(output->userModes, + (output->numUserModes + 1) * sizeof(RRModePtr)); else - newModes = malloc(sizeof (RRModePtr)); + newModes = malloc(sizeof(RRModePtr)); if (!newModes) - return BadAlloc; + return BadAlloc; output->userModes = newModes; output->userModes[output->numUserModes++] = mode; ++mode->refcnt; - RROutputChanged (output, TRUE); - RRTellChanged (pScreen); + RROutputChanged(output, TRUE); + RRTellChanged(pScreen); return Success; } int -RROutputDeleteUserMode (RROutputPtr output, - RRModePtr mode) +RROutputDeleteUserMode(RROutputPtr output, RRModePtr mode) { - int m; - + int m; + /* Find this mode in the user mode list */ - for (m = 0; m < output->numUserModes; m++) - { - RRModePtr e = output->userModes[m]; + for (m = 0; m < output->numUserModes; m++) { + RRModePtr e = output->userModes[m]; - if (mode == e) - break; + if (mode == e) + break; } /* Not there, access error */ if (m == output->numUserModes) - return BadAccess; + return BadAccess; /* make sure the mode isn't active for this output */ if (output->crtc && output->crtc->mode == mode) - return BadMatch; + return BadMatch; - memmove (output->userModes + m, output->userModes + m + 1, - (output->numUserModes - m - 1) * sizeof (RRModePtr)); + memmove(output->userModes + m, output->userModes + m + 1, + (output->numUserModes - m - 1) * sizeof(RRModePtr)); output->numUserModes--; - RRModeDestroy (mode); + RRModeDestroy(mode); return Success; } Bool -RROutputSetCrtcs (RROutputPtr output, - RRCrtcPtr *crtcs, - int numCrtcs) +RROutputSetCrtcs(RROutputPtr output, RRCrtcPtr * crtcs, int numCrtcs) { - RRCrtcPtr *newCrtcs; - int i; - - if (numCrtcs == output->numCrtcs) - { - for (i = 0; i < numCrtcs; i++) - if (output->crtcs[i] != crtcs[i]) - break; - if (i == numCrtcs) - return TRUE; + RRCrtcPtr *newCrtcs; + int i; + + if (numCrtcs == output->numCrtcs) { + for (i = 0; i < numCrtcs; i++) + if (output->crtcs[i] != crtcs[i]) + break; + if (i == numCrtcs) + return TRUE; } - if (numCrtcs) - { - newCrtcs = malloc(numCrtcs * sizeof (RRCrtcPtr)); - if (!newCrtcs) - return FALSE; + if (numCrtcs) { + newCrtcs = malloc(numCrtcs * sizeof(RRCrtcPtr)); + if (!newCrtcs) + return FALSE; } else - newCrtcs = NULL; + newCrtcs = NULL; free(output->crtcs); - memcpy (newCrtcs, crtcs, numCrtcs * sizeof (RRCrtcPtr)); + memcpy(newCrtcs, crtcs, numCrtcs * sizeof(RRCrtcPtr)); output->crtcs = newCrtcs; output->numCrtcs = numCrtcs; - RROutputChanged (output, TRUE); + RROutputChanged(output, TRUE); return TRUE; } Bool -RROutputSetConnection (RROutputPtr output, - CARD8 connection) +RROutputSetConnection(RROutputPtr output, CARD8 connection) { if (output->connection == connection) - return TRUE; + return TRUE; output->connection = connection; - RROutputChanged (output, TRUE); + RROutputChanged(output, TRUE); return TRUE; } Bool -RROutputSetSubpixelOrder (RROutputPtr output, - int subpixelOrder) +RROutputSetSubpixelOrder(RROutputPtr output, int subpixelOrder) { if (output->subpixelOrder == subpixelOrder) - return TRUE; + return TRUE; output->subpixelOrder = subpixelOrder; - RROutputChanged (output, FALSE); + RROutputChanged(output, FALSE); return TRUE; } Bool -RROutputSetPhysicalSize (RROutputPtr output, - int mmWidth, - int mmHeight) +RROutputSetPhysicalSize(RROutputPtr output, int mmWidth, int mmHeight) { if (output->mmWidth == mmWidth && output->mmHeight == mmHeight) - return TRUE; + return TRUE; output->mmWidth = mmWidth; output->mmHeight = mmHeight; - RROutputChanged (output, FALSE); + RROutputChanged(output, FALSE); return TRUE; } - void RRDeliverOutputEvent(ClientPtr client, WindowPtr pWin, RROutputPtr output) { ScreenPtr pScreen = pWin->drawable.pScreen; - rrScrPriv (pScreen); - xRROutputChangeNotifyEvent oe; - RRCrtcPtr crtc = output->crtc; - RRModePtr mode = crtc ? crtc->mode : 0; - + + rrScrPriv(pScreen); + xRROutputChangeNotifyEvent oe; + RRCrtcPtr crtc = output->crtc; + RRModePtr mode = crtc ? crtc->mode : 0; + oe.type = RRNotify + RREventBase; oe.subCode = RRNotify_OutputChange; oe.timestamp = pScrPriv->lastSetTime.milliseconds; oe.configTimestamp = pScrPriv->lastConfigTime.milliseconds; oe.window = pWin->drawable.id; oe.output = output->id; - if (crtc) - { - oe.crtc = crtc->id; - oe.mode = mode ? mode->mode.id : None; - oe.rotation = crtc->rotation; + if (crtc) { + oe.crtc = crtc->id; + oe.mode = mode ? mode->mode.id : None; + oe.rotation = crtc->rotation; } - else - { - oe.crtc = None; - oe.mode = None; - oe.rotation = RR_Rotate_0; + else { + oe.crtc = None; + oe.mode = None; + oe.rotation = RR_Rotate_0; } oe.connection = output->connection; oe.subpixelOrder = output->subpixelOrder; - WriteEventsToClient (client, 1, (xEvent *) &oe); + WriteEventsToClient(client, 1, (xEvent *) &oe); } /* * Destroy a Output at shutdown */ void -RROutputDestroy (RROutputPtr output) +RROutputDestroy(RROutputPtr output) { - FreeResource (output->id, 0); + FreeResource(output->id, 0); } static int -RROutputDestroyResource (pointer value, XID pid) +RROutputDestroyResource(pointer value, XID pid) { - RROutputPtr output = (RROutputPtr) value; - ScreenPtr pScreen = output->pScreen; - int m; - - if (pScreen) - { - rrScrPriv(pScreen); - int i; - - if (pScrPriv->primaryOutput == output) - pScrPriv->primaryOutput = NULL; - - for (i = 0; i < pScrPriv->numOutputs; i++) - { - if (pScrPriv->outputs[i] == output) - { - memmove (pScrPriv->outputs + i, pScrPriv->outputs + i + 1, - (pScrPriv->numOutputs - (i + 1)) * sizeof (RROutputPtr)); - --pScrPriv->numOutputs; - break; - } - } + RROutputPtr output = (RROutputPtr) value; + ScreenPtr pScreen = output->pScreen; + int m; + + if (pScreen) { + rrScrPriv(pScreen); + int i; + + if (pScrPriv->primaryOutput == output) + pScrPriv->primaryOutput = NULL; + + for (i = 0; i < pScrPriv->numOutputs; i++) { + if (pScrPriv->outputs[i] == output) { + memmove(pScrPriv->outputs + i, pScrPriv->outputs + i + 1, + (pScrPriv->numOutputs - (i + 1)) * sizeof(RROutputPtr)); + --pScrPriv->numOutputs; + break; + } + } } - if (output->modes) - { - for (m = 0; m < output->numModes; m++) - RRModeDestroy (output->modes[m]); - free(output->modes); + if (output->modes) { + for (m = 0; m < output->numModes; m++) + RRModeDestroy(output->modes[m]); + free(output->modes); } - + for (m = 0; m < output->numUserModes; m++) - RRModeDestroy (output->userModes[m]); + RRModeDestroy(output->userModes[m]); free(output->userModes); free(output->crtcs); free(output->clones); - RRDeleteAllOutputProperties (output); + RRDeleteAllOutputProperties(output); free(output); return 1; } @@ -413,11 +383,11 @@ RROutputDestroyResource (pointer value, XID pid) * Initialize output type */ Bool -RROutputInit (void) +RROutputInit(void) { - RROutputType = CreateNewResourceType (RROutputDestroyResource, "OUTPUT"); + RROutputType = CreateNewResourceType(RROutputDestroyResource, "OUTPUT"); if (!RROutputType) - return FALSE; + return FALSE; return TRUE; } @@ -434,21 +404,21 @@ RROutputInitErrorValue(void) #define OutputInfoExtra (SIZEOF(xRRGetOutputInfoReply) - 32) int -ProcRRGetOutputInfo (ClientPtr client) +ProcRRGetOutputInfo(ClientPtr client) { REQUEST(xRRGetOutputInfoReq); - xRRGetOutputInfoReply rep; - RROutputPtr output; - CARD8 *extra; - unsigned long extraLen; - ScreenPtr pScreen; - rrScrPrivPtr pScrPriv; - RRCrtc *crtcs; - RRMode *modes; - RROutput *clones; - char *name; - int i; - + xRRGetOutputInfoReply rep; + RROutputPtr output; + CARD8 *extra; + unsigned long extraLen; + ScreenPtr pScreen; + rrScrPrivPtr pScrPriv; + RRCrtc *crtcs; + RRMode *modes; + RROutput *clones; + char *name; + int i; + REQUEST_SIZE_MATCH(xRRGetOutputInfoReq); VERIFY_RR_OUTPUT(stuff->output, output, DixReadAccess); @@ -469,88 +439,81 @@ ProcRRGetOutputInfo (ClientPtr client) rep.nPreferred = output->numPreferred; rep.nClones = output->numClones; rep.nameLength = output->nameLength; - + extraLen = ((output->numCrtcs + - output->numModes + output->numUserModes + - output->numClones + - bytes_to_int32(rep.nameLength)) << 2); - - if (extraLen) - { - rep.length += bytes_to_int32(extraLen); - extra = malloc(extraLen); - if (!extra) - return BadAlloc; + output->numModes + output->numUserModes + + output->numClones + bytes_to_int32(rep.nameLength)) << 2); + + if (extraLen) { + rep.length += bytes_to_int32(extraLen); + extra = malloc(extraLen); + if (!extra) + return BadAlloc; } else - extra = NULL; + extra = NULL; crtcs = (RRCrtc *) extra; modes = (RRMode *) (crtcs + output->numCrtcs); clones = (RROutput *) (modes + output->numModes + output->numUserModes); name = (char *) (clones + output->numClones); - - for (i = 0; i < output->numCrtcs; i++) - { - crtcs[i] = output->crtcs[i]->id; - if (client->swapped) - swapl(&crtcs[i]); + + for (i = 0; i < output->numCrtcs; i++) { + crtcs[i] = output->crtcs[i]->id; + if (client->swapped) + swapl(&crtcs[i]); } - for (i = 0; i < output->numModes + output->numUserModes; i++) - { - if (i < output->numModes) - modes[i] = output->modes[i]->mode.id; - else - modes[i] = output->userModes[i - output->numModes]->mode.id; - if (client->swapped) - swapl(&modes[i]); + for (i = 0; i < output->numModes + output->numUserModes; i++) { + if (i < output->numModes) + modes[i] = output->modes[i]->mode.id; + else + modes[i] = output->userModes[i - output->numModes]->mode.id; + if (client->swapped) + swapl(&modes[i]); } - for (i = 0; i < output->numClones; i++) - { - clones[i] = output->clones[i]->id; - if (client->swapped) - swapl(&clones[i]); + for (i = 0; i < output->numClones; i++) { + clones[i] = output->clones[i]->id; + if (client->swapped) + swapl(&clones[i]); } - memcpy (name, output->name, output->nameLength); + memcpy(name, output->name, output->nameLength); if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - swapl(&rep.timestamp); - swapl(&rep.crtc); - swapl(&rep.mmWidth); - swapl(&rep.mmHeight); - swaps(&rep.nCrtcs); - swaps(&rep.nModes); - swaps(&rep.nClones); - swaps(&rep.nameLength); + swaps(&rep.sequenceNumber); + swapl(&rep.length); + swapl(&rep.timestamp); + swapl(&rep.crtc); + swapl(&rep.mmWidth); + swapl(&rep.mmHeight); + swaps(&rep.nCrtcs); + swaps(&rep.nModes); + swaps(&rep.nClones); + swaps(&rep.nameLength); } - WriteToClient(client, sizeof(xRRGetOutputInfoReply), (char *)&rep); - if (extraLen) - { - WriteToClient (client, extraLen, (char *) extra); - free(extra); + WriteToClient(client, sizeof(xRRGetOutputInfoReply), (char *) &rep); + if (extraLen) { + WriteToClient(client, extraLen, (char *) extra); + free(extra); } - + return Success; } static void -RRSetPrimaryOutput(ScreenPtr pScreen, rrScrPrivPtr pScrPriv, - RROutputPtr output) +RRSetPrimaryOutput(ScreenPtr pScreen, rrScrPrivPtr pScrPriv, RROutputPtr output) { if (pScrPriv->primaryOutput == output) - return; + return; /* clear the old primary */ if (pScrPriv->primaryOutput) { - RROutputChanged(pScrPriv->primaryOutput, 0); - pScrPriv->primaryOutput = NULL; + RROutputChanged(pScrPriv->primaryOutput, 0); + pScrPriv->primaryOutput = NULL; } /* set the new primary */ if (output) { - pScrPriv->primaryOutput = output; - RROutputChanged(output, 0); + pScrPriv->primaryOutput = output; + RROutputChanged(output, 0); } pScrPriv->layoutChanged = TRUE; @@ -571,15 +534,15 @@ ProcRRSetOutputPrimary(ClientPtr client) rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); if (rc != Success) - return rc; + return rc; if (stuff->output) { - VERIFY_RR_OUTPUT(stuff->output, output, DixReadAccess); + VERIFY_RR_OUTPUT(stuff->output, output, DixReadAccess); - if (output->pScreen != pWin->drawable.pScreen) { - client->errorValue = stuff->window; - return BadMatch; - } + if (output->pScreen != pWin->drawable.pScreen) { + client->errorValue = stuff->window; + return BadMatch; + } } pScrPriv = rrGetScrPriv(pWin->drawable.pScreen); @@ -602,11 +565,11 @@ ProcRRGetOutputPrimary(ClientPtr client) rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); if (rc != Success) - return rc; + return rc; pScrPriv = rrGetScrPriv(pWin->drawable.pScreen); if (pScrPriv) - primary = pScrPriv->primaryOutput; + primary = pScrPriv->primaryOutput; memset(&rep, 0, sizeof(rep)); rep.type = X_Reply; @@ -614,8 +577,8 @@ ProcRRGetOutputPrimary(ClientPtr client) rep.output = primary ? primary->id : None; if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.output); + swaps(&rep.sequenceNumber); + swapl(&rep.output); } WriteToClient(client, sizeof(xRRGetOutputPrimaryReply), &rep); |