From b943cfe2afbd593e814de47b2f13f8b3b1af78da Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Tue, 7 Jun 2016 10:14:50 +0200 Subject: Drop trailing whitespaces (randr extension) sed -i "s/[ ]\+$//g" randr/*.{c,h} happy reviewing... git diff -w is an empty diff. --- nx-X11/programs/Xserver/randr/rroutput.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'nx-X11/programs/Xserver/randr/rroutput.c') diff --git a/nx-X11/programs/Xserver/randr/rroutput.c b/nx-X11/programs/Xserver/randr/rroutput.c index 06f8024e4..68c3ce242 100644 --- a/nx-X11/programs/Xserver/randr/rroutput.c +++ b/nx-X11/programs/Xserver/randr/rroutput.c @@ -32,7 +32,7 @@ void RROutputChanged (RROutputPtr output, Bool configChanged) { ScreenPtr pScreen = output->pScreen; - + output->changed = TRUE; if (pScreen) { @@ -59,11 +59,11 @@ RROutputCreate (ScreenPtr pScreen, if (!RRInit()) return NULL; - + pScrPriv = rrGetScrPriv(pScreen); if (pScrPriv->numOutputs) - outputs = xrealloc (pScrPriv->outputs, + outputs = xrealloc (pScrPriv->outputs, (pScrPriv->numOutputs + 1) * sizeof (RROutputPtr)); else outputs = xalloc (sizeof (RROutputPtr)); @@ -71,7 +71,7 @@ RROutputCreate (ScreenPtr pScreen, return FALSE; pScrPriv->outputs = outputs; - + output = xalloc (sizeof (RROutputRec) + nameLength + 1); if (!output) return NULL; @@ -99,7 +99,7 @@ RROutputCreate (ScreenPtr pScreen, output->pendingProperties = FALSE; output->changed = FALSE; output->devPrivate = devPrivate; - + if (!AddResource (output->id, RROutputType, (void *) output)) return NULL; @@ -232,7 +232,7 @@ RROutputDeleteUserMode (RROutputPtr output, RRModePtr mode) { int m; - + /* Find this mode in the user mode list */ for (m = 0; m < output->numUserModes; m++) { @@ -334,7 +334,7 @@ RRDeliverOutputEvent(ClientPtr client, WindowPtr pWin, RROutputPtr output) xRROutputChangeNotifyEvent oe; RRCrtcPtr crtc = output->crtc; RRModePtr mode = crtc ? crtc->mode : 0; - + oe.type = RRNotify + RREventBase; oe.subCode = RRNotify_OutputChange; oe.sequenceNumber = client->sequence; @@ -379,7 +379,7 @@ RROutputDestroyResource (void * value, XID pid) { rrScrPriv(pScreen); int i; - + for (i = 0; i < pScrPriv->numOutputs; i++) { if (pScrPriv->outputs[i] == output) @@ -397,7 +397,7 @@ RROutputDestroyResource (void * value, XID pid) RRModeDestroy (output->modes[m]); xfree (output->modes); } - + for (m = 0; m < output->numUserModes; m++) RRModeDestroy (output->userModes[m]); if (output->userModes) @@ -442,7 +442,7 @@ ProcRRGetOutputInfo (ClientPtr client) RROutput *clones; char *name; int i, n; - + REQUEST_SIZE_MATCH(xRRGetOutputInfoReq); output = LookupOutput(client, stuff->output, DixReadAccess); @@ -470,8 +470,8 @@ ProcRRGetOutputInfo (ClientPtr client) rep.nPreferred = output->numPreferred; rep.nClones = output->numClones; rep.nameLength = output->nameLength; - - extraLen = ((output->numCrtcs + + + extraLen = ((output->numCrtcs + output->numModes + output->numUserModes + output->numClones + ((rep.nameLength + 3) >> 2)) << 2); @@ -490,7 +490,7 @@ ProcRRGetOutputInfo (ClientPtr client) 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; @@ -531,6 +531,6 @@ ProcRRGetOutputInfo (ClientPtr client) WriteToClient (client, extraLen, (char *) extra); xfree (extra); } - + return client->noClientException; } -- cgit v1.2.3 From e440ea768d004ca83993dfb5774daa7971d90c10 Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Tue, 7 Jun 2016 10:26:58 +0200 Subject: randr extension: Convert to Xorg coding style. The reformatting has been achieved by applying x-indent.sh to all .c and .h files in Xserver/randr/. --- nx-X11/programs/Xserver/randr/rroutput.c | 489 ++++++++++++++----------------- 1 file changed, 226 insertions(+), 263 deletions(-) (limited to 'nx-X11/programs/Xserver/randr/rroutput.c') diff --git a/nx-X11/programs/Xserver/randr/rroutput.c b/nx-X11/programs/Xserver/randr/rroutput.c index 68c3ce242..523ee55d8 100644 --- a/nx-X11/programs/Xserver/randr/rroutput.c +++ b/nx-X11/programs/Xserver/randr/rroutput.c @@ -23,23 +23,22 @@ #include "randrstr.h" #include "registry.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 = xrealloc (pScrPriv->outputs, - (pScrPriv->numOutputs + 1) * sizeof (RROutputPtr)); + outputs = xrealloc(pScrPriv->outputs, + (pScrPriv->numOutputs + 1) * sizeof(RROutputPtr)); else - outputs = xalloc (sizeof (RROutputPtr)); + outputs = xalloc(sizeof(RROutputPtr)); if (!outputs) - return FALSE; + return FALSE; pScrPriv->outputs = outputs; - output = xalloc (sizeof (RROutputRec) + nameLength + 1); + output = xalloc(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; @@ -100,8 +97,8 @@ RROutputCreate (ScreenPtr pScreen, output->changed = FALSE; output->devPrivate = devPrivate; - if (!AddResource (output->id, RROutputType, (void *) output)) - return NULL; + if (!AddResource(output->id, RROutputType, (void *) output)) + return NULL; pScrPriv->outputs[pScrPriv->numOutputs++] = output; return output; @@ -111,229 +108,208 @@ 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 = xalloc (numClones * sizeof (RROutputPtr)); - if (!newClones) - return FALSE; + if (numClones) { + newClones = xalloc(numClones * sizeof(RROutputPtr)); + if (!newClones) + return FALSE; } else - newClones = NULL; + newClones = NULL; if (output->clones) - xfree (output->clones); - memcpy (newClones, clones, numClones * sizeof (RROutputPtr)); + xfree(output->clones); + 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 = xalloc (numModes * sizeof (RRModePtr)); - if (!newModes) - return FALSE; + if (numModes) { + newModes = xalloc(numModes * sizeof(RRModePtr)); + if (!newModes) + return FALSE; } else - newModes = NULL; - if (output->modes) - { - for (i = 0; i < output->numModes; i++) - RRModeDestroy (output->modes[i]); - xfree (output->modes); + newModes = NULL; + if (output->modes) { + for (i = 0; i < output->numModes; i++) + RRModeDestroy(output->modes[i]); + xfree(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 = xrealloc (output->userModes, - (output->numUserModes + 1) * sizeof (RRModePtr)); + newModes = xrealloc(output->userModes, + (output->numUserModes + 1) * sizeof(RRModePtr)); else - newModes = xalloc (sizeof (RRModePtr)); + newModes = xalloc(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 = xalloc (numCrtcs * sizeof (RRCrtcPtr)); - if (!newCrtcs) - return FALSE; + if (numCrtcs) { + newCrtcs = xalloc(numCrtcs * sizeof(RRCrtcPtr)); + if (!newCrtcs) + return FALSE; } else - newCrtcs = NULL; + newCrtcs = NULL; if (output->crtcs) - xfree (output->crtcs); - memcpy (newCrtcs, crtcs, numCrtcs * sizeof (RRCrtcPtr)); + xfree(output->crtcs); + 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; @@ -342,73 +318,67 @@ RRDeliverOutputEvent(ClientPtr client, WindowPtr pWin, RROutputPtr output) 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 (void * value, XID pid) +RROutputDestroyResource(void *value, XID pid) { - RROutputPtr output = (RROutputPtr) value; - ScreenPtr pScreen = output->pScreen; - int m; - - if (pScreen) - { - rrScrPriv(pScreen); - int i; - - 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; + + 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]); - xfree (output->modes); + if (output->modes) { + for (m = 0; m < output->numModes; m++) + RRModeDestroy(output->modes[m]); + xfree(output->modes); } for (m = 0; m < output->numUserModes; m++) - RRModeDestroy (output->userModes[m]); + RRModeDestroy(output->userModes[m]); if (output->userModes) - xfree (output->userModes); + xfree(output->userModes); if (output->crtcs) - xfree (output->crtcs); + xfree(output->crtcs); if (output->clones) - xfree (output->clones); - RRDeleteAllOutputProperties (output); - xfree (output); + xfree(output->clones); + RRDeleteAllOutputProperties(output); + xfree(output); return 1; } @@ -416,40 +386,39 @@ RROutputDestroyResource (void * value, XID pid) * Initialize output type */ Bool -RROutputInit (void) +RROutputInit(void) { - RROutputType = CreateNewResourceType (RROutputDestroyResource); + RROutputType = CreateNewResourceType(RROutputDestroyResource); if (!RROutputType) - return FALSE; - RegisterResourceName (RROutputType, "OUTPUT"); + return FALSE; + RegisterResourceName(RROutputType, "OUTPUT"); return TRUE; } #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, n; + xRRGetOutputInfoReply rep; + RROutputPtr output; + CARD8 *extra; + unsigned long extraLen; + ScreenPtr pScreen; + rrScrPrivPtr pScrPriv; + RRCrtc *crtcs; + RRMode *modes; + RROutput *clones; + char *name; + int i, n; REQUEST_SIZE_MATCH(xRRGetOutputInfoReq); output = LookupOutput(client, stuff->output, DixReadAccess); - if (!output) - { - client->errorValue = stuff->output; - return RRErrorBase + BadRROutput; + if (!output) { + client->errorValue = stuff->output; + return RRErrorBase + BadRROutput; } pScreen = output->pScreen; @@ -472,64 +441,58 @@ ProcRRGetOutputInfo (ClientPtr client) rep.nameLength = output->nameLength; extraLen = ((output->numCrtcs + - output->numModes + output->numUserModes + - output->numClones + - ((rep.nameLength + 3) >> 2)) << 2); - - if (extraLen) - { - rep.length += extraLen >> 2; - extra = xalloc (extraLen); - if (!extra) - return BadAlloc; + output->numModes + output->numUserModes + + output->numClones + ((rep.nameLength + 3) >> 2)) << 2); + + if (extraLen) { + rep.length += extraLen >> 2; + extra = xalloc(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], n); + for (i = 0; i < output->numCrtcs; i++) { + crtcs[i] = output->crtcs[i]->id; + if (client->swapped) + swapl(&crtcs[i], n); } - 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], n); + 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], n); } - for (i = 0; i < output->numClones; i++) - { - clones[i] = output->clones[i]->id; - if (client->swapped) - swapl (&clones[i], n); + for (i = 0; i < output->numClones; i++) { + clones[i] = output->clones[i]->id; + if (client->swapped) + swapl(&clones[i], n); } - memcpy (name, output->name, output->nameLength); + memcpy(name, output->name, output->nameLength); if (client->swapped) { - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, n); - swapl(&rep.timestamp, n); - swapl(&rep.crtc, n); - swapl(&rep.mmWidth, n); - swapl(&rep.mmHeight, n); - swaps(&rep.nCrtcs, n); - swaps(&rep.nModes, n); - swaps(&rep.nClones, n); - swaps(&rep.nameLength, n); + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.timestamp, n); + swapl(&rep.crtc, n); + swapl(&rep.mmWidth, n); + swapl(&rep.mmHeight, n); + swaps(&rep.nCrtcs, n); + swaps(&rep.nModes, n); + swaps(&rep.nClones, n); + swaps(&rep.nameLength, n); } - WriteToClient(client, sizeof(xRRGetOutputInfoReply), (char *)&rep); - if (extraLen) - { - WriteToClient (client, extraLen, (char *) extra); - xfree (extra); + WriteToClient(client, sizeof(xRRGetOutputInfoReply), (char *) &rep); + if (extraLen) { + WriteToClient(client, extraLen, (char *) extra); + xfree(extra); } return client->noClientException; -- cgit v1.2.3 From c2b1f489d7998c83af73c7cb25bbb2bc53f26094 Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Mon, 20 Jun 2016 11:10:06 +0200 Subject: Backport RANDR proto version 1.5 to nx-X11's Xserver. Backported to X.org's /xorg/xserver Git hash level: a6b6e8ba026acedef6336b17adf06aebddd5f22f. --- nx-X11/programs/Xserver/randr/rroutput.c | 308 ++++++++++++++++++++++++------- 1 file changed, 241 insertions(+), 67 deletions(-) (limited to 'nx-X11/programs/Xserver/randr/rroutput.c') diff --git a/nx-X11/programs/Xserver/randr/rroutput.c b/nx-X11/programs/Xserver/randr/rroutput.c index 523ee55d8..2628fabb0 100644 --- a/nx-X11/programs/Xserver/randr/rroutput.c +++ b/nx-X11/programs/Xserver/randr/rroutput.c @@ -1,5 +1,6 @@ /* * Copyright © 2006 Keith Packard + * Copyright © 2008 Red Hat, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -21,7 +22,6 @@ */ #include "randrstr.h" -#include "registry.h" RESTYPE RROutputType; @@ -31,15 +31,30 @@ RESTYPE RROutputType; void RROutputChanged(RROutputPtr output, Bool configChanged) { + /* set changed bits on the master screen only */ ScreenPtr pScreen = output->pScreen; + rrScrPrivPtr mastersp; output->changed = TRUE; - if (pScreen) { - rrScrPriv(pScreen); - pScrPriv->changed = TRUE; - if (configChanged) - pScrPriv->configChanged = TRUE; + if (!pScreen) + return; + +#ifndef NXAGENT_SERVER + if (pScreen->isGPU) { + ScreenPtr master = pScreen->current_master; + if (!master) + return; + mastersp = rrGetScrPriv(master); } + else +#endif + { + mastersp = rrGetScrPriv(pScreen); + } + + RRSetChanged(pScreen); + if (configChanged) + mastersp->configChanged = TRUE; } /* @@ -60,8 +75,13 @@ RROutputCreate(ScreenPtr pScreen, pScrPriv = rrGetScrPriv(pScreen); if (pScrPriv->numOutputs) +#ifndef NXAGENT_SERVER + outputs = reallocarray(pScrPriv->outputs, + pScrPriv->numOutputs + 1, sizeof(RROutputPtr)); +#else /* !defined(NXAGENT_SERVER) */ outputs = xrealloc(pScrPriv->outputs, (pScrPriv->numOutputs + 1) * sizeof(RROutputPtr)); +#endif /* !defined(NXAGENT_SERVER) */ else outputs = xalloc(sizeof(RROutputPtr)); if (!outputs) @@ -101,6 +121,9 @@ RROutputCreate(ScreenPtr pScreen, return NULL; pScrPriv->outputs[pScrPriv->numOutputs++] = output; + + RRResourcesChanged(pScreen); + return output; } @@ -121,14 +144,17 @@ RROutputSetClones(RROutputPtr output, RROutputPtr * clones, int numClones) return TRUE; } if (numClones) { +#ifndef NXAGENT_SERVER + newClones = xallocarray(numClones, sizeof(RROutputPtr)); +#else /* !defined(NXAGENT_SERVER) */ newClones = xalloc(numClones * sizeof(RROutputPtr)); +#endif /* !defined(NXAGENT_SERVER) */ if (!newClones) return FALSE; } else newClones = NULL; - if (output->clones) - xfree(output->clones); + xfree(output->clones); memcpy(newClones, clones, numClones * sizeof(RROutputPtr)); output->clones = newClones; output->numClones = numClones; @@ -155,7 +181,11 @@ RROutputSetModes(RROutputPtr output, } if (numModes) { +#ifndef NXAGENT_SERVER + newModes = xallocarray(numModes, sizeof(RRModePtr)); +#else /* !defined(NXAGENT_SERVER) */ newModes = xalloc(numModes * sizeof(RRModePtr)); +#endif /* !defined(NXAGENT_SERVER) */ if (!newModes) return FALSE; } @@ -198,8 +228,13 @@ RROutputAddUserMode(RROutputPtr output, RRModePtr mode) return BadMatch; if (output->userModes) +#ifndef NXAGENT_SERVER + newModes = reallocarray(output->userModes, + output->numUserModes + 1, sizeof(RRModePtr)); +#else /* !defined(NXAGENT_SERVER) */ newModes = xrealloc(output->userModes, (output->numUserModes + 1) * sizeof(RRModePtr)); +#endif /* !defined(NXAGENT_SERVER) */ else newModes = xalloc(sizeof(RRModePtr)); if (!newModes) @@ -254,14 +289,17 @@ RROutputSetCrtcs(RROutputPtr output, RRCrtcPtr * crtcs, int numCrtcs) return TRUE; } if (numCrtcs) { +#ifndef NXAGENT_SERVER + newCrtcs = xallocarray(numCrtcs, sizeof(RRCrtcPtr)); +#else /* !defined(NXAGENT_SERVER) */ newCrtcs = xalloc(numCrtcs * sizeof(RRCrtcPtr)); +#endif /* !defined(NXAGENT_SERVER) */ if (!newCrtcs) return FALSE; } else newCrtcs = NULL; - if (output->crtcs) - xfree(output->crtcs); + xfree(output->crtcs); memcpy(newCrtcs, crtcs, numCrtcs * sizeof(RRCrtcPtr)); output->crtcs = newCrtcs; output->numCrtcs = numCrtcs; @@ -307,29 +345,25 @@ 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; - - oe.type = RRNotify + RREventBase; - oe.subCode = RRNotify_OutputChange; - oe.sequenceNumber = client->sequence; - 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; - } - else { - oe.crtc = None; - oe.mode = None; - oe.rotation = RR_Rotate_0; - } - oe.connection = output->connection; - oe.subpixelOrder = output->subpixelOrder; + RRModePtr mode = crtc ? crtc->mode : NULL; + + xRROutputChangeNotifyEvent oe = { + .type = RRNotify + RREventBase, + .subCode = RRNotify_OutputChange, +#ifdef NXAGENT_SERVER + .sequenceNumber = client->sequence, +#endif + .timestamp = pScrPriv->lastSetTime.milliseconds, + .configTimestamp = pScrPriv->lastConfigTime.milliseconds, + .window = pWin->drawable.id, + .output = output->id, + .crtc = crtc ? crtc->id : None, + .mode = mode ? mode->mode.id : None, + .rotation = crtc ? crtc->rotation : RR_Rotate_0, + .connection = output->connection, + .subpixelOrder = output->subpixelOrder + }; WriteEventsToClient(client, 1, (xEvent *) &oe); } @@ -353,6 +387,9 @@ RROutputDestroyResource(void *value, XID pid) 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, @@ -361,6 +398,8 @@ RROutputDestroyResource(void *value, XID pid) break; } } + + RRResourcesChanged(pScreen); } if (output->modes) { for (m = 0; m < output->numModes; m++) @@ -370,13 +409,10 @@ RROutputDestroyResource(void *value, XID pid) for (m = 0; m < output->numUserModes; m++) RRModeDestroy(output->userModes[m]); - if (output->userModes) - xfree(output->userModes); + xfree(output->userModes); - if (output->crtcs) - xfree(output->crtcs); - if (output->clones) - xfree(output->clones); + xfree(output->crtcs); + xfree(output->clones); RRDeleteAllOutputProperties(output); xfree(output); return 1; @@ -388,13 +424,28 @@ RROutputDestroyResource(void *value, XID pid) Bool RROutputInit(void) { - RROutputType = CreateNewResourceType(RROutputDestroyResource); + RROutputType = CreateNewResourceType(RROutputDestroyResource +#ifndef NXAGENT_SERVER + , "OUTPUT" +#endif + ); if (!RROutputType) return FALSE; - RegisterResourceName(RROutputType, "OUTPUT"); + return TRUE; } +/* + * Initialize output type error value + */ +void +RROutputInitErrorValue(void) +{ +#ifndef NXAGENT_SERVER + SetResourceTypeErrorValue(RROutputType, RRErrorBase + BadRROutput); +#endif +} + #define OutputInfoExtra (SIZEOF(xRRGetOutputInfoReply) - 32) int @@ -411,41 +462,38 @@ ProcRRGetOutputInfo(ClientPtr client) RRMode *modes; RROutput *clones; char *name; - int i, n; + int i; + int n; REQUEST_SIZE_MATCH(xRRGetOutputInfoReq); - output = LookupOutput(client, stuff->output, DixReadAccess); - - if (!output) { - client->errorValue = stuff->output; - return RRErrorBase + BadRROutput; - } + VERIFY_RR_OUTPUT(stuff->output, output, DixReadAccess); pScreen = output->pScreen; pScrPriv = rrGetScrPriv(pScreen); - rep.type = X_Reply; - rep.status = RRSetConfigSuccess; - rep.sequenceNumber = client->sequence; - rep.length = OutputInfoExtra >> 2; - rep.timestamp = pScrPriv->lastSetTime.milliseconds; - rep.crtc = output->crtc ? output->crtc->id : None; - rep.mmWidth = output->mmWidth; - rep.mmHeight = output->mmHeight; - rep.connection = output->connection; - rep.subpixelOrder = output->subpixelOrder; - rep.nCrtcs = output->numCrtcs; - rep.nModes = output->numModes + output->numUserModes; - rep.nPreferred = output->numPreferred; - rep.nClones = output->numClones; - rep.nameLength = output->nameLength; - + rep = (xRRGetOutputInfoReply) { + .type = X_Reply, + .status = RRSetConfigSuccess, + .sequenceNumber = client->sequence, + .length = bytes_to_int32(OutputInfoExtra), + .timestamp = pScrPriv->lastSetTime.milliseconds, + .crtc = output->crtc ? output->crtc->id : None, + .mmWidth = output->mmWidth, + .mmHeight = output->mmHeight, + .connection = output->connection, + .subpixelOrder = output->subpixelOrder, + .nCrtcs = output->numCrtcs, + .nModes = output->numModes + output->numUserModes, + .nPreferred = output->numPreferred, + .nClones = output->numClones, + .nameLength = output->nameLength + }; extraLen = ((output->numCrtcs + - output->numModes + output->numUserModes + - output->numClones + ((rep.nameLength + 3) >> 2)) << 2); + output->numModes + output->numUserModes + + output->numClones + bytes_to_int32(rep.nameLength)) << 2); if (extraLen) { - rep.length += extraLen >> 2; + rep.length += bytes_to_int32(extraLen); extra = xalloc(extraLen); if (!extra) return BadAlloc; @@ -486,6 +534,7 @@ ProcRRGetOutputInfo(ClientPtr client) swapl(&rep.mmHeight, n); swaps(&rep.nCrtcs, n); swaps(&rep.nModes, n); + swaps(&rep.nPreferred, n); swaps(&rep.nClones, n); swaps(&rep.nameLength, n); } @@ -495,5 +544,130 @@ ProcRRGetOutputInfo(ClientPtr client) xfree(extra); } - return client->noClientException; + return Success; +} + +static void +RRSetPrimaryOutput(ScreenPtr pScreen, rrScrPrivPtr pScrPriv, RROutputPtr output) +{ + if (pScrPriv->primaryOutput == output) + return; + + /* clear the old primary */ + if (pScrPriv->primaryOutput) { + RROutputChanged(pScrPriv->primaryOutput, 0); + pScrPriv->primaryOutput = NULL; + } + + /* set the new primary */ + if (output) { + pScrPriv->primaryOutput = output; + RROutputChanged(output, 0); + } + + pScrPriv->layoutChanged = TRUE; + + RRTellChanged(pScreen); +} + +int +ProcRRSetOutputPrimary(ClientPtr client) +{ + REQUEST(xRRSetOutputPrimaryReq); + RROutputPtr output = NULL; + WindowPtr pWin; + rrScrPrivPtr pScrPriv; + int ret; +#ifndef NXAGENT_SERVER + ScreenPtr slave; +#endif + + REQUEST_SIZE_MATCH(xRRSetOutputPrimaryReq); + +#ifndef NXAGENT_SERVER + ret = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); +#else + pWin = SecurityLookupWindow(stuff->window, client, SecurityReadAccess); + ret = pWin ? Success : BadWindow; +#endif + + if (ret != Success) + return ret; + + if (stuff->output) { + VERIFY_RR_OUTPUT(stuff->output, output, DixReadAccess); + +#ifndef NXAGENT_SERVER + if (!output->pScreen->isGPU && output->pScreen != pWin->drawable.pScreen) { + client->errorValue = stuff->window; + return BadMatch; + } + if (output->pScreen->isGPU && + output->pScreen->current_master != pWin->drawable.pScreen) { + client->errorValue = stuff->window; + return BadMatch; + } +#endif + } + + pScrPriv = rrGetScrPriv(pWin->drawable.pScreen); + if (pScrPriv) + { + RRSetPrimaryOutput(pWin->drawable.pScreen, pScrPriv, output); + +#ifndef NXAGENT_SERVER + xorg_list_for_each_entry(slave, + &pWin->drawable.pScreen->output_slave_list, + output_head) { + rrScrPrivPtr pSlavePriv; + pSlavePriv = rrGetScrPriv(slave); + + RRSetPrimaryOutput(slave, pSlavePriv, output); + } +#endif + } + + return Success; +} + +int +ProcRRGetOutputPrimary(ClientPtr client) +{ + REQUEST(xRRGetOutputPrimaryReq); + WindowPtr pWin; + rrScrPrivPtr pScrPriv; + xRRGetOutputPrimaryReply rep; + RROutputPtr primary = NULL; + int rc; + int n; + + REQUEST_SIZE_MATCH(xRRGetOutputPrimaryReq); + +#ifndef NXAGENT_SERVER + rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); +#else + pWin = SecurityLookupWindow(stuff->window, client, SecurityReadAccess); + rc = pWin ? Success : BadWindow; +#endif + + if (rc != Success) + return rc; + + pScrPriv = rrGetScrPriv(pWin->drawable.pScreen); + if (pScrPriv) + primary = pScrPriv->primaryOutput; + + rep = (xRRGetOutputPrimaryReply) { + .type = X_Reply, + .sequenceNumber = client->sequence, + .output = primary ? primary->id : None + }; + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.output, n); + } + + WriteToClient(client, sizeof(xRRGetOutputPrimaryReply), (char *) &rep); + + return Success; } -- cgit v1.2.3