diff options
author | marha <marha@users.sourceforge.net> | 2011-09-22 15:20:09 +0200 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2011-09-22 15:20:09 +0200 |
commit | c1e6c7428a8d2c1b60ffac7df7a3f56c300fa983 (patch) | |
tree | 8874978d314129a4f47ee575b076c2d8eb1a8738 /xorg-server/randr | |
parent | 37466741e35c5eb3b204863a5023bf8d192efc06 (diff) | |
download | vcxsrv-c1e6c7428a8d2c1b60ffac7df7a3f56c300fa983.tar.gz vcxsrv-c1e6c7428a8d2c1b60ffac7df7a3f56c300fa983.tar.bz2 vcxsrv-c1e6c7428a8d2c1b60ffac7df7a3f56c300fa983.zip |
libxtrans libX11 libX11 libXext mesa xserver git update 22 sep 2011
Diffstat (limited to 'xorg-server/randr')
-rw-r--r-- | xorg-server/randr/rrcrtc.c | 100 | ||||
-rw-r--r-- | xorg-server/randr/rrdispatch.c | 9 | ||||
-rw-r--r-- | xorg-server/randr/rrmode.c | 763 | ||||
-rw-r--r-- | xorg-server/randr/rroutput.c | 1249 | ||||
-rw-r--r-- | xorg-server/randr/rrproperty.c | 48 | ||||
-rw-r--r-- | xorg-server/randr/rrscreen.c | 106 | ||||
-rw-r--r-- | xorg-server/randr/rrsdispatch.c | 262 | ||||
-rw-r--r-- | xorg-server/randr/rrxinerama.c | 942 |
8 files changed, 1711 insertions, 1768 deletions
diff --git a/xorg-server/randr/rrcrtc.c b/xorg-server/randr/rrcrtc.c index 0437795c4..e6a38ae60 100644 --- a/xorg-server/randr/rrcrtc.c +++ b/xorg-server/randr/rrcrtc.c @@ -751,7 +751,7 @@ ProcRRGetCrtcInfo (ClientPtr client) RRModePtr mode; RROutput *outputs; RROutput *possible; - int i, j, k, n; + int i, j, k; int width, height; BoxRec panned_area; @@ -818,7 +818,7 @@ ProcRRGetCrtcInfo (ClientPtr client) { outputs[i] = crtc->outputs[i]->id; if (client->swapped) - swapl (&outputs[i], n); + swapl(&outputs[i]); } k = 0; for (i = 0; i < pScrPriv->numOutputs; i++) @@ -827,23 +827,23 @@ ProcRRGetCrtcInfo (ClientPtr client) { possible[k] = pScrPriv->outputs[i]->id; if (client->swapped) - swapl (&possible[k], n); + swapl(&possible[k]); k++; } if (client->swapped) { - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, n); - swapl(&rep.timestamp, n); - swaps(&rep.x, n); - swaps(&rep.y, n); - swaps(&rep.width, n); - swaps(&rep.height, n); - swapl(&rep.mode, n); - swaps(&rep.rotation, n); - swaps(&rep.rotations, n); - swaps(&rep.nOutput, n); - swaps(&rep.nPossibleOutput, n); + swaps(&rep.sequenceNumber); + swapl(&rep.length); + swapl(&rep.timestamp); + swaps(&rep.x); + swaps(&rep.y); + swaps(&rep.width); + swaps(&rep.height); + swapl(&rep.mode); + swaps(&rep.rotation); + swaps(&rep.rotations); + swaps(&rep.nOutput); + swaps(&rep.nPossibleOutput); } WriteToClient(client, sizeof(xRRGetCrtcInfoReply), (char *)&rep); if (extraLen) @@ -1058,10 +1058,9 @@ sendReply: if (client->swapped) { - int n; - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, n); - swapl(&rep.newTimestamp, n); + swaps(&rep.sequenceNumber); + swapl(&rep.length); + swapl(&rep.newTimestamp); } WriteToClient(client, sizeof(xRRSetCrtcConfigReply), (char *)&rep); @@ -1079,7 +1078,6 @@ ProcRRGetPanning (ClientPtr client) BoxRec total; BoxRec tracking; INT16 border[4]; - int n; REQUEST_SIZE_MATCH(xRRGetPanningReq); VERIFY_RR_CRTC(stuff->crtc, crtc, DixReadAccess); @@ -1117,21 +1115,21 @@ ProcRRGetPanning (ClientPtr client) } if (client->swapped) { - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, n); - swaps(&rep.timestamp, n); - swaps(&rep.left, n); - swaps(&rep.top, n); - swaps(&rep.width, n); - swaps(&rep.height, n); - swaps(&rep.track_left, n); - swaps(&rep.track_top, n); - swaps(&rep.track_width, n); - swaps(&rep.track_height, n); - swaps(&rep.border_left, n); - swaps(&rep.border_top, n); - swaps(&rep.border_right, n); - swaps(&rep.border_bottom, n); + swaps(&rep.sequenceNumber); + swapl(&rep.length); + swapl(&rep.timestamp); + swaps(&rep.left); + swaps(&rep.top); + swaps(&rep.width); + swaps(&rep.height); + swaps(&rep.track_left); + swaps(&rep.track_top); + swaps(&rep.track_width); + swaps(&rep.track_height); + swaps(&rep.border_left); + swaps(&rep.border_top); + swaps(&rep.border_right); + swaps(&rep.border_bottom); } WriteToClient(client, sizeof(xRRGetPanningReply), (char *)&rep); return Success; @@ -1149,7 +1147,6 @@ ProcRRSetPanning (ClientPtr client) BoxRec total; BoxRec tracking; INT16 border[4]; - int n; REQUEST_SIZE_MATCH(xRRSetPanningReq); VERIFY_RR_CRTC(stuff->crtc, crtc, DixReadAccess); @@ -1198,9 +1195,9 @@ sendReply: rep.newTimestamp = pScrPriv->lastSetTime.milliseconds; if (client->swapped) { - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, n); - swaps(&rep.newTimestamp, n); + swaps(&rep.sequenceNumber); + swapl(&rep.length); + swapl(&rep.newTimestamp); } WriteToClient(client, sizeof(xRRSetPanningReply), (char *)&rep); return Success; @@ -1212,7 +1209,6 @@ ProcRRGetCrtcGammaSize (ClientPtr client) REQUEST(xRRGetCrtcGammaSizeReq); xRRGetCrtcGammaSizeReply reply; RRCrtcPtr crtc; - int n; REQUEST_SIZE_MATCH(xRRGetCrtcGammaSizeReq); VERIFY_RR_CRTC(stuff->crtc, crtc, DixReadAccess); @@ -1226,9 +1222,9 @@ ProcRRGetCrtcGammaSize (ClientPtr client) reply.length = 0; reply.size = crtc->gammaSize; if (client->swapped) { - swaps (&reply.sequenceNumber, n); - swapl (&reply.length, n); - swaps (&reply.size, n); + swaps(&reply.sequenceNumber); + swapl(&reply.length); + swaps(&reply.size); } WriteToClient (client, sizeof (xRRGetCrtcGammaSizeReply), (char *) &reply); return Success; @@ -1240,7 +1236,6 @@ ProcRRGetCrtcGamma (ClientPtr client) REQUEST(xRRGetCrtcGammaReq); xRRGetCrtcGammaReply reply; RRCrtcPtr crtc; - int n; unsigned long len; char *extra = NULL; @@ -1264,9 +1259,9 @@ ProcRRGetCrtcGamma (ClientPtr client) reply.length = bytes_to_int32(len); reply.size = crtc->gammaSize; if (client->swapped) { - swaps (&reply.sequenceNumber, n); - swapl (&reply.length, n); - swaps (&reply.size, n); + swaps(&reply.sequenceNumber); + swapl(&reply.length); + swaps(&reply.size); } WriteToClient (client, sizeof (xRRGetCrtcGammaReply), (char *) &reply); if (crtc->gammaSize) @@ -1361,7 +1356,6 @@ transform_filter_encode (ClientPtr client, char *output, RRTransformPtr transform) { int nbytes, nparams; - int n; if (transform->filter == NULL) { *nbytesFilter = 0; @@ -1377,8 +1371,8 @@ transform_filter_encode (ClientPtr client, char *output, output[nbytes++] = 0; memcpy (output + nbytes, transform->params, nparams * sizeof (xFixed)); if (client->swapped) { - swaps (nbytesFilter, n); - swaps (nparamsFilter, n); + swaps(nbytesFilter); + swaps(nparamsFilter); SwapLongs ((CARD32 *) (output + nbytes), nparams); } nbytes += nparams * sizeof (xFixed); @@ -1399,7 +1393,7 @@ ProcRRGetCrtcTransform (ClientPtr client) REQUEST(xRRGetCrtcTransformReq); xRRGetCrtcTransformReply *reply; RRCrtcPtr crtc; - int n, nextra; + int nextra; RRTransformPtr current, pending; char *extra; @@ -1436,8 +1430,8 @@ ProcRRGetCrtcTransform (ClientPtr client) current); if (client->swapped) { - swaps (&reply->sequenceNumber, n); - swapl (&reply->length, n); + swaps(&reply->sequenceNumber); + swapl(&reply->length); } WriteToClient (client, sizeof (xRRGetCrtcTransformReply) + nextra, (char *) reply); free(reply); diff --git a/xorg-server/randr/rrdispatch.c b/xorg-server/randr/rrdispatch.c index d1c99c288..5a6a85287 100644 --- a/xorg-server/randr/rrdispatch.c +++ b/xorg-server/randr/rrdispatch.c @@ -36,7 +36,6 @@ static int ProcRRQueryVersion (ClientPtr client) { xRRQueryVersionReply rep = {0}; - register int n; REQUEST(xRRQueryVersionReq); rrClientPriv(client); @@ -59,10 +58,10 @@ ProcRRQueryVersion (ClientPtr client) } if (client->swapped) { - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, n); - swapl(&rep.majorVersion, n); - swapl(&rep.minorVersion, n); + swaps(&rep.sequenceNumber); + swapl(&rep.length); + swapl(&rep.majorVersion); + swapl(&rep.minorVersion); } WriteToClient(client, sizeof(xRRQueryVersionReply), (char *)&rep); return Success; diff --git a/xorg-server/randr/rrmode.c b/xorg-server/randr/rrmode.c index ae7939909..63a2d2a74 100644 --- a/xorg-server/randr/rrmode.c +++ b/xorg-server/randr/rrmode.c @@ -1,382 +1,381 @@ -/*
- * Copyright © 2006 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that copyright
- * notice and this permission notice appear in supporting documentation, and
- * that the name of the copyright holders not be used in advertising or
- * publicity pertaining to distribution of the software without specific,
- * written prior permission. The copyright holders make no representations
- * about the suitability of this software for any purpose. It is provided "as
- * is" without express or implied warranty.
- *
- * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-#include "randrstr.h"
-
-RESTYPE RRModeType;
-
-static Bool
-RRModeEqual (xRRModeInfo *a, xRRModeInfo *b)
-{
- if (a->width != b->width) return FALSE;
- if (a->height != b->height) return FALSE;
- if (a->dotClock != b->dotClock) return FALSE;
- if (a->hSyncStart != b->hSyncStart) return FALSE;
- if (a->hSyncEnd != b->hSyncEnd) return FALSE;
- if (a->hTotal != b->hTotal) return FALSE;
- if (a->hSkew != b->hSkew) return FALSE;
- if (a->vSyncStart != b->vSyncStart) return FALSE;
- if (a->vSyncEnd != b->vSyncEnd) return FALSE;
- if (a->vTotal != b->vTotal) return FALSE;
- if (a->nameLength != b->nameLength) return FALSE;
- if (a->modeFlags != b->modeFlags) return FALSE;
- return TRUE;
-}
-
-/*
- * Keep a list so it's easy to find modes in the resource database.
- */
-static int num_modes;
-static RRModePtr *modes;
-
-static RRModePtr
-RRModeCreate (xRRModeInfo *modeInfo,
- const char *name,
- ScreenPtr userScreen)
-{
- RRModePtr mode, *newModes;
-
- if (!RRInit ())
- return NULL;
-
- mode = malloc(sizeof (RRModeRec) + modeInfo->nameLength + 1);
- if (!mode)
- return NULL;
- mode->refcnt = 1;
- mode->mode = *modeInfo;
- mode->name = (char *) (mode + 1);
- memcpy (mode->name, name, modeInfo->nameLength);
- mode->name[modeInfo->nameLength] = '\0';
- mode->userScreen = userScreen;
-
- if (num_modes)
- newModes = realloc(modes, (num_modes + 1) * sizeof (RRModePtr));
- else
- newModes = malloc(sizeof (RRModePtr));
-
- if (!newModes)
- {
- free(mode);
- return NULL;
- }
-
- mode->mode.id = FakeClientID(0);
- if (!AddResource (mode->mode.id, RRModeType, (pointer) mode))
- return NULL;
- modes = newModes;
- modes[num_modes++] = mode;
-
- /*
- * give the caller a reference to this mode
- */
- ++mode->refcnt;
- return mode;
-}
-
-static RRModePtr
-RRModeFindByName (const char *name,
- CARD16 nameLength)
-{
- int i;
- RRModePtr mode;
-
- for (i = 0; i < num_modes; i++)
- {
- mode = modes[i];
- if (mode->mode.nameLength == nameLength &&
- !memcmp (name, mode->name, nameLength))
- {
- return mode;
- }
- }
- return NULL;
-}
-
-RRModePtr
-RRModeGet (xRRModeInfo *modeInfo,
- const char *name)
-{
- int i;
-
- for (i = 0; i < num_modes; i++)
- {
- RRModePtr mode = modes[i];
- if (RRModeEqual (&mode->mode, modeInfo) &&
- !memcmp (name, mode->name, modeInfo->nameLength))
- {
- ++mode->refcnt;
- return mode;
- }
- }
-
- return RRModeCreate (modeInfo, name, NULL);
-}
-
-static RRModePtr
-RRModeCreateUser (ScreenPtr pScreen,
- xRRModeInfo *modeInfo,
- const char *name,
- int *error)
-{
- RRModePtr mode;
-
- mode = RRModeFindByName (name, modeInfo->nameLength);
- if (mode)
- {
- *error = BadName;
- return NULL;
- }
-
- mode = RRModeCreate (modeInfo, name, pScreen);
- if (!mode)
- {
- *error = BadAlloc;
- return NULL;
- }
- *error = Success;
- return mode;
-}
-
-RRModePtr *
-RRModesForScreen (ScreenPtr pScreen, int *num_ret)
-{
- rrScrPriv(pScreen);
- int o, c, m;
- RRModePtr *screen_modes;
- int num_screen_modes = 0;
-
- screen_modes = malloc((num_modes ? num_modes : 1) * sizeof (RRModePtr));
- if (!screen_modes)
- return NULL;
-
- /*
- * Add modes from all outputs
- */
- for (o = 0; o < pScrPriv->numOutputs; o++)
- {
- RROutputPtr output = pScrPriv->outputs[o];
- int m, n;
-
- for (m = 0; m < output->numModes + output->numUserModes; m++)
- {
- RRModePtr mode = (m < output->numModes ?
- output->modes[m] :
- output->userModes[m-output->numModes]);
- for (n = 0; n < num_screen_modes; n++)
- if (screen_modes[n] == mode)
- break;
- if (n == num_screen_modes)
- screen_modes[num_screen_modes++] = mode;
- }
- }
- /*
- * Add modes from all crtcs. The goal is to
- * make sure all available and active modes
- * are visible to the client
- */
- for (c = 0; c < pScrPriv->numCrtcs; c++)
- {
- RRCrtcPtr crtc = pScrPriv->crtcs[c];
- RRModePtr mode = crtc->mode;
- int n;
-
- if (!mode) continue;
- for (n = 0; n < num_screen_modes; n++)
- if (screen_modes[n] == mode)
- break;
- if (n == num_screen_modes)
- screen_modes[num_screen_modes++] = mode;
- }
- /*
- * Add all user modes for this screen
- */
- for (m = 0; m < num_modes; m++)
- {
- RRModePtr mode = modes[m];
- int n;
-
- if (mode->userScreen != pScreen)
- continue;
- for (n = 0; n < num_screen_modes; n++)
- if (screen_modes[n] == mode)
- break;
- if (n == num_screen_modes)
- screen_modes[num_screen_modes++] = mode;
- }
-
- *num_ret = num_screen_modes;
- return screen_modes;
-}
-
-void
-RRModeDestroy (RRModePtr mode)
-{
- int m;
-
- if (--mode->refcnt > 0)
- return;
- for (m = 0; m < num_modes; m++)
- {
- if (modes[m] == mode)
- {
- memmove (modes + m, modes + m + 1,
- (num_modes - m - 1) * sizeof (RRModePtr));
- num_modes--;
- if (!num_modes)
- {
- free(modes);
- modes = NULL;
- }
- break;
- }
- }
-
- free(mode);
-}
-
-static int
-RRModeDestroyResource (pointer value, XID pid)
-{
- RRModeDestroy ((RRModePtr) value);
- return 1;
-}
-
-/*
- * Initialize mode type
- */
-Bool
-RRModeInit (void)
-{
- assert (num_modes == 0);
- assert (modes == NULL);
- RRModeType = CreateNewResourceType (RRModeDestroyResource, "MODE");
- if (!RRModeType)
- return FALSE;
-
- return TRUE;
-}
-
-/*
- * Initialize mode type error value
- */
-void
-RRModeInitErrorValue(void)
-{
- SetResourceTypeErrorValue(RRModeType, RRErrorBase + BadRRMode);
-}
-
-int
-ProcRRCreateMode (ClientPtr client)
-{
- REQUEST(xRRCreateModeReq);
- xRRCreateModeReply rep = {0};
- WindowPtr pWin;
- ScreenPtr pScreen;
- rrScrPrivPtr pScrPriv;
- xRRModeInfo *modeInfo;
- long units_after;
- char *name;
- int error, rc;
- RRModePtr mode;
-
- REQUEST_AT_LEAST_SIZE (xRRCreateModeReq);
- rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
- if (rc != Success)
- return rc;
-
- pScreen = pWin->drawable.pScreen;
- pScrPriv = rrGetScrPriv(pScreen);
-
- modeInfo = &stuff->modeInfo;
- name = (char *) (stuff + 1);
- units_after = (stuff->length - bytes_to_int32(sizeof (xRRCreateModeReq)));
-
- /* check to make sure requested name fits within the data provided */
- if (bytes_to_int32(modeInfo->nameLength) > units_after)
- return BadLength;
-
- mode = RRModeCreateUser (pScreen, modeInfo, name, &error);
- if (!mode)
- return error;
-
- rep.type = X_Reply;
- rep.pad0 = 0;
- rep.sequenceNumber = client->sequence;
- rep.length = 0;
- rep.mode = mode->mode.id;
- if (client->swapped)
- {
- int n;
- swaps(&rep.sequenceNumber, n);
- swapl(&rep.length, n);
- swapl(&rep.mode, n);
- }
- WriteToClient(client, sizeof(xRRCreateModeReply), (char *)&rep);
- /* Drop out reference to this mode */
- RRModeDestroy (mode);
- return Success;
-}
-
-int
-ProcRRDestroyMode (ClientPtr client)
-{
- REQUEST(xRRDestroyModeReq);
- RRModePtr mode;
-
- REQUEST_SIZE_MATCH(xRRDestroyModeReq);
- VERIFY_RR_MODE(stuff->mode, mode, DixDestroyAccess);
-
- if (!mode->userScreen)
- return BadMatch;
- if (mode->refcnt > 1)
- return BadAccess;
- FreeResource (stuff->mode, 0);
- return Success;
-}
-
-int
-ProcRRAddOutputMode (ClientPtr client)
-{
- REQUEST(xRRAddOutputModeReq);
- RRModePtr mode;
- RROutputPtr output;
-
- REQUEST_SIZE_MATCH(xRRAddOutputModeReq);
- VERIFY_RR_OUTPUT(stuff->output, output, DixReadAccess);
- VERIFY_RR_MODE(stuff->mode, mode, DixUseAccess);
-
- return RROutputAddUserMode (output, mode);
-}
-
-int
-ProcRRDeleteOutputMode (ClientPtr client)
-{
- REQUEST(xRRDeleteOutputModeReq);
- RRModePtr mode;
- RROutputPtr output;
-
- REQUEST_SIZE_MATCH(xRRDeleteOutputModeReq);
- VERIFY_RR_OUTPUT(stuff->output, output, DixReadAccess);
- VERIFY_RR_MODE(stuff->mode, mode, DixUseAccess);
-
- return RROutputDeleteUserMode (output, mode);
-}
+/* + * Copyright © 2006 Keith Packard + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include "randrstr.h" + +RESTYPE RRModeType; + +static Bool +RRModeEqual (xRRModeInfo *a, xRRModeInfo *b) +{ + if (a->width != b->width) return FALSE; + if (a->height != b->height) return FALSE; + if (a->dotClock != b->dotClock) return FALSE; + if (a->hSyncStart != b->hSyncStart) return FALSE; + if (a->hSyncEnd != b->hSyncEnd) return FALSE; + if (a->hTotal != b->hTotal) return FALSE; + if (a->hSkew != b->hSkew) return FALSE; + if (a->vSyncStart != b->vSyncStart) return FALSE; + if (a->vSyncEnd != b->vSyncEnd) return FALSE; + if (a->vTotal != b->vTotal) return FALSE; + if (a->nameLength != b->nameLength) return FALSE; + if (a->modeFlags != b->modeFlags) return FALSE; + return TRUE; +} + +/* + * Keep a list so it's easy to find modes in the resource database. + */ +static int num_modes; +static RRModePtr *modes; + +static RRModePtr +RRModeCreate (xRRModeInfo *modeInfo, + const char *name, + ScreenPtr userScreen) +{ + RRModePtr mode, *newModes; + + if (!RRInit ()) + return NULL; + + mode = malloc(sizeof (RRModeRec) + modeInfo->nameLength + 1); + if (!mode) + return NULL; + mode->refcnt = 1; + mode->mode = *modeInfo; + mode->name = (char *) (mode + 1); + memcpy (mode->name, name, modeInfo->nameLength); + mode->name[modeInfo->nameLength] = '\0'; + mode->userScreen = userScreen; + + if (num_modes) + newModes = realloc(modes, (num_modes + 1) * sizeof (RRModePtr)); + else + newModes = malloc(sizeof (RRModePtr)); + + if (!newModes) + { + free(mode); + return NULL; + } + + mode->mode.id = FakeClientID(0); + if (!AddResource (mode->mode.id, RRModeType, (pointer) mode)) + return NULL; + modes = newModes; + modes[num_modes++] = mode; + + /* + * give the caller a reference to this mode + */ + ++mode->refcnt; + return mode; +} + +static RRModePtr +RRModeFindByName (const char *name, + CARD16 nameLength) +{ + int i; + RRModePtr mode; + + for (i = 0; i < num_modes; i++) + { + mode = modes[i]; + if (mode->mode.nameLength == nameLength && + !memcmp (name, mode->name, nameLength)) + { + return mode; + } + } + return NULL; +} + +RRModePtr +RRModeGet (xRRModeInfo *modeInfo, + const char *name) +{ + int i; + + for (i = 0; i < num_modes; i++) + { + RRModePtr mode = modes[i]; + if (RRModeEqual (&mode->mode, modeInfo) && + !memcmp (name, mode->name, modeInfo->nameLength)) + { + ++mode->refcnt; + return mode; + } + } + + return RRModeCreate (modeInfo, name, NULL); +} + +static RRModePtr +RRModeCreateUser (ScreenPtr pScreen, + xRRModeInfo *modeInfo, + const char *name, + int *error) +{ + RRModePtr mode; + + mode = RRModeFindByName (name, modeInfo->nameLength); + if (mode) + { + *error = BadName; + return NULL; + } + + mode = RRModeCreate (modeInfo, name, pScreen); + if (!mode) + { + *error = BadAlloc; + return NULL; + } + *error = Success; + return mode; +} + +RRModePtr * +RRModesForScreen (ScreenPtr pScreen, int *num_ret) +{ + rrScrPriv(pScreen); + int o, c, m; + RRModePtr *screen_modes; + int num_screen_modes = 0; + + screen_modes = malloc((num_modes ? num_modes : 1) * sizeof (RRModePtr)); + if (!screen_modes) + return NULL; + + /* + * Add modes from all outputs + */ + for (o = 0; o < pScrPriv->numOutputs; o++) + { + RROutputPtr output = pScrPriv->outputs[o]; + int m, n; + + for (m = 0; m < output->numModes + output->numUserModes; m++) + { + RRModePtr mode = (m < output->numModes ? + output->modes[m] : + output->userModes[m-output->numModes]); + for (n = 0; n < num_screen_modes; n++) + if (screen_modes[n] == mode) + break; + if (n == num_screen_modes) + screen_modes[num_screen_modes++] = mode; + } + } + /* + * Add modes from all crtcs. The goal is to + * make sure all available and active modes + * are visible to the client + */ + for (c = 0; c < pScrPriv->numCrtcs; c++) + { + RRCrtcPtr crtc = pScrPriv->crtcs[c]; + RRModePtr mode = crtc->mode; + int n; + + if (!mode) continue; + for (n = 0; n < num_screen_modes; n++) + if (screen_modes[n] == mode) + break; + if (n == num_screen_modes) + screen_modes[num_screen_modes++] = mode; + } + /* + * Add all user modes for this screen + */ + for (m = 0; m < num_modes; m++) + { + RRModePtr mode = modes[m]; + int n; + + if (mode->userScreen != pScreen) + continue; + for (n = 0; n < num_screen_modes; n++) + if (screen_modes[n] == mode) + break; + if (n == num_screen_modes) + screen_modes[num_screen_modes++] = mode; + } + + *num_ret = num_screen_modes; + return screen_modes; +} + +void +RRModeDestroy (RRModePtr mode) +{ + int m; + + if (--mode->refcnt > 0) + return; + for (m = 0; m < num_modes; m++) + { + if (modes[m] == mode) + { + memmove (modes + m, modes + m + 1, + (num_modes - m - 1) * sizeof (RRModePtr)); + num_modes--; + if (!num_modes) + { + free(modes); + modes = NULL; + } + break; + } + } + + free(mode); +} + +static int +RRModeDestroyResource (pointer value, XID pid) +{ + RRModeDestroy ((RRModePtr) value); + return 1; +} + +/* + * Initialize mode type + */ +Bool +RRModeInit (void) +{ + assert (num_modes == 0); + assert (modes == NULL); + RRModeType = CreateNewResourceType (RRModeDestroyResource, "MODE"); + if (!RRModeType) + return FALSE; + + return TRUE; +} + +/* + * Initialize mode type error value + */ +void +RRModeInitErrorValue(void) +{ + SetResourceTypeErrorValue(RRModeType, RRErrorBase + BadRRMode); +} + +int +ProcRRCreateMode (ClientPtr client) +{ + REQUEST(xRRCreateModeReq); + xRRCreateModeReply rep = {0}; + WindowPtr pWin; + ScreenPtr pScreen; + rrScrPrivPtr pScrPriv; + xRRModeInfo *modeInfo; + long units_after; + char *name; + int error, rc; + RRModePtr mode; + + REQUEST_AT_LEAST_SIZE (xRRCreateModeReq); + rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); + if (rc != Success) + return rc; + + pScreen = pWin->drawable.pScreen; + pScrPriv = rrGetScrPriv(pScreen); + + modeInfo = &stuff->modeInfo; + name = (char *) (stuff + 1); + units_after = (stuff->length - bytes_to_int32(sizeof (xRRCreateModeReq))); + + /* check to make sure requested name fits within the data provided */ + if (bytes_to_int32(modeInfo->nameLength) > units_after) + return BadLength; + + mode = RRModeCreateUser (pScreen, modeInfo, name, &error); + if (!mode) + return error; + + rep.type = X_Reply; + rep.pad0 = 0; + rep.sequenceNumber = client->sequence; + rep.length = 0; + rep.mode = mode->mode.id; + if (client->swapped) + { + swaps(&rep.sequenceNumber); + swapl(&rep.length); + swapl(&rep.mode); + } + WriteToClient(client, sizeof(xRRCreateModeReply), (char *)&rep); + /* Drop out reference to this mode */ + RRModeDestroy (mode); + return Success; +} + +int +ProcRRDestroyMode (ClientPtr client) +{ + REQUEST(xRRDestroyModeReq); + RRModePtr mode; + + REQUEST_SIZE_MATCH(xRRDestroyModeReq); + VERIFY_RR_MODE(stuff->mode, mode, DixDestroyAccess); + + if (!mode->userScreen) + return BadMatch; + if (mode->refcnt > 1) + return BadAccess; + FreeResource (stuff->mode, 0); + return Success; +} + +int +ProcRRAddOutputMode (ClientPtr client) +{ + REQUEST(xRRAddOutputModeReq); + RRModePtr mode; + RROutputPtr output; + + REQUEST_SIZE_MATCH(xRRAddOutputModeReq); + VERIFY_RR_OUTPUT(stuff->output, output, DixReadAccess); + VERIFY_RR_MODE(stuff->mode, mode, DixUseAccess); + + return RROutputAddUserMode (output, mode); +} + +int +ProcRRDeleteOutputMode (ClientPtr client) +{ + REQUEST(xRRDeleteOutputModeReq); + RRModePtr mode; + RROutputPtr output; + + REQUEST_SIZE_MATCH(xRRDeleteOutputModeReq); + VERIFY_RR_OUTPUT(stuff->output, output, DixReadAccess); + VERIFY_RR_MODE(stuff->mode, mode, DixUseAccess); + + return RROutputDeleteUserMode (output, mode); +} diff --git a/xorg-server/randr/rroutput.c b/xorg-server/randr/rroutput.c index 8f661a383..b57be198f 100644 --- a/xorg-server/randr/rroutput.c +++ b/xorg-server/randr/rroutput.c @@ -1,625 +1,624 @@ -/*
- * 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
- * the above copyright notice appear in all copies and that both that copyright
- * notice and this permission notice appear in supporting documentation, and
- * that the name of the copyright holders not be used in advertising or
- * publicity pertaining to distribution of the software without specific,
- * written prior permission. The copyright holders make no representations
- * about the suitability of this software for any purpose. It is provided "as
- * is" without express or implied warranty.
- *
- * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-#include "randrstr.h"
-
-RESTYPE RROutputType;
-
-/*
- * Notify the output of some change
- */
-void
-RROutputChanged (RROutputPtr output, Bool configChanged)
-{
- ScreenPtr pScreen = output->pScreen;
-
- output->changed = TRUE;
- if (pScreen)
- {
- rrScrPriv (pScreen);
- pScrPriv->changed = TRUE;
- if (configChanged)
- pScrPriv->configChanged = TRUE;
- }
-}
-
-/*
- * Create an output
- */
-
-RROutputPtr
-RROutputCreate (ScreenPtr pScreen,
- const char *name,
- int nameLength,
- void *devPrivate)
-{
- RROutputPtr output;
- RROutputPtr *outputs;
- rrScrPrivPtr pScrPriv;
-
- if (!RRInit())
- return NULL;
-
- pScrPriv = rrGetScrPriv(pScreen);
-
- if (pScrPriv->numOutputs)
- outputs = realloc(pScrPriv->outputs,
- (pScrPriv->numOutputs + 1) * sizeof (RROutputPtr));
- else
- outputs = malloc(sizeof (RROutputPtr));
- if (!outputs)
- return FALSE;
-
- pScrPriv->outputs = outputs;
-
- output = malloc(sizeof (RROutputRec) + nameLength + 1);
- if (!output)
- return NULL;
- output->id = FakeClientID (0);
- output->pScreen = pScreen;
- output->name = (char *) (output + 1);
- output->nameLength = nameLength;
- memcpy (output->name, name, nameLength);
- output->name[nameLength] = '\0';
- output->connection = RR_UnknownConnection;
- output->subpixelOrder = SubPixelUnknown;
- output->mmWidth = 0;
- output->mmHeight = 0;
- output->crtc = NULL;
- output->numCrtcs = 0;
- output->crtcs = NULL;
- output->numClones = 0;
- output->clones = NULL;
- output->numModes = 0;
- output->numPreferred = 0;
- output->modes = NULL;
- output->numUserModes = 0;
- output->userModes = NULL;
- output->properties = NULL;
- output->pendingProperties = FALSE;
- output->changed = FALSE;
- output->devPrivate = devPrivate;
-
- if (!AddResource (output->id, RROutputType, (pointer) output))
- return NULL;
-
- pScrPriv->outputs[pScrPriv->numOutputs++] = output;
- return output;
-}
-
-/*
- * Notify extension that output parameters have been changed
- */
-Bool
-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;
- }
- if (numClones)
- {
- newClones = malloc(numClones * sizeof (RROutputPtr));
- if (!newClones)
- return FALSE;
- }
- else
- newClones = NULL;
- free(output->clones);
- memcpy (newClones, clones, numClones * sizeof (RROutputPtr));
- output->clones = newClones;
- output->numClones = numClones;
- RROutputChanged (output, TRUE);
- return TRUE;
-}
-
-Bool
-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;
- }
- }
-
- 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);
- }
- memcpy (newModes, modes, numModes * sizeof (RRModePtr));
- output->modes = newModes;
- output->numModes = numModes;
- output->numPreferred = numPreferred;
- RROutputChanged (output, TRUE);
- return TRUE;
-}
-
-int
-RROutputAddUserMode (RROutputPtr output,
- RRModePtr mode)
-{
- int m;
- ScreenPtr pScreen = output->pScreen;
- rrScrPriv(pScreen);
- 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;
- }
-
- /* Check with the DDX to see if this mode is OK */
- if (pScrPriv->rrOutputValidateMode)
- if (!pScrPriv->rrOutputValidateMode (pScreen, output, mode))
- return BadMatch;
-
- if (output->userModes)
- newModes = realloc(output->userModes,
- (output->numUserModes + 1) * sizeof (RRModePtr));
- else
- newModes = malloc(sizeof (RRModePtr));
- if (!newModes)
- return BadAlloc;
-
- output->userModes = newModes;
- output->userModes[output->numUserModes++] = mode;
- ++mode->refcnt;
- RROutputChanged (output, TRUE);
- RRTellChanged (pScreen);
- return Success;
-}
-
-int
-RROutputDeleteUserMode (RROutputPtr output,
- RRModePtr mode)
-{
- int m;
-
- /* Find this mode in the user mode list */
- for (m = 0; m < output->numUserModes; m++)
- {
- RRModePtr e = output->userModes[m];
-
- if (mode == e)
- break;
- }
- /* Not there, access error */
- if (m == output->numUserModes)
- return BadAccess;
-
- /* make sure the mode isn't active for this output */
- if (output->crtc && output->crtc->mode == mode)
- return BadMatch;
-
- memmove (output->userModes + m, output->userModes + m + 1,
- (output->numUserModes - m - 1) * sizeof (RRModePtr));
- output->numUserModes--;
- RRModeDestroy (mode);
- return Success;
-}
-
-Bool
-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;
- }
- if (numCrtcs)
- {
- newCrtcs = malloc(numCrtcs * sizeof (RRCrtcPtr));
- if (!newCrtcs)
- return FALSE;
- }
- else
- newCrtcs = NULL;
- free(output->crtcs);
- memcpy (newCrtcs, crtcs, numCrtcs * sizeof (RRCrtcPtr));
- output->crtcs = newCrtcs;
- output->numCrtcs = numCrtcs;
- RROutputChanged (output, TRUE);
- return TRUE;
-}
-
-Bool
-RROutputSetConnection (RROutputPtr output,
- CARD8 connection)
-{
- if (output->connection == connection)
- return TRUE;
- output->connection = connection;
- RROutputChanged (output, TRUE);
- return TRUE;
-}
-
-Bool
-RROutputSetSubpixelOrder (RROutputPtr output,
- int subpixelOrder)
-{
- if (output->subpixelOrder == subpixelOrder)
- return TRUE;
-
- output->subpixelOrder = subpixelOrder;
- RROutputChanged (output, FALSE);
- return TRUE;
-}
-
-Bool
-RROutputSetPhysicalSize (RROutputPtr output,
- int mmWidth,
- int mmHeight)
-{
- if (output->mmWidth == mmWidth && output->mmHeight == mmHeight)
- return TRUE;
- output->mmWidth = mmWidth;
- output->mmHeight = mmHeight;
- 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;
-
- 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;
- }
- 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);
-}
-
-/*
- * Destroy a Output at shutdown
- */
-void
-RROutputDestroy (RROutputPtr output)
-{
- FreeResource (output->id, 0);
-}
-
-static int
-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;
- }
- }
- }
- 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]);
- free(output->userModes);
-
- free(output->crtcs);
- free(output->clones);
- RRDeleteAllOutputProperties (output);
- free(output);
- return 1;
-}
-
-/*
- * Initialize output type
- */
-Bool
-RROutputInit (void)
-{
- RROutputType = CreateNewResourceType (RROutputDestroyResource, "OUTPUT");
- if (!RROutputType)
- return FALSE;
-
- return TRUE;
-}
-
-/*
- * Initialize output type error value
- */
-void
-RROutputInitErrorValue(void)
-{
- SetResourceTypeErrorValue(RROutputType, RRErrorBase + BadRROutput);
-}
-
-#define OutputInfoExtra (SIZEOF(xRRGetOutputInfoReply) - 32)
-
-int
-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;
-
- REQUEST_SIZE_MATCH(xRRGetOutputInfoReq);
- VERIFY_RR_OUTPUT(stuff->output, output, DixReadAccess);
-
- pScreen = output->pScreen;
- pScrPriv = rrGetScrPriv(pScreen);
-
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.length = bytes_to_int32(OutputInfoExtra);
- 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;
-
- 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;
- }
- else
- 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->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);
- }
- 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);
- }
- 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)
-{
- 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 rc;
-
- REQUEST_SIZE_MATCH(xRRSetOutputPrimaryReq);
-
- rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
- if (rc != Success)
- return rc;
-
- if (stuff->output) {
- VERIFY_RR_OUTPUT(stuff->output, output, DixReadAccess);
-
- if (output->pScreen != pWin->drawable.pScreen) {
- client->errorValue = stuff->window;
- return BadMatch;
- }
- }
-
- pScrPriv = rrGetScrPriv(pWin->drawable.pScreen);
- RRSetPrimaryOutput(pWin->drawable.pScreen, pScrPriv, output);
-
- return Success;
-}
-
-int
-ProcRRGetOutputPrimary(ClientPtr client)
-{
- REQUEST(xRRGetOutputPrimaryReq);
- WindowPtr pWin;
- rrScrPrivPtr pScrPriv;
- xRRGetOutputPrimaryReply rep;
- RROutputPtr primary = NULL;
- int rc;
-
- REQUEST_SIZE_MATCH(xRRGetOutputPrimaryReq);
-
- rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
- if (rc != Success)
- return rc;
-
- pScrPriv = rrGetScrPriv(pWin->drawable.pScreen);
- if (pScrPriv)
- primary = pScrPriv->primaryOutput;
-
- memset(&rep, 0, sizeof(rep));
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.output = primary ? primary->id : None;
-
- if (client->swapped) {
- int n;
- swaps(&rep.sequenceNumber, n);
- swapl(&rep.output, n);
- }
-
- WriteToClient(client, sizeof(xRRGetOutputPrimaryReply), &rep);
-
- return Success;
-}
+/* + * 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 + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include "randrstr.h" + +RESTYPE RROutputType; + +/* + * Notify the output of some change + */ +void +RROutputChanged (RROutputPtr output, Bool configChanged) +{ + ScreenPtr pScreen = output->pScreen; + + output->changed = TRUE; + if (pScreen) + { + rrScrPriv (pScreen); + pScrPriv->changed = TRUE; + if (configChanged) + pScrPriv->configChanged = TRUE; + } +} + +/* + * Create an output + */ + +RROutputPtr +RROutputCreate (ScreenPtr pScreen, + const char *name, + int nameLength, + void *devPrivate) +{ + RROutputPtr output; + RROutputPtr *outputs; + rrScrPrivPtr pScrPriv; + + if (!RRInit()) + return NULL; + + pScrPriv = rrGetScrPriv(pScreen); + + if (pScrPriv->numOutputs) + outputs = realloc(pScrPriv->outputs, + (pScrPriv->numOutputs + 1) * sizeof (RROutputPtr)); + else + outputs = malloc(sizeof (RROutputPtr)); + if (!outputs) + return FALSE; + + pScrPriv->outputs = outputs; + + output = malloc(sizeof (RROutputRec) + nameLength + 1); + if (!output) + return NULL; + output->id = FakeClientID (0); + output->pScreen = pScreen; + output->name = (char *) (output + 1); + output->nameLength = nameLength; + memcpy (output->name, name, nameLength); + output->name[nameLength] = '\0'; + output->connection = RR_UnknownConnection; + output->subpixelOrder = SubPixelUnknown; + output->mmWidth = 0; + output->mmHeight = 0; + output->crtc = NULL; + output->numCrtcs = 0; + output->crtcs = NULL; + output->numClones = 0; + output->clones = NULL; + output->numModes = 0; + output->numPreferred = 0; + output->modes = NULL; + output->numUserModes = 0; + output->userModes = NULL; + output->properties = NULL; + output->pendingProperties = FALSE; + output->changed = FALSE; + output->devPrivate = devPrivate; + + if (!AddResource (output->id, RROutputType, (pointer) output)) + return NULL; + + pScrPriv->outputs[pScrPriv->numOutputs++] = output; + return output; +} + +/* + * Notify extension that output parameters have been changed + */ +Bool +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; + } + if (numClones) + { + newClones = malloc(numClones * sizeof (RROutputPtr)); + if (!newClones) + return FALSE; + } + else + newClones = NULL; + free(output->clones); + memcpy (newClones, clones, numClones * sizeof (RROutputPtr)); + output->clones = newClones; + output->numClones = numClones; + RROutputChanged (output, TRUE); + return TRUE; +} + +Bool +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; + } + } + + 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); + } + memcpy (newModes, modes, numModes * sizeof (RRModePtr)); + output->modes = newModes; + output->numModes = numModes; + output->numPreferred = numPreferred; + RROutputChanged (output, TRUE); + return TRUE; +} + +int +RROutputAddUserMode (RROutputPtr output, + RRModePtr mode) +{ + int m; + ScreenPtr pScreen = output->pScreen; + rrScrPriv(pScreen); + 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; + } + + /* Check with the DDX to see if this mode is OK */ + if (pScrPriv->rrOutputValidateMode) + if (!pScrPriv->rrOutputValidateMode (pScreen, output, mode)) + return BadMatch; + + if (output->userModes) + newModes = realloc(output->userModes, + (output->numUserModes + 1) * sizeof (RRModePtr)); + else + newModes = malloc(sizeof (RRModePtr)); + if (!newModes) + return BadAlloc; + + output->userModes = newModes; + output->userModes[output->numUserModes++] = mode; + ++mode->refcnt; + RROutputChanged (output, TRUE); + RRTellChanged (pScreen); + return Success; +} + +int +RROutputDeleteUserMode (RROutputPtr output, + RRModePtr mode) +{ + int m; + + /* Find this mode in the user mode list */ + for (m = 0; m < output->numUserModes; m++) + { + RRModePtr e = output->userModes[m]; + + if (mode == e) + break; + } + /* Not there, access error */ + if (m == output->numUserModes) + return BadAccess; + + /* make sure the mode isn't active for this output */ + if (output->crtc && output->crtc->mode == mode) + return BadMatch; + + memmove (output->userModes + m, output->userModes + m + 1, + (output->numUserModes - m - 1) * sizeof (RRModePtr)); + output->numUserModes--; + RRModeDestroy (mode); + return Success; +} + +Bool +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; + } + if (numCrtcs) + { + newCrtcs = malloc(numCrtcs * sizeof (RRCrtcPtr)); + if (!newCrtcs) + return FALSE; + } + else + newCrtcs = NULL; + free(output->crtcs); + memcpy (newCrtcs, crtcs, numCrtcs * sizeof (RRCrtcPtr)); + output->crtcs = newCrtcs; + output->numCrtcs = numCrtcs; + RROutputChanged (output, TRUE); + return TRUE; +} + +Bool +RROutputSetConnection (RROutputPtr output, + CARD8 connection) +{ + if (output->connection == connection) + return TRUE; + output->connection = connection; + RROutputChanged (output, TRUE); + return TRUE; +} + +Bool +RROutputSetSubpixelOrder (RROutputPtr output, + int subpixelOrder) +{ + if (output->subpixelOrder == subpixelOrder) + return TRUE; + + output->subpixelOrder = subpixelOrder; + RROutputChanged (output, FALSE); + return TRUE; +} + +Bool +RROutputSetPhysicalSize (RROutputPtr output, + int mmWidth, + int mmHeight) +{ + if (output->mmWidth == mmWidth && output->mmHeight == mmHeight) + return TRUE; + output->mmWidth = mmWidth; + output->mmHeight = mmHeight; + 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; + + 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; + } + 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); +} + +/* + * Destroy a Output at shutdown + */ +void +RROutputDestroy (RROutputPtr output) +{ + FreeResource (output->id, 0); +} + +static int +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; + } + } + } + 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]); + free(output->userModes); + + free(output->crtcs); + free(output->clones); + RRDeleteAllOutputProperties (output); + free(output); + return 1; +} + +/* + * Initialize output type + */ +Bool +RROutputInit (void) +{ + RROutputType = CreateNewResourceType (RROutputDestroyResource, "OUTPUT"); + if (!RROutputType) + return FALSE; + + return TRUE; +} + +/* + * Initialize output type error value + */ +void +RROutputInitErrorValue(void) +{ + SetResourceTypeErrorValue(RROutputType, RRErrorBase + BadRROutput); +} + +#define OutputInfoExtra (SIZEOF(xRRGetOutputInfoReply) - 32) + +int +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; + + REQUEST_SIZE_MATCH(xRRGetOutputInfoReq); + VERIFY_RR_OUTPUT(stuff->output, output, DixReadAccess); + + pScreen = output->pScreen; + pScrPriv = rrGetScrPriv(pScreen); + + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.length = bytes_to_int32(OutputInfoExtra); + 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; + + 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; + } + else + 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->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]); + } + 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); + } + 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) +{ + 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 rc; + + REQUEST_SIZE_MATCH(xRRSetOutputPrimaryReq); + + rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); + if (rc != Success) + return rc; + + if (stuff->output) { + VERIFY_RR_OUTPUT(stuff->output, output, DixReadAccess); + + if (output->pScreen != pWin->drawable.pScreen) { + client->errorValue = stuff->window; + return BadMatch; + } + } + + pScrPriv = rrGetScrPriv(pWin->drawable.pScreen); + RRSetPrimaryOutput(pWin->drawable.pScreen, pScrPriv, output); + + return Success; +} + +int +ProcRRGetOutputPrimary(ClientPtr client) +{ + REQUEST(xRRGetOutputPrimaryReq); + WindowPtr pWin; + rrScrPrivPtr pScrPriv; + xRRGetOutputPrimaryReply rep; + RROutputPtr primary = NULL; + int rc; + + REQUEST_SIZE_MATCH(xRRGetOutputPrimaryReq); + + rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); + if (rc != Success) + return rc; + + pScrPriv = rrGetScrPriv(pWin->drawable.pScreen); + if (pScrPriv) + primary = pScrPriv->primaryOutput; + + memset(&rep, 0, sizeof(rep)); + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.output = primary ? primary->id : None; + + if (client->swapped) { + swaps(&rep.sequenceNumber); + swapl(&rep.output); + } + + WriteToClient(client, sizeof(xRRGetOutputPrimaryReply), &rep); + + return Success; +} diff --git a/xorg-server/randr/rrproperty.c b/xorg-server/randr/rrproperty.c index 61e7bb45a..6ed24d3aa 100644 --- a/xorg-server/randr/rrproperty.c +++ b/xorg-server/randr/rrproperty.c @@ -409,10 +409,9 @@ ProcRRListOutputProperties (ClientPtr client) rep.nAtoms = numProps; if (client->swapped) { - int n; - swaps (&rep.sequenceNumber, n); - swapl (&rep.length, n); - swaps (&rep.nAtoms, n); + swaps(&rep.sequenceNumber); + swapl(&rep.length); + swaps(&rep.nAtoms); } temppAtoms = pAtoms; for (prop = output->properties; prop; prop = prop->next) @@ -458,9 +457,8 @@ ProcRRQueryOutputProperty (ClientPtr client) rep.immutable = prop->immutable; if (client->swapped) { - int n; - swaps (&rep.sequenceNumber, n); - swapl (&rep.length, n); + swaps(&rep.sequenceNumber); + swapl(&rep.length); } WriteToClient (client, sizeof (xRRQueryOutputPropertyReply), (char*)&rep); if (prop->num_valid) @@ -615,13 +613,11 @@ ProcRRGetOutputProperty (ClientPtr client) reply.propertyType = None; reply.format = 0; 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); + swaps(&reply.sequenceNumber); + swapl(&reply.length); + swapl(&reply.propertyType); + swapl(&reply.bytesAfter); + swapl(&reply.nItems); } WriteToClient(client, sizeof(xRRGetOutputPropertyReply), &reply); return Success; @@ -647,13 +643,11 @@ ProcRRGetOutputProperty (ClientPtr client) reply.nItems = 0; reply.propertyType = prop_value->type; 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); + swaps(&reply.sequenceNumber); + swapl(&reply.length); + swapl(&reply.propertyType); + swapl(&reply.bytesAfter); + swapl(&reply.nItems); } WriteToClient(client, sizeof(xRRGetOutputPropertyReply), &reply); return Success; @@ -704,13 +698,11 @@ ProcRRGetOutputProperty (ClientPtr client) } 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); + swaps(&reply.sequenceNumber); + swapl(&reply.length); + swapl(&reply.propertyType); + swapl(&reply.bytesAfter); + swapl(&reply.nItems); } WriteToClient(client, sizeof(xGenericReply), &reply); if (len) diff --git a/xorg-server/randr/rrscreen.c b/xorg-server/randr/rrscreen.c index da6d48d6e..ab4675734 100644 --- a/xorg-server/randr/rrscreen.c +++ b/xorg-server/randr/rrscreen.c @@ -232,14 +232,12 @@ ProcRRGetScreenSizeRange (ClientPtr client) } if (client->swapped) { - int n; - - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, n); - swaps(&rep.minWidth, n); - swaps(&rep.minHeight, n); - swaps(&rep.maxWidth, n); - swaps(&rep.maxHeight, n); + swaps(&rep.sequenceNumber); + swapl(&rep.length); + swaps(&rep.minWidth); + swaps(&rep.minHeight); + swaps(&rep.maxWidth); + swaps(&rep.maxHeight); } WriteToClient(client, sizeof(xRRGetScreenSizeRangeReply), (char *)&rep); return Success; @@ -318,7 +316,7 @@ rrGetScreenResources(ClientPtr client, Bool query) rrScrPrivPtr pScrPriv; CARD8 *extra; unsigned long extraLen; - int i, n, rc, has_primary = 0; + int i, rc, has_primary = 0; RRCrtc *crtcs; RROutput *outputs; xRRModeInfo *modeinfos; @@ -401,7 +399,7 @@ rrGetScreenResources(ClientPtr client, Bool query) has_primary = 1; crtcs[0] = pScrPriv->primaryOutput->crtc->id; if (client->swapped) - swapl (&crtcs[0], n); + swapl(&crtcs[0]); } for (i = 0; i < pScrPriv->numCrtcs; i++) @@ -414,14 +412,14 @@ rrGetScreenResources(ClientPtr client, Bool query) } crtcs[i + has_primary] = pScrPriv->crtcs[i]->id; if (client->swapped) - swapl (&crtcs[i + has_primary], n); + swapl(&crtcs[i + has_primary]); } for (i = 0; i < pScrPriv->numOutputs; i++) { outputs[i] = pScrPriv->outputs[i]->id; if (client->swapped) - swapl (&outputs[i], n); + swapl(&outputs[i]); } for (i = 0; i < num_modes; i++) @@ -430,19 +428,19 @@ rrGetScreenResources(ClientPtr client, Bool query) modeinfos[i] = mode->mode; if (client->swapped) { - swapl (&modeinfos[i].id, n); - swaps (&modeinfos[i].width, n); - swaps (&modeinfos[i].height, n); - swapl (&modeinfos[i].dotClock, n); - swaps (&modeinfos[i].hSyncStart, n); - swaps (&modeinfos[i].hSyncEnd, n); - swaps (&modeinfos[i].hTotal, n); - swaps (&modeinfos[i].hSkew, n); - swaps (&modeinfos[i].vSyncStart, n); - swaps (&modeinfos[i].vSyncEnd, n); - swaps (&modeinfos[i].vTotal, n); - swaps (&modeinfos[i].nameLength, n); - swapl (&modeinfos[i].modeFlags, n); + swapl(&modeinfos[i].id); + swaps(&modeinfos[i].width); + swaps(&modeinfos[i].height); + swapl(&modeinfos[i].dotClock); + swaps(&modeinfos[i].hSyncStart); + swaps(&modeinfos[i].hSyncEnd); + swaps(&modeinfos[i].hTotal); + swaps(&modeinfos[i].hSkew); + swaps(&modeinfos[i].vSyncStart); + swaps(&modeinfos[i].vSyncEnd); + swaps(&modeinfos[i].vTotal); + swaps(&modeinfos[i].nameLength); + swapl(&modeinfos[i].modeFlags); } memcpy (names, mode->name, mode->mode.nameLength); @@ -453,14 +451,14 @@ rrGetScreenResources(ClientPtr client, Bool query) } if (client->swapped) { - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, n); - swapl(&rep.timestamp, n); - swapl(&rep.configTimestamp, n); - swaps(&rep.nCrtcs, n); - swaps(&rep.nOutputs, n); - swaps(&rep.nModes, n); - swaps(&rep.nbytesNames, n); + swaps(&rep.sequenceNumber); + swapl(&rep.length); + swapl(&rep.timestamp); + swapl(&rep.configTimestamp); + swaps(&rep.nCrtcs); + swaps(&rep.nOutputs); + swaps(&rep.nModes); + swaps(&rep.nbytesNames); } WriteToClient(client, sizeof(xRRGetScreenResourcesReply), (char *)&rep); if (extraLen) @@ -592,7 +590,7 @@ ProcRRGetScreenInfo (ClientPtr client) REQUEST(xRRGetScreenInfoReq); xRRGetScreenInfoReply rep; WindowPtr pWin; - int n, rc; + int rc; ScreenPtr pScreen; rrScrPrivPtr pScrPriv; CARD8 *extra; @@ -688,10 +686,10 @@ ProcRRGetScreenInfo (ClientPtr client) size->heightInMillimeters = pSize->mmHeight; if (client->swapped) { - swaps (&size->widthInPixels, n); - swaps (&size->heightInPixels, n); - swaps (&size->widthInMillimeters, n); - swaps (&size->heightInMillimeters, n); + swaps(&size->widthInPixels); + swaps(&size->heightInPixels); + swaps(&size->widthInMillimeters); + swaps(&size->heightInMillimeters); } size++; if (has_rate) @@ -699,7 +697,7 @@ ProcRRGetScreenInfo (ClientPtr client) *rates = pSize->nRates; if (client->swapped) { - swaps (rates, n); + swaps(rates); } rates++; for (j = 0; j < pSize->nRates; j++) @@ -707,7 +705,7 @@ ProcRRGetScreenInfo (ClientPtr client) *rates = pSize->pRates[j].rate; if (client->swapped) { - swaps (rates, n); + swaps(rates); } rates++; } @@ -723,14 +721,14 @@ ProcRRGetScreenInfo (ClientPtr client) rep.length = bytes_to_int32(extraLen); } if (client->swapped) { - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, n); - swapl(&rep.timestamp, n); - swaps(&rep.rotation, n); - swaps(&rep.nSizes, n); - swaps(&rep.sizeID, n); - swaps(&rep.rate, n); - swaps(&rep.nrateEnts, n); + swaps(&rep.sequenceNumber); + swapl(&rep.length); + swapl(&rep.timestamp); + swaps(&rep.rotation); + swaps(&rep.nSizes); + swaps(&rep.sizeID); + swaps(&rep.rate); + swaps(&rep.nrateEnts); } WriteToClient(client, sizeof(xRRGetScreenInfoReply), (char *)&rep); if (extraLen) @@ -747,7 +745,7 @@ ProcRRSetScreenConfig (ClientPtr client) REQUEST(xRRSetScreenConfigReq); xRRSetScreenConfigReply rep; DrawablePtr pDraw; - int n, rc; + int rc; ScreenPtr pScreen; rrScrPrivPtr pScrPriv; TimeStamp time; @@ -976,11 +974,11 @@ sendReply: if (client->swapped) { - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, n); - swapl(&rep.newTimestamp, n); - swapl(&rep.newConfigTimestamp, n); - swapl(&rep.root, n); + swaps(&rep.sequenceNumber); + swapl(&rep.length); + swapl(&rep.newTimestamp); + swapl(&rep.newConfigTimestamp); + swapl(&rep.root); } WriteToClient(client, sizeof(xRRSetScreenConfigReply), (char *)&rep); diff --git a/xorg-server/randr/rrsdispatch.c b/xorg-server/randr/rrsdispatch.c index e16090a41..543fc9022 100644 --- a/xorg-server/randr/rrsdispatch.c +++ b/xorg-server/randr/rrsdispatch.c @@ -25,149 +25,138 @@ static int SProcRRQueryVersion (ClientPtr client) { - register int n; REQUEST(xRRQueryVersionReq); - swaps(&stuff->length, n); - swapl(&stuff->majorVersion, n); - swapl(&stuff->minorVersion, n); + swaps(&stuff->length); + swapl(&stuff->majorVersion); + swapl(&stuff->minorVersion); return (*ProcRandrVector[stuff->randrReqType]) (client); } static int SProcRRGetScreenInfo (ClientPtr client) { - register int n; REQUEST(xRRGetScreenInfoReq); - swaps(&stuff->length, n); - swapl(&stuff->window, n); + swaps(&stuff->length); + swapl(&stuff->window); return (*ProcRandrVector[stuff->randrReqType]) (client); } static int SProcRRSetScreenConfig (ClientPtr client) { - register int n; REQUEST(xRRSetScreenConfigReq); if (RRClientKnowsRates (client)) { REQUEST_SIZE_MATCH (xRRSetScreenConfigReq); - swaps (&stuff->rate, n); + swaps(&stuff->rate); } else { REQUEST_SIZE_MATCH (xRR1_0SetScreenConfigReq); } - swaps(&stuff->length, n); - swapl(&stuff->drawable, n); - swapl(&stuff->timestamp, n); - swaps(&stuff->sizeID, n); - swaps(&stuff->rotation, n); + swaps(&stuff->length); + swapl(&stuff->drawable); + swapl(&stuff->timestamp); + swaps(&stuff->sizeID); + swaps(&stuff->rotation); return (*ProcRandrVector[stuff->randrReqType]) (client); } static int SProcRRSelectInput (ClientPtr client) { - register int n; REQUEST(xRRSelectInputReq); - swaps(&stuff->length, n); - swapl(&stuff->window, n); - swaps(&stuff->enable, n); + swaps(&stuff->length); + swapl(&stuff->window); + swaps(&stuff->enable); return (*ProcRandrVector[stuff->randrReqType]) (client); } static int SProcRRGetScreenSizeRange (ClientPtr client) { - int n; REQUEST(xRRGetScreenSizeRangeReq); REQUEST_SIZE_MATCH(xRRGetScreenSizeRangeReq); - swaps(&stuff->length, n); - swapl(&stuff->window, n); + swaps(&stuff->length); + swapl(&stuff->window); return (*ProcRandrVector[stuff->randrReqType]) (client); } static int SProcRRSetScreenSize (ClientPtr client) { - int n; REQUEST(xRRSetScreenSizeReq); REQUEST_SIZE_MATCH(xRRSetScreenSizeReq); - swaps(&stuff->length, n); - swapl(&stuff->window, n); - swaps(&stuff->width, n); - swaps(&stuff->height, n); - swapl(&stuff->widthInMillimeters, n); - swapl(&stuff->heightInMillimeters, n); + swaps(&stuff->length); + swapl(&stuff->window); + swaps(&stuff->width); + swaps(&stuff->height); + swapl(&stuff->widthInMillimeters); + swapl(&stuff->heightInMillimeters); return (*ProcRandrVector[stuff->randrReqType]) (client); } static int SProcRRGetScreenResources (ClientPtr client) { - int n; REQUEST(xRRGetScreenResourcesReq); REQUEST_SIZE_MATCH(xRRGetScreenResourcesReq); - swaps(&stuff->length, n); - swapl(&stuff->window, n); + swaps(&stuff->length); + swapl(&stuff->window); return (*ProcRandrVector[stuff->randrReqType]) (client); } static int SProcRRGetOutputInfo (ClientPtr client) { - int n; REQUEST(xRRGetOutputInfoReq); REQUEST_SIZE_MATCH(xRRGetOutputInfoReq); - swaps(&stuff->length, n); - swapl(&stuff->output, n); - swapl(&stuff->configTimestamp, n); + swaps(&stuff->length); + swapl(&stuff->output); + swapl(&stuff->configTimestamp); return (*ProcRandrVector[stuff->randrReqType]) (client); } static int SProcRRListOutputProperties (ClientPtr client) { - int n; REQUEST(xRRListOutputPropertiesReq); REQUEST_SIZE_MATCH(xRRListOutputPropertiesReq); - swaps(&stuff->length, n); - swapl(&stuff->output, n); + swaps(&stuff->length); + swapl(&stuff->output); return (*ProcRandrVector[stuff->randrReqType]) (client); } static int SProcRRQueryOutputProperty (ClientPtr client) { - int n; REQUEST(xRRQueryOutputPropertyReq); REQUEST_SIZE_MATCH(xRRQueryOutputPropertyReq); - swaps(&stuff->length, n); - swapl(&stuff->output, n); - swapl(&stuff->property, n); + swaps(&stuff->length); + swapl(&stuff->output); + swapl(&stuff->property); return (*ProcRandrVector[stuff->randrReqType]) (client); } static int SProcRRConfigureOutputProperty (ClientPtr client) { - int n; REQUEST(xRRConfigureOutputPropertyReq); - swaps(&stuff->length, n); - swapl(&stuff->output, n); - swapl(&stuff->property, n); + swaps(&stuff->length); + swapl(&stuff->output); + swapl(&stuff->property); SwapRestL(stuff); return (*ProcRandrVector[stuff->randrReqType]) (client); } @@ -175,15 +164,14 @@ SProcRRConfigureOutputProperty (ClientPtr client) static int SProcRRChangeOutputProperty (ClientPtr client) { - int n; REQUEST(xRRChangeOutputPropertyReq); REQUEST_AT_LEAST_SIZE (xRRChangeOutputPropertyReq); - swaps(&stuff->length, n); - swapl(&stuff->output, n); - swapl(&stuff->property, n); - swapl(&stuff->type, n); - swapl(&stuff->nUnits, n); + swaps(&stuff->length); + swapl(&stuff->output); + swapl(&stuff->property); + swapl(&stuff->type); + swapl(&stuff->nUnits); switch(stuff->format) { case 8: break; @@ -203,125 +191,117 @@ SProcRRChangeOutputProperty (ClientPtr client) static int SProcRRDeleteOutputProperty (ClientPtr client) { - int n; REQUEST(xRRDeleteOutputPropertyReq); REQUEST_SIZE_MATCH(xRRDeleteOutputPropertyReq); - swaps(&stuff->length, n); - swapl(&stuff->output, n); - swapl(&stuff->property, n); + swaps(&stuff->length); + swapl(&stuff->output); + swapl(&stuff->property); return (*ProcRandrVector[stuff->randrReqType]) (client); } static int SProcRRGetOutputProperty (ClientPtr client) { - int n; REQUEST(xRRGetOutputPropertyReq); REQUEST_SIZE_MATCH(xRRGetOutputPropertyReq); - swaps(&stuff->length, n); - swapl(&stuff->output, n); - swapl(&stuff->property, n); - swapl(&stuff->type, n); - swapl(&stuff->longOffset, n); - swapl(&stuff->longLength, n); + swaps(&stuff->length); + swapl(&stuff->output); + swapl(&stuff->property); + swapl(&stuff->type); + swapl(&stuff->longOffset); + swapl(&stuff->longLength); return (*ProcRandrVector[stuff->randrReqType]) (client); } static int SProcRRCreateMode (ClientPtr client) { - int n; xRRModeInfo *modeinfo; REQUEST(xRRCreateModeReq); REQUEST_AT_LEAST_SIZE(xRRCreateModeReq); - swaps(&stuff->length, n); - swapl(&stuff->window, n); + swaps(&stuff->length); + swapl(&stuff->window); 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); + swapl(&modeinfo->id); + swaps(&modeinfo->width); + swaps(&modeinfo->height); + swapl(&modeinfo->dotClock); + swaps(&modeinfo->hSyncStart); + swaps(&modeinfo->hSyncEnd); + swaps(&modeinfo->hTotal); + swaps(&modeinfo->vSyncStart); + swaps(&modeinfo->vSyncEnd); + swaps(&modeinfo->vTotal); + swaps(&modeinfo->nameLength); + swapl(&modeinfo->modeFlags); return (*ProcRandrVector[stuff->randrReqType]) (client); } static int SProcRRDestroyMode (ClientPtr client) { - int n; REQUEST(xRRDestroyModeReq); REQUEST_SIZE_MATCH(xRRDestroyModeReq); - swaps(&stuff->length, n); - swapl(&stuff->mode, n); + swaps(&stuff->length); + swapl(&stuff->mode); return (*ProcRandrVector[stuff->randrReqType]) (client); } static int SProcRRAddOutputMode (ClientPtr client) { - int n; REQUEST(xRRAddOutputModeReq); REQUEST_SIZE_MATCH(xRRAddOutputModeReq); - swaps(&stuff->length, n); - swapl(&stuff->output, n); - swapl(&stuff->mode, n); + swaps(&stuff->length); + swapl(&stuff->output); + swapl(&stuff->mode); return (*ProcRandrVector[stuff->randrReqType]) (client); } static int SProcRRDeleteOutputMode (ClientPtr client) { - int n; REQUEST(xRRDeleteOutputModeReq); REQUEST_SIZE_MATCH(xRRDeleteOutputModeReq); - swaps(&stuff->length, n); - swapl(&stuff->output, n); - swapl(&stuff->mode, n); + swaps(&stuff->length); + swapl(&stuff->output); + swapl(&stuff->mode); return (*ProcRandrVector[stuff->randrReqType]) (client); } static int SProcRRGetCrtcInfo (ClientPtr client) { - int n; REQUEST(xRRGetCrtcInfoReq); REQUEST_SIZE_MATCH(xRRGetCrtcInfoReq); - swaps(&stuff->length, n); - swapl(&stuff->crtc, n); - swapl(&stuff->configTimestamp, n); + swaps(&stuff->length); + swapl(&stuff->crtc); + swapl(&stuff->configTimestamp); return (*ProcRandrVector[stuff->randrReqType]) (client); } static int SProcRRSetCrtcConfig (ClientPtr client) { - int n; REQUEST(xRRSetCrtcConfigReq); REQUEST_AT_LEAST_SIZE(xRRSetCrtcConfigReq); - swaps(&stuff->length, n); - 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); + swaps(&stuff->length); + swapl(&stuff->crtc); + swapl(&stuff->timestamp); + swapl(&stuff->configTimestamp); + swaps(&stuff->x); + swaps(&stuff->y); + swapl(&stuff->mode); + swaps(&stuff->rotation); SwapRestL(stuff); return (*ProcRandrVector[stuff->randrReqType]) (client); } @@ -329,37 +309,34 @@ SProcRRSetCrtcConfig (ClientPtr client) static int SProcRRGetCrtcGammaSize (ClientPtr client) { - int n; REQUEST(xRRGetCrtcGammaSizeReq); REQUEST_SIZE_MATCH(xRRGetCrtcGammaSizeReq); - swaps(&stuff->length, n); - swapl(&stuff->crtc, n); + swaps(&stuff->length); + swapl(&stuff->crtc); return (*ProcRandrVector[stuff->randrReqType]) (client); } static int SProcRRGetCrtcGamma (ClientPtr client) { - int n; REQUEST(xRRGetCrtcGammaReq); REQUEST_SIZE_MATCH(xRRGetCrtcGammaReq); - swaps(&stuff->length, n); - swapl(&stuff->crtc, n); + swaps(&stuff->length); + swapl(&stuff->crtc); return (*ProcRandrVector[stuff->randrReqType]) (client); } static int SProcRRSetCrtcGamma (ClientPtr client) { - int n; REQUEST(xRRSetCrtcGammaReq); REQUEST_AT_LEAST_SIZE(xRRSetCrtcGammaReq); - swaps(&stuff->length, n); - swapl(&stuff->crtc, n); - swaps(&stuff->size, n); + swaps(&stuff->length); + swapl(&stuff->crtc); + swaps(&stuff->size); SwapRestS(stuff); return (*ProcRandrVector[stuff->randrReqType]) (client); } @@ -367,16 +344,16 @@ SProcRRSetCrtcGamma (ClientPtr client) static int SProcRRSetCrtcTransform (ClientPtr client) { - int n, nparams; + int nparams; char *filter; CARD32 *params; REQUEST(xRRSetCrtcTransformReq); REQUEST_AT_LEAST_SIZE(xRRSetCrtcTransformReq); - swaps(&stuff->length, n); - swapl(&stuff->crtc, n); + swaps(&stuff->length); + swapl(&stuff->crtc); SwapLongs((CARD32 *)&stuff->transform, bytes_to_int32(sizeof(xRenderTransform))); - swaps(&stuff->nbytesFilter, n); + swaps(&stuff->nbytesFilter); filter = (char *)(stuff + 1); params = (CARD32 *) (filter + pad_to_int32(stuff->nbytesFilter)); nparams = ((CARD32 *) stuff + client->req_len) - params; @@ -390,74 +367,69 @@ SProcRRSetCrtcTransform (ClientPtr client) static int SProcRRGetCrtcTransform (ClientPtr client) { - int n; REQUEST(xRRGetCrtcTransformReq); REQUEST_SIZE_MATCH(xRRGetCrtcTransformReq); - swaps(&stuff->length, n); - swapl(&stuff->crtc, n); + swaps(&stuff->length); + swapl(&stuff->crtc); return (*ProcRandrVector[stuff->randrReqType]) (client); } static int SProcRRGetPanning (ClientPtr client) { - int n; REQUEST(xRRGetPanningReq); REQUEST_SIZE_MATCH(xRRGetPanningReq); - swaps(&stuff->length, n); - swapl(&stuff->crtc, n); + swaps(&stuff->length); + swapl(&stuff->crtc); return (*ProcRandrVector[stuff->randrReqType]) (client); } static int SProcRRSetPanning (ClientPtr client) { - int n; REQUEST(xRRSetPanningReq); REQUEST_SIZE_MATCH(xRRSetPanningReq); - swaps(&stuff->length, n); - swapl(&stuff->crtc, n); - swapl(&stuff->timestamp, n); - swaps(&stuff->left, n); - swaps(&stuff->top, n); - swaps(&stuff->width, n); - swaps(&stuff->height, n); - swaps(&stuff->track_left, n); - swaps(&stuff->track_top, n); - swaps(&stuff->track_width, n); - swaps(&stuff->track_height, n); - swaps(&stuff->border_left, n); - swaps(&stuff->border_top, n); - swaps(&stuff->border_right, n); - swaps(&stuff->border_bottom, n); + swaps(&stuff->length); + swapl(&stuff->crtc); + swapl(&stuff->timestamp); + swaps(&stuff->left); + swaps(&stuff->top); + swaps(&stuff->width); + swaps(&stuff->height); + swaps(&stuff->track_left); + swaps(&stuff->track_top); + swaps(&stuff->track_width); + swaps(&stuff->track_height); + swaps(&stuff->border_left); + swaps(&stuff->border_top); + swaps(&stuff->border_right); + swaps(&stuff->border_bottom); return (*ProcRandrVector[stuff->randrReqType]) (client); } static int SProcRRSetOutputPrimary (ClientPtr client) { - int n; REQUEST(xRRSetOutputPrimaryReq); REQUEST_SIZE_MATCH(xRRSetOutputPrimaryReq); - swaps(&stuff->length, n); - swapl(&stuff->window, n); - swapl(&stuff->output, n); + swaps(&stuff->length); + swapl(&stuff->window); + swapl(&stuff->output); return ProcRandrVector[stuff->randrReqType](client); } static int SProcRRGetOutputPrimary (ClientPtr client) { - int n; REQUEST(xRRGetOutputPrimaryReq); REQUEST_SIZE_MATCH(xRRGetOutputPrimaryReq); - swaps(&stuff->length, n); - swapl(&stuff->window, n); + swaps(&stuff->length); + swapl(&stuff->window); return ProcRandrVector[stuff->randrReqType](client); } diff --git a/xorg-server/randr/rrxinerama.c b/xorg-server/randr/rrxinerama.c index 1dee6ca22..6d4519043 100644 --- a/xorg-server/randr/rrxinerama.c +++ b/xorg-server/randr/rrxinerama.c @@ -1,476 +1,466 @@ -/*
- * Copyright © 2006 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that copyright
- * notice and this permission notice appear in supporting documentation, and
- * that the name of the copyright holders not be used in advertising or
- * publicity pertaining to distribution of the software without specific,
- * written prior permission. The copyright holders make no representations
- * about the suitability of this software for any purpose. It is provided "as
- * is" without express or implied warranty.
- *
- * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-/*
- * This Xinerama implementation comes from the SiS driver which has
- * the following notice:
- */
-/*
- * SiS driver main code
- *
- * Copyright (C) 2001-2005 by Thomas Winischhofer, Vienna, Austria.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1) Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2) Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3) The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * Author: Thomas Winischhofer <thomas@winischhofer.net>
- * - driver entirely rewritten since 2001, only basic structure taken from
- * old code (except sis_dri.c, sis_shadow.c, sis_accel.c and parts of
- * sis_dga.c; these were mostly taken over; sis_dri.c was changed for
- * new versions of the DRI layer)
- *
- * This notice covers the entire driver code unless indicated otherwise.
- *
- * Formerly based on code which was
- * Copyright (C) 1998, 1999 by Alan Hourihane, Wigan, England.
- * Written by:
- * Alan Hourihane <alanh@fairlite.demon.co.uk>,
- * Mike Chapman <mike@paranoia.com>,
- * Juanjo Santamarta <santamarta@ctv.es>,
- * Mitani Hiroshi <hmitani@drl.mei.co.jp>,
- * David Thomas <davtom@dream.org.uk>.
- */
-
-#include "randrstr.h"
-#include "swaprep.h"
-#include <X11/extensions/panoramiXproto.h>
-#include "protocol-versions.h"
-
-/* Xinerama is not multi-screen capable; just report about screen 0 */
-#define RR_XINERAMA_SCREEN 0
-
-static int ProcRRXineramaQueryVersion(ClientPtr client);
-static int ProcRRXineramaGetState(ClientPtr client);
-static int ProcRRXineramaGetScreenCount(ClientPtr client);
-static int ProcRRXineramaGetScreenSize(ClientPtr client);
-static int ProcRRXineramaIsActive(ClientPtr client);
-static int ProcRRXineramaQueryScreens(ClientPtr client);
-static int SProcRRXineramaDispatch(ClientPtr client);
-
-/* Proc */
-
-int
-ProcRRXineramaQueryVersion(ClientPtr client)
-{
- xPanoramiXQueryVersionReply rep;
- register int n;
-
- REQUEST_SIZE_MATCH(xPanoramiXQueryVersionReq);
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.majorVersion = SERVER_RRXINERAMA_MAJOR_VERSION;
- rep.minorVersion = SERVER_RRXINERAMA_MINOR_VERSION;
- if(client->swapped) {
- swaps(&rep.sequenceNumber, n);
- swapl(&rep.length, n);
- swaps(&rep.majorVersion, n);
- swaps(&rep.minorVersion, n);
- }
- WriteToClient(client, sizeof(xPanoramiXQueryVersionReply), (char *)&rep);
- return Success;
-}
-
-int
-ProcRRXineramaGetState(ClientPtr client)
-{
- REQUEST(xPanoramiXGetStateReq);
- WindowPtr pWin;
- xPanoramiXGetStateReply rep;
- register int n, rc;
- ScreenPtr pScreen;
- rrScrPrivPtr pScrPriv;
- Bool active = FALSE;
-
- REQUEST_SIZE_MATCH(xPanoramiXGetStateReq);
- rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
- if(rc != Success)
- return rc;
-
- pScreen = pWin->drawable.pScreen;
- pScrPriv = rrGetScrPriv(pScreen);
- if (pScrPriv)
- {
- /* XXX do we need more than this? */
- active = TRUE;
- }
-
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.state = active;
- rep.window = stuff->window;
- if(client->swapped) {
- swaps (&rep.sequenceNumber, n);
- swapl (&rep.length, n);
- swapl (&rep.window, n);
- }
- WriteToClient(client, sizeof(xPanoramiXGetStateReply), (char *)&rep);
- return Success;
-}
-
-static Bool
-RRXineramaCrtcActive (RRCrtcPtr crtc)
-{
- return crtc->mode != NULL && crtc->numOutputs > 0;
-}
-
-static int
-RRXineramaScreenCount (ScreenPtr pScreen)
-{
- int i, n;
-
- n = 0;
- if (rrGetScrPriv (pScreen))
- {
- rrScrPriv(pScreen);
- for (i = 0; i < pScrPriv->numCrtcs; i++)
- if (RRXineramaCrtcActive (pScrPriv->crtcs[i]))
- n++;
- }
- return n;
-}
-
-static Bool
-RRXineramaScreenActive (ScreenPtr pScreen)
-{
- return RRXineramaScreenCount (pScreen) > 0;
-}
-
-int
-ProcRRXineramaGetScreenCount(ClientPtr client)
-{
- REQUEST(xPanoramiXGetScreenCountReq);
- WindowPtr pWin;
- xPanoramiXGetScreenCountReply rep;
- register int n, rc;
-
- REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq);
- rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
- if (rc != Success)
- return rc;
-
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.ScreenCount = RRXineramaScreenCount (pWin->drawable.pScreen);
- rep.window = stuff->window;
- if(client->swapped) {
- swaps(&rep.sequenceNumber, n);
- swapl(&rep.length, n);
- swapl(&rep.window, n);
- }
- WriteToClient(client, sizeof(xPanoramiXGetScreenCountReply), (char *)&rep);
- return Success;
-}
-
-int
-ProcRRXineramaGetScreenSize(ClientPtr client)
-{
- REQUEST(xPanoramiXGetScreenSizeReq);
- WindowPtr pWin, pRoot;
- ScreenPtr pScreen;
- xPanoramiXGetScreenSizeReply rep;
- register int n, rc;
-
- REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
- rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
- if (rc != Success)
- return rc;
-
- pScreen = pWin->drawable.pScreen;
- pRoot = pScreen->root;
-
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.width = pRoot->drawable.width;
- rep.height = pRoot->drawable.height;
- rep.window = stuff->window;
- rep.screen = stuff->screen;
- if(client->swapped) {
- swaps(&rep.sequenceNumber, n);
- swapl(&rep.length, n);
- swapl(&rep.width, n);
- swapl(&rep.height, n);
- swapl(&rep.window, n);
- swapl(&rep.screen, n);
- }
- WriteToClient(client, sizeof(xPanoramiXGetScreenSizeReply), (char *)&rep);
- return Success;
-}
-
-int
-ProcRRXineramaIsActive(ClientPtr client)
-{
- xXineramaIsActiveReply rep;
-
- REQUEST_SIZE_MATCH(xXineramaIsActiveReq);
-
- memset(&rep, 0, sizeof(xXineramaIsActiveReply));
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.state = RRXineramaScreenActive (screenInfo.screens[RR_XINERAMA_SCREEN]);
- if(client->swapped) {
- register int n;
- swaps(&rep.sequenceNumber, n);
- swapl(&rep.length, n);
- swapl(&rep.state, n);
- }
- WriteToClient(client, sizeof(xXineramaIsActiveReply), (char *) &rep);
- return Success;
-}
-
-static void
-RRXineramaWriteCrtc(ClientPtr client, RRCrtcPtr crtc)
-{
- xXineramaScreenInfo scratch;
-
- if (RRXineramaCrtcActive (crtc))
- {
- ScreenPtr pScreen = crtc->pScreen;
- rrScrPrivPtr pScrPriv = rrGetScrPriv(pScreen);
- BoxRec panned_area;
-
- /* Check to see if crtc is panned and return the full area when applicable. */
- if (pScrPriv && pScrPriv->rrGetPanning &&
- pScrPriv->rrGetPanning (pScreen, crtc, &panned_area, NULL, NULL) &&
- (panned_area.x2 > panned_area.x1) && (panned_area.y2 > panned_area.y1)) {
- scratch.x_org = panned_area.x1;
- scratch.y_org = panned_area.y1;
- scratch.width = panned_area.x2 - panned_area.x1;
- scratch.height = panned_area.y2 - panned_area.y1;
- } else {
- int width, height;
- RRCrtcGetScanoutSize (crtc, &width, &height);
- scratch.x_org = crtc->x;
- scratch.y_org = crtc->y;
- scratch.width = width;
- scratch.height = height;
- }
- if(client->swapped) {
- register int n;
- swaps(&scratch.x_org, n);
- swaps(&scratch.y_org, n);
- swaps(&scratch.width, n);
- swaps(&scratch.height, n);
- }
- WriteToClient(client, sz_XineramaScreenInfo, &scratch);
- }
-}
-
-int
-ProcRRXineramaQueryScreens(ClientPtr client)
-{
- xXineramaQueryScreensReply rep;
- ScreenPtr pScreen = screenInfo.screens[RR_XINERAMA_SCREEN];
-
- REQUEST_SIZE_MATCH(xXineramaQueryScreensReq);
-
- if (RRXineramaScreenActive (pScreen))
- RRGetInfo (pScreen, FALSE);
-
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.number = RRXineramaScreenCount (pScreen);
- rep.length = bytes_to_int32(rep.number * sz_XineramaScreenInfo);
- if(client->swapped) {
- register int n;
- swaps(&rep.sequenceNumber, n);
- swapl(&rep.length, n);
- swapl(&rep.number, n);
- }
- WriteToClient(client, sizeof(xXineramaQueryScreensReply), (char *)&rep);
-
- if(rep.number) {
- rrScrPriv(pScreen);
- int i;
- int has_primary = 0;
-
- if (pScrPriv->primaryOutput && pScrPriv->primaryOutput->crtc) {
- has_primary = 1;
- RRXineramaWriteCrtc(client, pScrPriv->primaryOutput->crtc);
- }
-
- for(i = 0; i < pScrPriv->numCrtcs; i++) {
- if (has_primary &&
- pScrPriv->primaryOutput->crtc == pScrPriv->crtcs[i])
- {
- has_primary = 0;
- continue;
- }
- RRXineramaWriteCrtc(client, pScrPriv->crtcs[i]);
- }
- }
-
- return Success;
-}
-
-static int
-ProcRRXineramaDispatch(ClientPtr client)
-{
- REQUEST(xReq);
- switch (stuff->data) {
- case X_PanoramiXQueryVersion:
- return ProcRRXineramaQueryVersion(client);
- case X_PanoramiXGetState:
- return ProcRRXineramaGetState(client);
- case X_PanoramiXGetScreenCount:
- return ProcRRXineramaGetScreenCount(client);
- case X_PanoramiXGetScreenSize:
- return ProcRRXineramaGetScreenSize(client);
- case X_XineramaIsActive:
- return ProcRRXineramaIsActive(client);
- case X_XineramaQueryScreens:
- return ProcRRXineramaQueryScreens(client);
- }
- return BadRequest;
-}
-
-/* SProc */
-
-static int
-SProcRRXineramaQueryVersion (ClientPtr client)
-{
- REQUEST(xPanoramiXQueryVersionReq);
- register int n;
- swaps(&stuff->length,n);
- REQUEST_SIZE_MATCH (xPanoramiXQueryVersionReq);
- return ProcRRXineramaQueryVersion(client);
-}
-
-static int
-SProcRRXineramaGetState(ClientPtr client)
-{
- REQUEST(xPanoramiXGetStateReq);
- register int n;
- swaps (&stuff->length, n);
- REQUEST_SIZE_MATCH(xPanoramiXGetStateReq);
- swapl (&stuff->window, n);
- return ProcRRXineramaGetState(client);
-}
-
-static int
-SProcRRXineramaGetScreenCount(ClientPtr client)
-{
- REQUEST(xPanoramiXGetScreenCountReq);
- register int n;
- swaps (&stuff->length, n);
- REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq);
- swapl (&stuff->window, n);
- return ProcRRXineramaGetScreenCount(client);
-}
-
-static int
-SProcRRXineramaGetScreenSize(ClientPtr client)
-{
- REQUEST(xPanoramiXGetScreenSizeReq);
- register int n;
- swaps (&stuff->length, n);
- REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
- swapl (&stuff->window, n);
- swapl (&stuff->screen, n);
- return ProcRRXineramaGetScreenSize(client);
-}
-
-static int
-SProcRRXineramaIsActive(ClientPtr client)
-{
- REQUEST(xXineramaIsActiveReq);
- register int n;
- swaps (&stuff->length, n);
- REQUEST_SIZE_MATCH(xXineramaIsActiveReq);
- return ProcRRXineramaIsActive(client);
-}
-
-static int
-SProcRRXineramaQueryScreens(ClientPtr client)
-{
- REQUEST(xXineramaQueryScreensReq);
- register int n;
- swaps (&stuff->length, n);
- REQUEST_SIZE_MATCH(xXineramaQueryScreensReq);
- return ProcRRXineramaQueryScreens(client);
-}
-
-int
-SProcRRXineramaDispatch(ClientPtr client)
-{
- REQUEST(xReq);
- switch (stuff->data) {
- case X_PanoramiXQueryVersion:
- return SProcRRXineramaQueryVersion(client);
- case X_PanoramiXGetState:
- return SProcRRXineramaGetState(client);
- case X_PanoramiXGetScreenCount:
- return SProcRRXineramaGetScreenCount(client);
- case X_PanoramiXGetScreenSize:
- return SProcRRXineramaGetScreenSize(client);
- case X_XineramaIsActive:
- return SProcRRXineramaIsActive(client);
- case X_XineramaQueryScreens:
- return SProcRRXineramaQueryScreens(client);
- }
- return BadRequest;
-}
-
-void
-RRXineramaExtensionInit(void)
-{
-#ifdef PANORAMIX
- if(!noPanoramiXExtension)
- return;
-#endif
-
- /*
- * Xinerama isn't capable enough to have multiple protocol screens each
- * with their own output geometry. So if there's more than one protocol
- * screen, just don't even try.
- */
- if (screenInfo.numScreens > 1)
- return;
-
- (void) AddExtension(PANORAMIX_PROTOCOL_NAME, 0,0,
- ProcRRXineramaDispatch,
- SProcRRXineramaDispatch,
- NULL,
- StandardMinorOpcode);
-}
+/* + * Copyright © 2006 Keith Packard + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ +/* + * This Xinerama implementation comes from the SiS driver which has + * the following notice: + */ +/* + * SiS driver main code + * + * Copyright (C) 2001-2005 by Thomas Winischhofer, Vienna, Austria. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2) Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3) The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Author: Thomas Winischhofer <thomas@winischhofer.net> + * - driver entirely rewritten since 2001, only basic structure taken from + * old code (except sis_dri.c, sis_shadow.c, sis_accel.c and parts of + * sis_dga.c; these were mostly taken over; sis_dri.c was changed for + * new versions of the DRI layer) + * + * This notice covers the entire driver code unless indicated otherwise. + * + * Formerly based on code which was + * Copyright (C) 1998, 1999 by Alan Hourihane, Wigan, England. + * Written by: + * Alan Hourihane <alanh@fairlite.demon.co.uk>, + * Mike Chapman <mike@paranoia.com>, + * Juanjo Santamarta <santamarta@ctv.es>, + * Mitani Hiroshi <hmitani@drl.mei.co.jp>, + * David Thomas <davtom@dream.org.uk>. + */ + +#include "randrstr.h" +#include "swaprep.h" +#include <X11/extensions/panoramiXproto.h> +#include "protocol-versions.h" + +/* Xinerama is not multi-screen capable; just report about screen 0 */ +#define RR_XINERAMA_SCREEN 0 + +static int ProcRRXineramaQueryVersion(ClientPtr client); +static int ProcRRXineramaGetState(ClientPtr client); +static int ProcRRXineramaGetScreenCount(ClientPtr client); +static int ProcRRXineramaGetScreenSize(ClientPtr client); +static int ProcRRXineramaIsActive(ClientPtr client); +static int ProcRRXineramaQueryScreens(ClientPtr client); +static int SProcRRXineramaDispatch(ClientPtr client); + +/* Proc */ + +int +ProcRRXineramaQueryVersion(ClientPtr client) +{ + xPanoramiXQueryVersionReply rep; + + REQUEST_SIZE_MATCH(xPanoramiXQueryVersionReq); + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.majorVersion = SERVER_RRXINERAMA_MAJOR_VERSION; + rep.minorVersion = SERVER_RRXINERAMA_MINOR_VERSION; + if(client->swapped) { + swaps(&rep.sequenceNumber); + swapl(&rep.length); + swaps(&rep.majorVersion); + swaps(&rep.minorVersion); + } + WriteToClient(client, sizeof(xPanoramiXQueryVersionReply), (char *)&rep); + return Success; +} + +int +ProcRRXineramaGetState(ClientPtr client) +{ + REQUEST(xPanoramiXGetStateReq); + WindowPtr pWin; + xPanoramiXGetStateReply rep; + register int rc; + ScreenPtr pScreen; + rrScrPrivPtr pScrPriv; + Bool active = FALSE; + + REQUEST_SIZE_MATCH(xPanoramiXGetStateReq); + rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); + if(rc != Success) + return rc; + + pScreen = pWin->drawable.pScreen; + pScrPriv = rrGetScrPriv(pScreen); + if (pScrPriv) + { + /* XXX do we need more than this? */ + active = TRUE; + } + + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.state = active; + rep.window = stuff->window; + if(client->swapped) { + swaps(&rep.sequenceNumber); + swapl(&rep.length); + swapl(&rep.window); + } + WriteToClient(client, sizeof(xPanoramiXGetStateReply), (char *)&rep); + return Success; +} + +static Bool +RRXineramaCrtcActive (RRCrtcPtr crtc) +{ + return crtc->mode != NULL && crtc->numOutputs > 0; +} + +static int +RRXineramaScreenCount (ScreenPtr pScreen) +{ + int i, n; + + n = 0; + if (rrGetScrPriv (pScreen)) + { + rrScrPriv(pScreen); + for (i = 0; i < pScrPriv->numCrtcs; i++) + if (RRXineramaCrtcActive (pScrPriv->crtcs[i])) + n++; + } + return n; +} + +static Bool +RRXineramaScreenActive (ScreenPtr pScreen) +{ + return RRXineramaScreenCount (pScreen) > 0; +} + +int +ProcRRXineramaGetScreenCount(ClientPtr client) +{ + REQUEST(xPanoramiXGetScreenCountReq); + WindowPtr pWin; + xPanoramiXGetScreenCountReply rep; + register int rc; + + REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq); + rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); + if (rc != Success) + return rc; + + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.ScreenCount = RRXineramaScreenCount (pWin->drawable.pScreen); + rep.window = stuff->window; + if(client->swapped) { + swaps(&rep.sequenceNumber); + swapl(&rep.length); + swapl(&rep.window); + } + WriteToClient(client, sizeof(xPanoramiXGetScreenCountReply), (char *)&rep); + return Success; +} + +int +ProcRRXineramaGetScreenSize(ClientPtr client) +{ + REQUEST(xPanoramiXGetScreenSizeReq); + WindowPtr pWin, pRoot; + ScreenPtr pScreen; + xPanoramiXGetScreenSizeReply rep; + register int rc; + + REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq); + rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); + if (rc != Success) + return rc; + + pScreen = pWin->drawable.pScreen; + pRoot = pScreen->root; + + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.width = pRoot->drawable.width; + rep.height = pRoot->drawable.height; + rep.window = stuff->window; + rep.screen = stuff->screen; + if(client->swapped) { + swaps(&rep.sequenceNumber); + swapl(&rep.length); + swapl(&rep.width); + swapl(&rep.height); + swapl(&rep.window); + swapl(&rep.screen); + } + WriteToClient(client, sizeof(xPanoramiXGetScreenSizeReply), (char *)&rep); + return Success; +} + +int +ProcRRXineramaIsActive(ClientPtr client) +{ + xXineramaIsActiveReply rep; + + REQUEST_SIZE_MATCH(xXineramaIsActiveReq); + + memset(&rep, 0, sizeof(xXineramaIsActiveReply)); + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.state = RRXineramaScreenActive (screenInfo.screens[RR_XINERAMA_SCREEN]); + if(client->swapped) { + swaps(&rep.sequenceNumber); + swapl(&rep.length); + swapl(&rep.state); + } + WriteToClient(client, sizeof(xXineramaIsActiveReply), (char *) &rep); + return Success; +} + +static void +RRXineramaWriteCrtc(ClientPtr client, RRCrtcPtr crtc) +{ + xXineramaScreenInfo scratch; + + if (RRXineramaCrtcActive (crtc)) + { + ScreenPtr pScreen = crtc->pScreen; + rrScrPrivPtr pScrPriv = rrGetScrPriv(pScreen); + BoxRec panned_area; + + /* Check to see if crtc is panned and return the full area when applicable. */ + if (pScrPriv && pScrPriv->rrGetPanning && + pScrPriv->rrGetPanning (pScreen, crtc, &panned_area, NULL, NULL) && + (panned_area.x2 > panned_area.x1) && (panned_area.y2 > panned_area.y1)) { + scratch.x_org = panned_area.x1; + scratch.y_org = panned_area.y1; + scratch.width = panned_area.x2 - panned_area.x1; + scratch.height = panned_area.y2 - panned_area.y1; + } else { + int width, height; + RRCrtcGetScanoutSize (crtc, &width, &height); + scratch.x_org = crtc->x; + scratch.y_org = crtc->y; + scratch.width = width; + scratch.height = height; + } + if(client->swapped) { + swaps(&scratch.x_org); + swaps(&scratch.y_org); + swaps(&scratch.width); + swaps(&scratch.height); + } + WriteToClient(client, sz_XineramaScreenInfo, &scratch); + } +} + +int +ProcRRXineramaQueryScreens(ClientPtr client) +{ + xXineramaQueryScreensReply rep; + ScreenPtr pScreen = screenInfo.screens[RR_XINERAMA_SCREEN]; + + REQUEST_SIZE_MATCH(xXineramaQueryScreensReq); + + if (RRXineramaScreenActive (pScreen)) + RRGetInfo (pScreen, FALSE); + + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.number = RRXineramaScreenCount (pScreen); + rep.length = bytes_to_int32(rep.number * sz_XineramaScreenInfo); + if(client->swapped) { + swaps(&rep.sequenceNumber); + swapl(&rep.length); + swapl(&rep.number); + } + WriteToClient(client, sizeof(xXineramaQueryScreensReply), (char *)&rep); + + if(rep.number) { + rrScrPriv(pScreen); + int i; + int has_primary = 0; + + if (pScrPriv->primaryOutput && pScrPriv->primaryOutput->crtc) { + has_primary = 1; + RRXineramaWriteCrtc(client, pScrPriv->primaryOutput->crtc); + } + + for(i = 0; i < pScrPriv->numCrtcs; i++) { + if (has_primary && + pScrPriv->primaryOutput->crtc == pScrPriv->crtcs[i]) + { + has_primary = 0; + continue; + } + RRXineramaWriteCrtc(client, pScrPriv->crtcs[i]); + } + } + + return Success; +} + +static int +ProcRRXineramaDispatch(ClientPtr client) +{ + REQUEST(xReq); + switch (stuff->data) { + case X_PanoramiXQueryVersion: + return ProcRRXineramaQueryVersion(client); + case X_PanoramiXGetState: + return ProcRRXineramaGetState(client); + case X_PanoramiXGetScreenCount: + return ProcRRXineramaGetScreenCount(client); + case X_PanoramiXGetScreenSize: + return ProcRRXineramaGetScreenSize(client); + case X_XineramaIsActive: + return ProcRRXineramaIsActive(client); + case X_XineramaQueryScreens: + return ProcRRXineramaQueryScreens(client); + } + return BadRequest; +} + +/* SProc */ + +static int +SProcRRXineramaQueryVersion (ClientPtr client) +{ + REQUEST(xPanoramiXQueryVersionReq); + swaps(&stuff->length); + REQUEST_SIZE_MATCH (xPanoramiXQueryVersionReq); + return ProcRRXineramaQueryVersion(client); +} + +static int +SProcRRXineramaGetState(ClientPtr client) +{ + REQUEST(xPanoramiXGetStateReq); + swaps(&stuff->length); + REQUEST_SIZE_MATCH(xPanoramiXGetStateReq); + swapl(&stuff->window); + return ProcRRXineramaGetState(client); +} + +static int +SProcRRXineramaGetScreenCount(ClientPtr client) +{ + REQUEST(xPanoramiXGetScreenCountReq); + swaps(&stuff->length); + REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq); + swapl(&stuff->window); + return ProcRRXineramaGetScreenCount(client); +} + +static int +SProcRRXineramaGetScreenSize(ClientPtr client) +{ + REQUEST(xPanoramiXGetScreenSizeReq); + swaps(&stuff->length); + REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq); + swapl(&stuff->window); + swapl(&stuff->screen); + return ProcRRXineramaGetScreenSize(client); +} + +static int +SProcRRXineramaIsActive(ClientPtr client) +{ + REQUEST(xXineramaIsActiveReq); + swaps(&stuff->length); + REQUEST_SIZE_MATCH(xXineramaIsActiveReq); + return ProcRRXineramaIsActive(client); +} + +static int +SProcRRXineramaQueryScreens(ClientPtr client) +{ + REQUEST(xXineramaQueryScreensReq); + swaps(&stuff->length); + REQUEST_SIZE_MATCH(xXineramaQueryScreensReq); + return ProcRRXineramaQueryScreens(client); +} + +int +SProcRRXineramaDispatch(ClientPtr client) +{ + REQUEST(xReq); + switch (stuff->data) { + case X_PanoramiXQueryVersion: + return SProcRRXineramaQueryVersion(client); + case X_PanoramiXGetState: + return SProcRRXineramaGetState(client); + case X_PanoramiXGetScreenCount: + return SProcRRXineramaGetScreenCount(client); + case X_PanoramiXGetScreenSize: + return SProcRRXineramaGetScreenSize(client); + case X_XineramaIsActive: + return SProcRRXineramaIsActive(client); + case X_XineramaQueryScreens: + return SProcRRXineramaQueryScreens(client); + } + return BadRequest; +} + +void +RRXineramaExtensionInit(void) +{ +#ifdef PANORAMIX + if(!noPanoramiXExtension) + return; +#endif + + /* + * Xinerama isn't capable enough to have multiple protocol screens each + * with their own output geometry. So if there's more than one protocol + * screen, just don't even try. + */ + if (screenInfo.numScreens > 1) + return; + + (void) AddExtension(PANORAMIX_PROTOCOL_NAME, 0,0, + ProcRRXineramaDispatch, + SProcRRXineramaDispatch, + NULL, + StandardMinorOpcode); +} |