diff options
author | marha <marha@users.sourceforge.net> | 2012-03-23 10:05:55 +0100 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2012-03-23 10:05:55 +0100 |
commit | 0f834b91a4768673833ab4917e87d86c237bb1a6 (patch) | |
tree | 363489504ed4b2d360259b8de4c9e392918e5d02 /xorg-server/randr | |
parent | fc72edebf875378459368c5383d9023730cbca54 (diff) | |
download | vcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.tar.gz vcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.tar.bz2 vcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.zip |
libX11 xserver fontconfig mesa pixman xkbcomp xkeyboard-config git update
23 Mar 2012
Diffstat (limited to 'xorg-server/randr')
-rw-r--r-- | xorg-server/randr/randr.c | 998 | ||||
-rw-r--r-- | xorg-server/randr/randrstr.h | 681 | ||||
-rw-r--r-- | xorg-server/randr/rrcrtc.c | 1504 | ||||
-rw-r--r-- | xorg-server/randr/rrdispatch.c | 347 | ||||
-rw-r--r-- | xorg-server/randr/rrinfo.c | 310 | ||||
-rw-r--r-- | xorg-server/randr/rrmode.c | 385 | ||||
-rw-r--r-- | xorg-server/randr/rroutput.c | 527 | ||||
-rw-r--r-- | xorg-server/randr/rrpointer.c | 151 | ||||
-rw-r--r-- | xorg-server/randr/rrproperty.c | 775 | ||||
-rw-r--r-- | xorg-server/randr/rrscreen.c | 1321 | ||||
-rw-r--r-- | xorg-server/randr/rrsdispatch.c | 184 | ||||
-rw-r--r-- | xorg-server/randr/rrtransform.c | 368 | ||||
-rw-r--r-- | xorg-server/randr/rrtransform.h | 53 | ||||
-rw-r--r-- | xorg-server/randr/rrxinerama.c | 311 |
14 files changed, 3821 insertions, 4094 deletions
diff --git a/xorg-server/randr/randr.c b/xorg-server/randr/randr.c index 1551c63b1..9f3df5fbe 100644 --- a/xorg-server/randr/randr.c +++ b/xorg-server/randr/randr.c @@ -1,504 +1,494 @@ -/*
- * Copyright © 2000 Compaq Computer Corporation
- * Copyright © 2002 Hewlett-Packard Company
- * Copyright © 2006 Intel Corporation
- *
- * 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.
- *
- * Author: Jim Gettys, Hewlett-Packard Company, Inc.
- * Keith Packard, Intel Corporation
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "randrstr.h"
-
-/* From render.h */
-#ifndef SubPixelUnknown
-#define SubPixelUnknown 0
-#endif
-
-#define RR_VALIDATE
-static int RRNScreens;
-
-#define wrap(priv,real,mem,func) {\
- priv->mem = real->mem; \
- real->mem = func; \
-}
-
-#define unwrap(priv,real,mem) {\
- real->mem = priv->mem; \
-}
-
-static int ProcRRDispatch (ClientPtr pClient);
-static int SProcRRDispatch (ClientPtr pClient);
-
-int RREventBase;
-int RRErrorBase;
-RESTYPE RRClientType, RREventType; /* resource types for event masks */
-DevPrivateKeyRec RRClientPrivateKeyRec;
-
-DevPrivateKeyRec rrPrivKeyRec;
-
-static void
-RRClientCallback (CallbackListPtr *list,
- pointer closure,
- pointer data)
-{
- NewClientInfoRec *clientinfo = (NewClientInfoRec *) data;
- ClientPtr pClient = clientinfo->client;
- rrClientPriv(pClient);
- RRTimesPtr pTimes = (RRTimesPtr) (pRRClient + 1);
- int i;
-
- pRRClient->major_version = 0;
- pRRClient->minor_version = 0;
- for (i = 0; i < screenInfo.numScreens; i++)
- {
- ScreenPtr pScreen = screenInfo.screens[i];
- rrScrPriv(pScreen);
-
- if (pScrPriv)
- {
- pTimes[i].setTime = pScrPriv->lastSetTime;
- pTimes[i].configTime = pScrPriv->lastConfigTime;
- }
- }
-}
-
-static Bool
-RRCloseScreen (int i, ScreenPtr pScreen)
-{
- rrScrPriv(pScreen);
- int j;
-
- unwrap (pScrPriv, pScreen, CloseScreen);
- for (j = pScrPriv->numCrtcs - 1; j >= 0; j--)
- RRCrtcDestroy (pScrPriv->crtcs[j]);
- for (j = pScrPriv->numOutputs - 1; j >= 0; j--)
- RROutputDestroy (pScrPriv->outputs[j]);
-
- free(pScrPriv->crtcs);
- free(pScrPriv->outputs);
- free(pScrPriv);
- RRNScreens -= 1; /* ok, one fewer screen with RandR running */
- return (*pScreen->CloseScreen) (i, pScreen);
-}
-
-static void
-SRRScreenChangeNotifyEvent(xRRScreenChangeNotifyEvent *from,
- xRRScreenChangeNotifyEvent *to)
-{
- to->type = from->type;
- to->rotation = from->rotation;
- cpswaps(from->sequenceNumber, to->sequenceNumber);
- cpswapl(from->timestamp, to->timestamp);
- cpswapl(from->configTimestamp, to->configTimestamp);
- cpswapl(from->root, to->root);
- cpswapl(from->window, to->window);
- cpswaps(from->sizeID, to->sizeID);
- cpswaps(from->subpixelOrder, to->subpixelOrder);
- cpswaps(from->widthInPixels, to->widthInPixels);
- cpswaps(from->heightInPixels, to->heightInPixels);
- cpswaps(from->widthInMillimeters, to->widthInMillimeters);
- cpswaps(from->heightInMillimeters, to->heightInMillimeters);
-}
-
-static void
-SRRCrtcChangeNotifyEvent(xRRCrtcChangeNotifyEvent *from,
- xRRCrtcChangeNotifyEvent *to)
-{
- to->type = from->type;
- to->subCode = from->subCode;
- cpswaps(from->sequenceNumber, to->sequenceNumber);
- cpswapl(from->timestamp, to->timestamp);
- cpswapl(from->window, to->window);
- cpswapl(from->crtc, to->crtc);
- cpswapl(from->mode, to->mode);
- cpswaps(from->rotation, to->rotation);
- /* pad1 */
- cpswaps(from->x, to->x);
- cpswaps(from->y, to->y);
- cpswaps(from->width, to->width);
- cpswaps(from->height, to->height);
-}
-
-static void
-SRROutputChangeNotifyEvent(xRROutputChangeNotifyEvent *from,
- xRROutputChangeNotifyEvent *to)
-{
- to->type = from->type;
- to->subCode = from->subCode;
- cpswaps(from->sequenceNumber, to->sequenceNumber);
- cpswapl(from->timestamp, to->timestamp);
- cpswapl(from->configTimestamp, to->configTimestamp);
- cpswapl(from->window, to->window);
- cpswapl(from->output, to->output);
- cpswapl(from->crtc, to->crtc);
- cpswapl(from->mode, to->mode);
- cpswaps(from->rotation, to->rotation);
- to->connection = from->connection;
- to->subpixelOrder = from->subpixelOrder;
-}
-
-static void
-SRROutputPropertyNotifyEvent(xRROutputPropertyNotifyEvent *from,
- xRROutputPropertyNotifyEvent *to)
-{
- to->type = from->type;
- to->subCode = from->subCode;
- cpswaps(from->sequenceNumber, to->sequenceNumber);
- cpswapl(from->window, to->window);
- cpswapl(from->output, to->output);
- cpswapl(from->atom, to->atom);
- cpswapl(from->timestamp, to->timestamp);
- to->state = from->state;
- /* pad1 */
- /* pad2 */
- /* pad3 */
- /* pad4 */
-}
-
-static void
-SRRNotifyEvent (xEvent *from,
- xEvent *to)
-{
- switch (from->u.u.detail) {
- case RRNotify_CrtcChange:
- SRRCrtcChangeNotifyEvent ((xRRCrtcChangeNotifyEvent *) from,
- (xRRCrtcChangeNotifyEvent *) to);
- break;
- case RRNotify_OutputChange:
- SRROutputChangeNotifyEvent ((xRROutputChangeNotifyEvent *) from,
- (xRROutputChangeNotifyEvent *) to);
- break;
- case RRNotify_OutputProperty:
- SRROutputPropertyNotifyEvent ((xRROutputPropertyNotifyEvent *) from,
- (xRROutputPropertyNotifyEvent *) to);
- break;
- default:
- break;
- }
-}
-
-static int RRGeneration;
-
-Bool RRInit (void)
-{
- if (RRGeneration != serverGeneration)
- {
- if (!RRModeInit ())
- return FALSE;
- if (!RRCrtcInit ())
- return FALSE;
- if (!RROutputInit ())
- return FALSE;
- RRGeneration = serverGeneration;
- }
- if (!dixRegisterPrivateKey(&rrPrivKeyRec, PRIVATE_SCREEN, 0))
- return FALSE;
-
- return TRUE;
-}
-
-Bool RRScreenInit(ScreenPtr pScreen)
-{
- rrScrPrivPtr pScrPriv;
-
- if (!RRInit ())
- return FALSE;
-
- pScrPriv = (rrScrPrivPtr) calloc(1, sizeof (rrScrPrivRec));
- if (!pScrPriv)
- return FALSE;
-
- SetRRScreen(pScreen, pScrPriv);
-
- /*
- * Calling function best set these function vectors
- */
- pScrPriv->rrGetInfo = 0;
- pScrPriv->maxWidth = pScrPriv->minWidth = pScreen->width;
- pScrPriv->maxHeight = pScrPriv->minHeight = pScreen->height;
-
- pScrPriv->width = pScreen->width;
- pScrPriv->height = pScreen->height;
- pScrPriv->mmWidth = pScreen->mmWidth;
- pScrPriv->mmHeight = pScreen->mmHeight;
-#if RANDR_12_INTERFACE
- pScrPriv->rrScreenSetSize = NULL;
- pScrPriv->rrCrtcSet = NULL;
- pScrPriv->rrCrtcSetGamma = NULL;
-#endif
-#if RANDR_10_INTERFACE
- pScrPriv->rrSetConfig = 0;
- pScrPriv->rotations = RR_Rotate_0;
- pScrPriv->reqWidth = pScreen->width;
- pScrPriv->reqHeight = pScreen->height;
- pScrPriv->nSizes = 0;
- pScrPriv->pSizes = NULL;
- pScrPriv->rotation = RR_Rotate_0;
- pScrPriv->rate = 0;
- pScrPriv->size = 0;
-#endif
-
- /*
- * This value doesn't really matter -- any client must call
- * GetScreenInfo before reading it which will automatically update
- * the time
- */
- pScrPriv->lastSetTime = currentTime;
- pScrPriv->lastConfigTime = currentTime;
-
- wrap (pScrPriv, pScreen, CloseScreen, RRCloseScreen);
-
- pScreen->ConstrainCursorHarder = RRConstrainCursorHarder;
-
- pScrPriv->numOutputs = 0;
- pScrPriv->outputs = NULL;
- pScrPriv->numCrtcs = 0;
- pScrPriv->crtcs = NULL;
-
- RRNScreens += 1; /* keep count of screens that implement randr */
- return TRUE;
-}
-
-/*ARGSUSED*/
-static int
-RRFreeClient (pointer data, XID id)
-{
- RREventPtr pRREvent;
- WindowPtr pWin;
- RREventPtr *pHead, pCur, pPrev;
-
- pRREvent = (RREventPtr) data;
- pWin = pRREvent->window;
- dixLookupResourceByType((pointer *)&pHead, pWin->drawable.id,
- RREventType, serverClient, DixDestroyAccess);
- if (pHead) {
- pPrev = 0;
- for (pCur = *pHead; pCur && pCur != pRREvent; pCur=pCur->next)
- pPrev = pCur;
- if (pCur)
- {
- if (pPrev)
- pPrev->next = pRREvent->next;
- else
- *pHead = pRREvent->next;
- }
- }
- free((pointer) pRREvent);
- return 1;
-}
-
-/*ARGSUSED*/
-static int
-RRFreeEvents (pointer data, XID id)
-{
- RREventPtr *pHead, pCur, pNext;
-
- pHead = (RREventPtr *) data;
- for (pCur = *pHead; pCur; pCur = pNext) {
- pNext = pCur->next;
- FreeResource (pCur->clientResource, RRClientType);
- free((pointer) pCur);
- }
- free((pointer) pHead);
- return 1;
-}
-
-void
-RRExtensionInit (void)
-{
- ExtensionEntry *extEntry;
-
- if (RRNScreens == 0) return;
-
- if (!dixRegisterPrivateKey(&RRClientPrivateKeyRec, PRIVATE_CLIENT,
- sizeof (RRClientRec) +
- screenInfo.numScreens * sizeof (RRTimesRec)))
- return;
- if (!AddCallback (&ClientStateCallback, RRClientCallback, 0))
- return;
-
- RRClientType = CreateNewResourceType(RRFreeClient, "RandRClient");
- if (!RRClientType)
- return;
- RREventType = CreateNewResourceType(RRFreeEvents, "RandREvent");
- if (!RREventType)
- return;
- extEntry = AddExtension (RANDR_NAME, RRNumberEvents, RRNumberErrors,
- ProcRRDispatch, SProcRRDispatch,
- NULL, StandardMinorOpcode);
- if (!extEntry)
- return;
- RRErrorBase = extEntry->errorBase;
- RREventBase = extEntry->eventBase;
- EventSwapVector[RREventBase + RRScreenChangeNotify] = (EventSwapPtr)
- SRRScreenChangeNotifyEvent;
- EventSwapVector[RREventBase + RRNotify] = (EventSwapPtr)
- SRRNotifyEvent;
-
- RRModeInitErrorValue();
- RRCrtcInitErrorValue();
- RROutputInitErrorValue();
-
-#ifdef PANORAMIX
- RRXineramaExtensionInit();
-#endif
-}
-
-static int
-TellChanged (WindowPtr pWin, pointer value)
-{
- RREventPtr *pHead, pRREvent;
- ClientPtr client;
- ScreenPtr pScreen = pWin->drawable.pScreen;
- rrScrPriv(pScreen);
- int i;
-
- dixLookupResourceByType((pointer *)&pHead, pWin->drawable.id,
- RREventType, serverClient, DixReadAccess);
- if (!pHead)
- return WT_WALKCHILDREN;
-
- for (pRREvent = *pHead; pRREvent; pRREvent = pRREvent->next)
- {
- client = pRREvent->client;
- if (client == serverClient || client->clientGone)
- continue;
-
- if (pRREvent->mask & RRScreenChangeNotifyMask)
- RRDeliverScreenEvent (client, pWin, pScreen);
-
- if (pRREvent->mask & RRCrtcChangeNotifyMask)
- {
- for (i = 0; i < pScrPriv->numCrtcs; i++)
- {
- RRCrtcPtr crtc = pScrPriv->crtcs[i];
- if (crtc->changed)
- RRDeliverCrtcEvent (client, pWin, crtc);
- }
- }
-
- if (pRREvent->mask & RROutputChangeNotifyMask)
- {
- for (i = 0; i < pScrPriv->numOutputs; i++)
- {
- RROutputPtr output = pScrPriv->outputs[i];
- if (output->changed)
- RRDeliverOutputEvent (client, pWin, output);
- }
- }
- }
- return WT_WALKCHILDREN;
-}
-
-/*
- * Something changed; send events and adjust pointer position
- */
-void
-RRTellChanged (ScreenPtr pScreen)
-{
- rrScrPriv (pScreen);
- int i;
-
- if (pScrPriv->changed)
- {
- UpdateCurrentTime ();
- if (pScrPriv->configChanged)
- {
- pScrPriv->lastConfigTime = currentTime;
- pScrPriv->configChanged = FALSE;
- }
- pScrPriv->changed = FALSE;
- WalkTree (pScreen, TellChanged, (pointer) pScreen);
- for (i = 0; i < pScrPriv->numOutputs; i++)
- pScrPriv->outputs[i]->changed = FALSE;
- for (i = 0; i < pScrPriv->numCrtcs; i++)
- pScrPriv->crtcs[i]->changed = FALSE;
- if (pScrPriv->layoutChanged)
- {
- pScrPriv->layoutChanged = FALSE;
- RRPointerScreenConfigured (pScreen);
- RRSendConfigNotify (pScreen);
- }
- }
-}
-
-/*
- * Return the first output which is connected to an active CRTC
- * Used in emulating 1.0 behaviour
- */
-RROutputPtr
-RRFirstOutput (ScreenPtr pScreen)
-{
- rrScrPriv(pScreen);
- RROutputPtr output;
- int i, j;
-
- if (pScrPriv->primaryOutput && pScrPriv->primaryOutput->crtc)
- return pScrPriv->primaryOutput;
-
- for (i = 0; i < pScrPriv->numCrtcs; i++)
- {
- RRCrtcPtr crtc = pScrPriv->crtcs[i];
- for (j = 0; j < pScrPriv->numOutputs; j++)
- {
- output = pScrPriv->outputs[j];
- if (output->crtc == crtc)
- return output;
- }
- }
- return NULL;
-}
-
-CARD16
-RRVerticalRefresh (xRRModeInfo *mode)
-{
- CARD32 refresh;
- CARD32 dots = mode->hTotal * mode->vTotal;
- if (!dots)
- return 0;
- refresh = (mode->dotClock + dots/2) / dots;
- if (refresh > 0xffff)
- refresh = 0xffff;
- return (CARD16) refresh;
-}
-
-static int
-ProcRRDispatch (ClientPtr client)
-{
- REQUEST(xReq);
- if (stuff->data >= RRNumberRequests || !ProcRandrVector[stuff->data])
- return BadRequest;
- return (*ProcRandrVector[stuff->data]) (client);
-}
-
-static int
-SProcRRDispatch (ClientPtr client)
-{
- REQUEST(xReq);
- if (stuff->data >= RRNumberRequests || !ProcRandrVector[stuff->data])
- return BadRequest;
- return (*SProcRandrVector[stuff->data]) (client);
-}
-
+/* + * Copyright © 2000 Compaq Computer Corporation + * Copyright © 2002 Hewlett-Packard Company + * Copyright © 2006 Intel Corporation + * + * 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. + * + * Author: Jim Gettys, Hewlett-Packard Company, Inc. + * Keith Packard, Intel Corporation + */ + +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#include "randrstr.h" + +/* From render.h */ +#ifndef SubPixelUnknown +#define SubPixelUnknown 0 +#endif + +#define RR_VALIDATE +static int RRNScreens; + +#define wrap(priv,real,mem,func) {\ + priv->mem = real->mem; \ + real->mem = func; \ +} + +#define unwrap(priv,real,mem) {\ + real->mem = priv->mem; \ +} + +static int ProcRRDispatch(ClientPtr pClient); +static int SProcRRDispatch(ClientPtr pClient); + +int RREventBase; +int RRErrorBase; +RESTYPE RRClientType, RREventType; /* resource types for event masks */ +DevPrivateKeyRec RRClientPrivateKeyRec; + +DevPrivateKeyRec rrPrivKeyRec; + +static void +RRClientCallback(CallbackListPtr *list, pointer closure, pointer data) +{ + NewClientInfoRec *clientinfo = (NewClientInfoRec *) data; + ClientPtr pClient = clientinfo->client; + + rrClientPriv(pClient); + RRTimesPtr pTimes = (RRTimesPtr) (pRRClient + 1); + int i; + + pRRClient->major_version = 0; + pRRClient->minor_version = 0; + for (i = 0; i < screenInfo.numScreens; i++) { + ScreenPtr pScreen = screenInfo.screens[i]; + + rrScrPriv(pScreen); + + if (pScrPriv) { + pTimes[i].setTime = pScrPriv->lastSetTime; + pTimes[i].configTime = pScrPriv->lastConfigTime; + } + } +} + +static Bool +RRCloseScreen(int i, ScreenPtr pScreen) +{ + rrScrPriv(pScreen); + int j; + + unwrap(pScrPriv, pScreen, CloseScreen); + for (j = pScrPriv->numCrtcs - 1; j >= 0; j--) + RRCrtcDestroy(pScrPriv->crtcs[j]); + for (j = pScrPriv->numOutputs - 1; j >= 0; j--) + RROutputDestroy(pScrPriv->outputs[j]); + + free(pScrPriv->crtcs); + free(pScrPriv->outputs); + free(pScrPriv); + RRNScreens -= 1; /* ok, one fewer screen with RandR running */ + return (*pScreen->CloseScreen) (i, pScreen); +} + +static void +SRRScreenChangeNotifyEvent(xRRScreenChangeNotifyEvent * from, + xRRScreenChangeNotifyEvent * to) +{ + to->type = from->type; + to->rotation = from->rotation; + cpswaps(from->sequenceNumber, to->sequenceNumber); + cpswapl(from->timestamp, to->timestamp); + cpswapl(from->configTimestamp, to->configTimestamp); + cpswapl(from->root, to->root); + cpswapl(from->window, to->window); + cpswaps(from->sizeID, to->sizeID); + cpswaps(from->subpixelOrder, to->subpixelOrder); + cpswaps(from->widthInPixels, to->widthInPixels); + cpswaps(from->heightInPixels, to->heightInPixels); + cpswaps(from->widthInMillimeters, to->widthInMillimeters); + cpswaps(from->heightInMillimeters, to->heightInMillimeters); +} + +static void +SRRCrtcChangeNotifyEvent(xRRCrtcChangeNotifyEvent * from, + xRRCrtcChangeNotifyEvent * to) +{ + to->type = from->type; + to->subCode = from->subCode; + cpswaps(from->sequenceNumber, to->sequenceNumber); + cpswapl(from->timestamp, to->timestamp); + cpswapl(from->window, to->window); + cpswapl(from->crtc, to->crtc); + cpswapl(from->mode, to->mode); + cpswaps(from->rotation, to->rotation); + /* pad1 */ + cpswaps(from->x, to->x); + cpswaps(from->y, to->y); + cpswaps(from->width, to->width); + cpswaps(from->height, to->height); +} + +static void +SRROutputChangeNotifyEvent(xRROutputChangeNotifyEvent * from, + xRROutputChangeNotifyEvent * to) +{ + to->type = from->type; + to->subCode = from->subCode; + cpswaps(from->sequenceNumber, to->sequenceNumber); + cpswapl(from->timestamp, to->timestamp); + cpswapl(from->configTimestamp, to->configTimestamp); + cpswapl(from->window, to->window); + cpswapl(from->output, to->output); + cpswapl(from->crtc, to->crtc); + cpswapl(from->mode, to->mode); + cpswaps(from->rotation, to->rotation); + to->connection = from->connection; + to->subpixelOrder = from->subpixelOrder; +} + +static void +SRROutputPropertyNotifyEvent(xRROutputPropertyNotifyEvent * from, + xRROutputPropertyNotifyEvent * to) +{ + to->type = from->type; + to->subCode = from->subCode; + cpswaps(from->sequenceNumber, to->sequenceNumber); + cpswapl(from->window, to->window); + cpswapl(from->output, to->output); + cpswapl(from->atom, to->atom); + cpswapl(from->timestamp, to->timestamp); + to->state = from->state; + /* pad1 */ + /* pad2 */ + /* pad3 */ + /* pad4 */ +} + +static void +SRRNotifyEvent(xEvent *from, xEvent *to) +{ + switch (from->u.u.detail) { + case RRNotify_CrtcChange: + SRRCrtcChangeNotifyEvent((xRRCrtcChangeNotifyEvent *) from, + (xRRCrtcChangeNotifyEvent *) to); + break; + case RRNotify_OutputChange: + SRROutputChangeNotifyEvent((xRROutputChangeNotifyEvent *) from, + (xRROutputChangeNotifyEvent *) to); + break; + case RRNotify_OutputProperty: + SRROutputPropertyNotifyEvent((xRROutputPropertyNotifyEvent *) from, + (xRROutputPropertyNotifyEvent *) to); + break; + default: + break; + } +} + +static int RRGeneration; + +Bool +RRInit(void) +{ + if (RRGeneration != serverGeneration) { + if (!RRModeInit()) + return FALSE; + if (!RRCrtcInit()) + return FALSE; + if (!RROutputInit()) + return FALSE; + RRGeneration = serverGeneration; + } + if (!dixRegisterPrivateKey(&rrPrivKeyRec, PRIVATE_SCREEN, 0)) + return FALSE; + + return TRUE; +} + +Bool +RRScreenInit(ScreenPtr pScreen) +{ + rrScrPrivPtr pScrPriv; + + if (!RRInit()) + return FALSE; + + pScrPriv = (rrScrPrivPtr) calloc(1, sizeof(rrScrPrivRec)); + if (!pScrPriv) + return FALSE; + + SetRRScreen(pScreen, pScrPriv); + + /* + * Calling function best set these function vectors + */ + pScrPriv->rrGetInfo = 0; + pScrPriv->maxWidth = pScrPriv->minWidth = pScreen->width; + pScrPriv->maxHeight = pScrPriv->minHeight = pScreen->height; + + pScrPriv->width = pScreen->width; + pScrPriv->height = pScreen->height; + pScrPriv->mmWidth = pScreen->mmWidth; + pScrPriv->mmHeight = pScreen->mmHeight; +#if RANDR_12_INTERFACE + pScrPriv->rrScreenSetSize = NULL; + pScrPriv->rrCrtcSet = NULL; + pScrPriv->rrCrtcSetGamma = NULL; +#endif +#if RANDR_10_INTERFACE + pScrPriv->rrSetConfig = 0; + pScrPriv->rotations = RR_Rotate_0; + pScrPriv->reqWidth = pScreen->width; + pScrPriv->reqHeight = pScreen->height; + pScrPriv->nSizes = 0; + pScrPriv->pSizes = NULL; + pScrPriv->rotation = RR_Rotate_0; + pScrPriv->rate = 0; + pScrPriv->size = 0; +#endif + + /* + * This value doesn't really matter -- any client must call + * GetScreenInfo before reading it which will automatically update + * the time + */ + pScrPriv->lastSetTime = currentTime; + pScrPriv->lastConfigTime = currentTime; + + wrap(pScrPriv, pScreen, CloseScreen, RRCloseScreen); + + pScreen->ConstrainCursorHarder = RRConstrainCursorHarder; + + pScrPriv->numOutputs = 0; + pScrPriv->outputs = NULL; + pScrPriv->numCrtcs = 0; + pScrPriv->crtcs = NULL; + + RRNScreens += 1; /* keep count of screens that implement randr */ + return TRUE; +} + + /*ARGSUSED*/ static int +RRFreeClient(pointer data, XID id) +{ + RREventPtr pRREvent; + WindowPtr pWin; + RREventPtr *pHead, pCur, pPrev; + + pRREvent = (RREventPtr) data; + pWin = pRREvent->window; + dixLookupResourceByType((pointer *) &pHead, pWin->drawable.id, + RREventType, serverClient, DixDestroyAccess); + if (pHead) { + pPrev = 0; + for (pCur = *pHead; pCur && pCur != pRREvent; pCur = pCur->next) + pPrev = pCur; + if (pCur) { + if (pPrev) + pPrev->next = pRREvent->next; + else + *pHead = pRREvent->next; + } + } + free((pointer) pRREvent); + return 1; +} + + /*ARGSUSED*/ static int +RRFreeEvents(pointer data, XID id) +{ + RREventPtr *pHead, pCur, pNext; + + pHead = (RREventPtr *) data; + for (pCur = *pHead; pCur; pCur = pNext) { + pNext = pCur->next; + FreeResource(pCur->clientResource, RRClientType); + free((pointer) pCur); + } + free((pointer) pHead); + return 1; +} + +void +RRExtensionInit(void) +{ + ExtensionEntry *extEntry; + + if (RRNScreens == 0) + return; + + if (!dixRegisterPrivateKey(&RRClientPrivateKeyRec, PRIVATE_CLIENT, + sizeof(RRClientRec) + + screenInfo.numScreens * sizeof(RRTimesRec))) + return; + if (!AddCallback(&ClientStateCallback, RRClientCallback, 0)) + return; + + RRClientType = CreateNewResourceType(RRFreeClient, "RandRClient"); + if (!RRClientType) + return; + RREventType = CreateNewResourceType(RRFreeEvents, "RandREvent"); + if (!RREventType) + return; + extEntry = AddExtension(RANDR_NAME, RRNumberEvents, RRNumberErrors, + ProcRRDispatch, SProcRRDispatch, + NULL, StandardMinorOpcode); + if (!extEntry) + return; + RRErrorBase = extEntry->errorBase; + RREventBase = extEntry->eventBase; + EventSwapVector[RREventBase + RRScreenChangeNotify] = (EventSwapPtr) + SRRScreenChangeNotifyEvent; + EventSwapVector[RREventBase + RRNotify] = (EventSwapPtr) + SRRNotifyEvent; + + RRModeInitErrorValue(); + RRCrtcInitErrorValue(); + RROutputInitErrorValue(); + +#ifdef PANORAMIX + RRXineramaExtensionInit(); +#endif +} + +static int +TellChanged(WindowPtr pWin, pointer value) +{ + RREventPtr *pHead, pRREvent; + ClientPtr client; + ScreenPtr pScreen = pWin->drawable.pScreen; + + rrScrPriv(pScreen); + int i; + + dixLookupResourceByType((pointer *) &pHead, pWin->drawable.id, + RREventType, serverClient, DixReadAccess); + if (!pHead) + return WT_WALKCHILDREN; + + for (pRREvent = *pHead; pRREvent; pRREvent = pRREvent->next) { + client = pRREvent->client; + if (client == serverClient || client->clientGone) + continue; + + if (pRREvent->mask & RRScreenChangeNotifyMask) + RRDeliverScreenEvent(client, pWin, pScreen); + + if (pRREvent->mask & RRCrtcChangeNotifyMask) { + for (i = 0; i < pScrPriv->numCrtcs; i++) { + RRCrtcPtr crtc = pScrPriv->crtcs[i]; + + if (crtc->changed) + RRDeliverCrtcEvent(client, pWin, crtc); + } + } + + if (pRREvent->mask & RROutputChangeNotifyMask) { + for (i = 0; i < pScrPriv->numOutputs; i++) { + RROutputPtr output = pScrPriv->outputs[i]; + + if (output->changed) + RRDeliverOutputEvent(client, pWin, output); + } + } + } + return WT_WALKCHILDREN; +} + +/* + * Something changed; send events and adjust pointer position + */ +void +RRTellChanged(ScreenPtr pScreen) +{ + rrScrPriv(pScreen); + int i; + + if (pScrPriv->changed) { + UpdateCurrentTime(); + if (pScrPriv->configChanged) { + pScrPriv->lastConfigTime = currentTime; + pScrPriv->configChanged = FALSE; + } + pScrPriv->changed = FALSE; + WalkTree(pScreen, TellChanged, (pointer) pScreen); + for (i = 0; i < pScrPriv->numOutputs; i++) + pScrPriv->outputs[i]->changed = FALSE; + for (i = 0; i < pScrPriv->numCrtcs; i++) + pScrPriv->crtcs[i]->changed = FALSE; + if (pScrPriv->layoutChanged) { + pScrPriv->layoutChanged = FALSE; + RRPointerScreenConfigured(pScreen); + RRSendConfigNotify(pScreen); + } + } +} + +/* + * Return the first output which is connected to an active CRTC + * Used in emulating 1.0 behaviour + */ +RROutputPtr +RRFirstOutput(ScreenPtr pScreen) +{ + rrScrPriv(pScreen); + RROutputPtr output; + int i, j; + + if (pScrPriv->primaryOutput && pScrPriv->primaryOutput->crtc) + return pScrPriv->primaryOutput; + + for (i = 0; i < pScrPriv->numCrtcs; i++) { + RRCrtcPtr crtc = pScrPriv->crtcs[i]; + + for (j = 0; j < pScrPriv->numOutputs; j++) { + output = pScrPriv->outputs[j]; + if (output->crtc == crtc) + return output; + } + } + return NULL; +} + +CARD16 +RRVerticalRefresh(xRRModeInfo * mode) +{ + CARD32 refresh; + CARD32 dots = mode->hTotal * mode->vTotal; + + if (!dots) + return 0; + refresh = (mode->dotClock + dots / 2) / dots; + if (refresh > 0xffff) + refresh = 0xffff; + return (CARD16) refresh; +} + +static int +ProcRRDispatch(ClientPtr client) +{ + REQUEST(xReq); + if (stuff->data >= RRNumberRequests || !ProcRandrVector[stuff->data]) + return BadRequest; + return (*ProcRandrVector[stuff->data]) (client); +} + +static int +SProcRRDispatch(ClientPtr client) +{ + REQUEST(xReq); + if (stuff->data >= RRNumberRequests || !ProcRandrVector[stuff->data]) + return BadRequest; + return (*SProcRandrVector[stuff->data]) (client); +} diff --git a/xorg-server/randr/randrstr.h b/xorg-server/randr/randrstr.h index 842e0e05b..273885de7 100644 --- a/xorg-server/randr/randrstr.h +++ b/xorg-server/randr/randrstr.h @@ -47,191 +47,181 @@ #include "rrtransform.h" #include <X11/extensions/randr.h> #include <X11/extensions/randrproto.h> -#include <X11/extensions/render.h> /* we share subpixel order information */ +#include <X11/extensions/render.h> /* we share subpixel order information */ #include "picturestr.h" #include <X11/Xfuncproto.h> /* required for ABI compatibility for now */ #define RANDR_10_INTERFACE 1 #define RANDR_12_INTERFACE 1 -#define RANDR_13_INTERFACE 1 /* requires RANDR_12_INTERFACE */ +#define RANDR_13_INTERFACE 1 /* requires RANDR_12_INTERFACE */ #define RANDR_GET_CRTC_INTERFACE 1 #define RANDR_INTERFACE_VERSION 0x0103 -typedef XID RRMode; -typedef XID RROutput; -typedef XID RRCrtc; +typedef XID RRMode; +typedef XID RROutput; +typedef XID RRCrtc; -extern _X_EXPORT int RREventBase, RRErrorBase; +extern _X_EXPORT int RREventBase, RRErrorBase; + +extern _X_EXPORT int (*ProcRandrVector[RRNumberRequests]) (ClientPtr); +extern _X_EXPORT int (*SProcRandrVector[RRNumberRequests]) (ClientPtr); -extern _X_EXPORT int (*ProcRandrVector[RRNumberRequests])(ClientPtr); -extern _X_EXPORT int (*SProcRandrVector[RRNumberRequests])(ClientPtr); - /* * Modeline for a monitor. Name follows directly after this struct */ #define RRModeName(pMode) ((char *) (pMode + 1)) -typedef struct _rrMode RRModeRec, *RRModePtr; -typedef struct _rrPropertyValue RRPropertyValueRec, *RRPropertyValuePtr; -typedef struct _rrProperty RRPropertyRec, *RRPropertyPtr; -typedef struct _rrCrtc RRCrtcRec, *RRCrtcPtr; -typedef struct _rrOutput RROutputRec, *RROutputPtr; +typedef struct _rrMode RRModeRec, *RRModePtr; +typedef struct _rrPropertyValue RRPropertyValueRec, *RRPropertyValuePtr; +typedef struct _rrProperty RRPropertyRec, *RRPropertyPtr; +typedef struct _rrCrtc RRCrtcRec, *RRCrtcPtr; +typedef struct _rrOutput RROutputRec, *RROutputPtr; struct _rrMode { - int refcnt; - xRRModeInfo mode; - char *name; - ScreenPtr userScreen; + int refcnt; + xRRModeInfo mode; + char *name; + ScreenPtr userScreen; }; struct _rrPropertyValue { - Atom type; /* ignored by server */ - short format; /* format of data for swapping - 8,16,32 */ - long size; /* size of data in (format/8) bytes */ - pointer data; /* private to client */ + Atom type; /* ignored by server */ + short format; /* format of data for swapping - 8,16,32 */ + long size; /* size of data in (format/8) bytes */ + pointer data; /* private to client */ }; struct _rrProperty { - RRPropertyPtr next; - ATOM propertyName; - Bool is_pending; - Bool range; - Bool immutable; - int num_valid; - INT32 *valid_values; - RRPropertyValueRec current, pending; + RRPropertyPtr next; + ATOM propertyName; + Bool is_pending; + Bool range; + Bool immutable; + int num_valid; + INT32 *valid_values; + RRPropertyValueRec current, pending; }; struct _rrCrtc { - RRCrtc id; - ScreenPtr pScreen; - RRModePtr mode; - int x, y; - Rotation rotation; - Rotation rotations; - Bool changed; - int numOutputs; - RROutputPtr *outputs; - int gammaSize; - CARD16 *gammaRed; - CARD16 *gammaBlue; - CARD16 *gammaGreen; - void *devPrivate; - Bool transforms; - RRTransformRec client_pending_transform; - RRTransformRec client_current_transform; - PictTransform transform; + RRCrtc id; + ScreenPtr pScreen; + RRModePtr mode; + int x, y; + Rotation rotation; + Rotation rotations; + Bool changed; + int numOutputs; + RROutputPtr *outputs; + int gammaSize; + CARD16 *gammaRed; + CARD16 *gammaBlue; + CARD16 *gammaGreen; + void *devPrivate; + Bool transforms; + RRTransformRec client_pending_transform; + RRTransformRec client_current_transform; + PictTransform transform; struct pict_f_transform f_transform; struct pict_f_transform f_inverse; }; struct _rrOutput { - RROutput id; - ScreenPtr pScreen; - char *name; - int nameLength; - CARD8 connection; - CARD8 subpixelOrder; - int mmWidth; - int mmHeight; - RRCrtcPtr crtc; - int numCrtcs; - RRCrtcPtr *crtcs; - int numClones; - RROutputPtr *clones; - int numModes; - int numPreferred; - RRModePtr *modes; - int numUserModes; - RRModePtr *userModes; - Bool changed; - RRPropertyPtr properties; - Bool pendingProperties; - void *devPrivate; + RROutput id; + ScreenPtr pScreen; + char *name; + int nameLength; + CARD8 connection; + CARD8 subpixelOrder; + int mmWidth; + int mmHeight; + RRCrtcPtr crtc; + int numCrtcs; + RRCrtcPtr *crtcs; + int numClones; + RROutputPtr *clones; + int numModes; + int numPreferred; + RRModePtr *modes; + int numUserModes; + RRModePtr *userModes; + Bool changed; + RRPropertyPtr properties; + Bool pendingProperties; + void *devPrivate; }; #if RANDR_12_INTERFACE -typedef Bool (*RRScreenSetSizeProcPtr) (ScreenPtr pScreen, - CARD16 width, - CARD16 height, - CARD32 mmWidth, - CARD32 mmHeight); - -typedef Bool (*RRCrtcSetProcPtr) (ScreenPtr pScreen, - RRCrtcPtr crtc, - RRModePtr mode, - int x, - int y, - Rotation rotation, - int numOutputs, - RROutputPtr *outputs); - -typedef Bool (*RRCrtcSetGammaProcPtr) (ScreenPtr pScreen, - RRCrtcPtr crtc); - -typedef Bool (*RRCrtcGetGammaProcPtr) (ScreenPtr pScreen, - RRCrtcPtr crtc); - -typedef Bool (*RROutputSetPropertyProcPtr) (ScreenPtr pScreen, - RROutputPtr output, - Atom property, - RRPropertyValuePtr value); - -typedef Bool (*RROutputValidateModeProcPtr) (ScreenPtr pScreen, - RROutputPtr output, - RRModePtr mode); - -typedef void (*RRModeDestroyProcPtr) (ScreenPtr pScreen, - RRModePtr mode); +typedef Bool (*RRScreenSetSizeProcPtr) (ScreenPtr pScreen, + CARD16 width, + CARD16 height, + CARD32 mmWidth, CARD32 mmHeight); + +typedef Bool (*RRCrtcSetProcPtr) (ScreenPtr pScreen, + RRCrtcPtr crtc, + RRModePtr mode, + int x, + int y, + Rotation rotation, + int numOutputs, RROutputPtr * outputs); + +typedef Bool (*RRCrtcSetGammaProcPtr) (ScreenPtr pScreen, RRCrtcPtr crtc); + +typedef Bool (*RRCrtcGetGammaProcPtr) (ScreenPtr pScreen, RRCrtcPtr crtc); + +typedef Bool (*RROutputSetPropertyProcPtr) (ScreenPtr pScreen, + RROutputPtr output, + Atom property, + RRPropertyValuePtr value); + +typedef Bool (*RROutputValidateModeProcPtr) (ScreenPtr pScreen, + RROutputPtr output, + RRModePtr mode); + +typedef void (*RRModeDestroyProcPtr) (ScreenPtr pScreen, RRModePtr mode); #endif #if RANDR_13_INTERFACE -typedef Bool (*RROutputGetPropertyProcPtr) (ScreenPtr pScreen, - RROutputPtr output, - Atom property); -typedef Bool (*RRGetPanningProcPtr) (ScreenPtr pScrn, - RRCrtcPtr crtc, - BoxPtr totalArea, - BoxPtr trackingArea, - INT16 *border); -typedef Bool (*RRSetPanningProcPtr) (ScreenPtr pScrn, - RRCrtcPtr crtc, - BoxPtr totalArea, - BoxPtr trackingArea, - INT16 *border); - -#endif /* RANDR_13_INTERFACE */ - -typedef Bool (*RRGetInfoProcPtr) (ScreenPtr pScreen, Rotation *rotations); -typedef Bool (*RRCloseScreenProcPtr) ( int i, ScreenPtr pscreen); +typedef Bool (*RROutputGetPropertyProcPtr) (ScreenPtr pScreen, + RROutputPtr output, Atom property); +typedef Bool (*RRGetPanningProcPtr) (ScreenPtr pScrn, + RRCrtcPtr crtc, + BoxPtr totalArea, + BoxPtr trackingArea, INT16 *border); +typedef Bool (*RRSetPanningProcPtr) (ScreenPtr pScrn, + RRCrtcPtr crtc, + BoxPtr totalArea, + BoxPtr trackingArea, INT16 *border); + +#endif /* RANDR_13_INTERFACE */ + +typedef Bool (*RRGetInfoProcPtr) (ScreenPtr pScreen, Rotation * rotations); +typedef Bool (*RRCloseScreenProcPtr) (int i, ScreenPtr pscreen); /* These are for 1.0 compatibility */ - + typedef struct _rrRefresh { - CARD16 rate; - RRModePtr mode; + CARD16 rate; + RRModePtr mode; } RRScreenRate, *RRScreenRatePtr; typedef struct _rrScreenSize { - int id; - short width, height; - short mmWidth, mmHeight; - int nRates; + int id; + short width, height; + short mmWidth, mmHeight; + int nRates; RRScreenRatePtr pRates; } RRScreenSize, *RRScreenSizePtr; #ifdef RANDR_10_INTERFACE -typedef Bool (*RRSetConfigProcPtr) (ScreenPtr pScreen, - Rotation rotation, - int rate, - RRScreenSizePtr pSize); +typedef Bool (*RRSetConfigProcPtr) (ScreenPtr pScreen, + Rotation rotation, + int rate, RRScreenSizePtr pSize); #endif - typedef struct _rrScrPriv { /* @@ -239,68 +229,69 @@ typedef struct _rrScrPriv { * as they initialize */ #if RANDR_10_INTERFACE - RRSetConfigProcPtr rrSetConfig; + RRSetConfigProcPtr rrSetConfig; #endif - RRGetInfoProcPtr rrGetInfo; + RRGetInfoProcPtr rrGetInfo; #if RANDR_12_INTERFACE - RRScreenSetSizeProcPtr rrScreenSetSize; - RRCrtcSetProcPtr rrCrtcSet; - RRCrtcSetGammaProcPtr rrCrtcSetGamma; - RRCrtcGetGammaProcPtr rrCrtcGetGamma; - RROutputSetPropertyProcPtr rrOutputSetProperty; - RROutputValidateModeProcPtr rrOutputValidateMode; - RRModeDestroyProcPtr rrModeDestroy; + RRScreenSetSizeProcPtr rrScreenSetSize; + RRCrtcSetProcPtr rrCrtcSet; + RRCrtcSetGammaProcPtr rrCrtcSetGamma; + RRCrtcGetGammaProcPtr rrCrtcGetGamma; + RROutputSetPropertyProcPtr rrOutputSetProperty; + RROutputValidateModeProcPtr rrOutputValidateMode; + RRModeDestroyProcPtr rrModeDestroy; #endif #if RANDR_13_INTERFACE - RROutputGetPropertyProcPtr rrOutputGetProperty; - RRGetPanningProcPtr rrGetPanning; - RRSetPanningProcPtr rrSetPanning; + RROutputGetPropertyProcPtr rrOutputGetProperty; + RRGetPanningProcPtr rrGetPanning; + RRSetPanningProcPtr rrSetPanning; #endif - + /* * Private part of the structure; not considered part of the ABI */ - TimeStamp lastSetTime; /* last changed by client */ - TimeStamp lastConfigTime; /* possible configs changed */ - RRCloseScreenProcPtr CloseScreen; + TimeStamp lastSetTime; /* last changed by client */ + TimeStamp lastConfigTime; /* possible configs changed */ + RRCloseScreenProcPtr CloseScreen; - Bool changed; /* some config changed */ - Bool configChanged; /* configuration changed */ - Bool layoutChanged; /* screen layout changed */ + Bool changed; /* some config changed */ + Bool configChanged; /* configuration changed */ + Bool layoutChanged; /* screen layout changed */ - CARD16 minWidth, minHeight; - CARD16 maxWidth, maxHeight; - CARD16 width, height; /* last known screen size */ - CARD16 mmWidth, mmHeight; /* last known screen size */ + CARD16 minWidth, minHeight; + CARD16 maxWidth, maxHeight; + CARD16 width, height; /* last known screen size */ + CARD16 mmWidth, mmHeight; /* last known screen size */ - int numOutputs; - RROutputPtr *outputs; - RROutputPtr primaryOutput; + int numOutputs; + RROutputPtr *outputs; + RROutputPtr primaryOutput; - int numCrtcs; - RRCrtcPtr *crtcs; + int numCrtcs; + RRCrtcPtr *crtcs; /* Last known pointer position */ - RRCrtcPtr pointerCrtc; + RRCrtcPtr pointerCrtc; #ifdef RANDR_10_INTERFACE /* * Configuration information */ - Rotation rotations; - CARD16 reqWidth, reqHeight; - - int nSizes; - RRScreenSizePtr pSizes; - - Rotation rotation; - int rate; - int size; + Rotation rotations; + CARD16 reqWidth, reqHeight; + + int nSizes; + RRScreenSizePtr pSizes; + + Rotation rotation; + int rate; + int size; #endif - Bool discontiguous; + Bool discontiguous; } rrScrPrivRec, *rrScrPrivPtr; extern _X_EXPORT DevPrivateKeyRec rrPrivKeyRec; + #define rrPrivKey (&rrPrivKeyRec) #define rrGetScrPriv(pScr) ((rrScrPrivPtr)dixLookupPrivate(&(pScr)->devPrivates, rrPrivKey)) @@ -318,26 +309,27 @@ extern _X_EXPORT DevPrivateKeyRec rrPrivKeyRec; typedef struct _RREvent *RREventPtr; typedef struct _RREvent { - RREventPtr next; - ClientPtr client; - WindowPtr window; - XID clientResource; - int mask; + RREventPtr next; + ClientPtr client; + WindowPtr window; + XID clientResource; + int mask; } RREventRec; typedef struct _RRTimes { - TimeStamp setTime; - TimeStamp configTime; + TimeStamp setTime; + TimeStamp configTime; } RRTimesRec, *RRTimesPtr; typedef struct _RRClient { - int major_version; - int minor_version; + int major_version; + int minor_version; /* RRTimesRec times[0]; */ } RRClientRec, *RRClientPtr; -extern _X_EXPORT RESTYPE RRClientType, RREventType; /* resource types for event masks */ +extern _X_EXPORT RESTYPE RRClientType, RREventType; /* resource types for event masks */ extern _X_EXPORT DevPrivateKeyRec RRClientPrivateKeyRec; + #define RRClientPrivateKey (&RRClientPrivateKeyRec) extern _X_EXPORT RESTYPE RRCrtcType, RRModeType, RROutputType; @@ -376,18 +368,17 @@ extern _X_EXPORT RESTYPE RRCrtcType, RRModeType, RROutputType; /* Initialize the extension */ extern _X_EXPORT void -RRExtensionInit (void); + RRExtensionInit(void); #ifdef RANDR_12_INTERFACE /* * Set the range of sizes for the screen */ extern _X_EXPORT void -RRScreenSetSizeRange (ScreenPtr pScreen, - CARD16 minWidth, - CARD16 minHeight, - CARD16 maxWidth, - CARD16 maxHeight); + +RRScreenSetSizeRange(ScreenPtr pScreen, + CARD16 minWidth, + CARD16 minHeight, CARD16 maxWidth, CARD16 maxHeight); #endif /* rrscreen.c */ @@ -397,75 +388,72 @@ RRScreenSetSizeRange (ScreenPtr pScreen, * the size of the screen */ extern _X_EXPORT void -RRScreenSizeNotify (ScreenPtr pScreen); + RRScreenSizeNotify(ScreenPtr pScreen); /* * Request that the screen be resized */ extern _X_EXPORT Bool -RRScreenSizeSet (ScreenPtr pScreen, - CARD16 width, - CARD16 height, - CARD32 mmWidth, - CARD32 mmHeight); + +RRScreenSizeSet(ScreenPtr pScreen, + CARD16 width, CARD16 height, CARD32 mmWidth, CARD32 mmHeight); /* * Send ConfigureNotify event to root window when 'something' happens */ extern _X_EXPORT void -RRSendConfigNotify (ScreenPtr pScreen); - + RRSendConfigNotify(ScreenPtr pScreen); + /* * screen dispatch */ extern _X_EXPORT int -ProcRRGetScreenSizeRange (ClientPtr client); + ProcRRGetScreenSizeRange(ClientPtr client); extern _X_EXPORT int -ProcRRSetScreenSize (ClientPtr client); + ProcRRSetScreenSize(ClientPtr client); extern _X_EXPORT int -ProcRRGetScreenResources (ClientPtr client); + ProcRRGetScreenResources(ClientPtr client); extern _X_EXPORT int -ProcRRGetScreenResourcesCurrent (ClientPtr client); + ProcRRGetScreenResourcesCurrent(ClientPtr client); extern _X_EXPORT int -ProcRRSetScreenConfig (ClientPtr client); + ProcRRSetScreenConfig(ClientPtr client); extern _X_EXPORT int -ProcRRGetScreenInfo (ClientPtr client); + ProcRRGetScreenInfo(ClientPtr client); /* * Deliver a ScreenNotify event */ extern _X_EXPORT void -RRDeliverScreenEvent (ClientPtr client, WindowPtr pWin, ScreenPtr pScreen); - + RRDeliverScreenEvent(ClientPtr client, WindowPtr pWin, ScreenPtr pScreen); + /* randr.c */ /* * Send all pending events */ extern _X_EXPORT void -RRTellChanged (ScreenPtr pScreen); + RRTellChanged(ScreenPtr pScreen); /* * Poll the driver for changed information */ extern _X_EXPORT Bool -RRGetInfo (ScreenPtr pScreen, Bool force_query); + RRGetInfo(ScreenPtr pScreen, Bool force_query); -extern _X_EXPORT Bool RRInit (void); +extern _X_EXPORT Bool RRInit(void); extern _X_EXPORT Bool RRScreenInit(ScreenPtr pScreen); -extern _X_EXPORT RROutputPtr -RRFirstOutput (ScreenPtr pScreen); +extern _X_EXPORT RROutputPtr RRFirstOutput(ScreenPtr pScreen); extern _X_EXPORT CARD16 -RRVerticalRefresh (xRRModeInfo *mode); + RRVerticalRefresh(xRRModeInfo * mode); -#ifdef RANDR_10_INTERFACE +#ifdef RANDR_10_INTERFACE /* * This is the old interface, deprecated but left * around for compatibility @@ -476,31 +464,24 @@ RRVerticalRefresh (xRRModeInfo *mode); */ extern _X_EXPORT RRScreenSizePtr -RRRegisterSize (ScreenPtr pScreen, - short width, - short height, - short mmWidth, - short mmHeight); +RRRegisterSize(ScreenPtr pScreen, + short width, short height, short mmWidth, short mmHeight); extern _X_EXPORT Bool -RRRegisterRate (ScreenPtr pScreen, - RRScreenSizePtr pSize, - int rate); + RRRegisterRate(ScreenPtr pScreen, RRScreenSizePtr pSize, int rate); /* * Finally, set the current configuration of the screen */ extern _X_EXPORT void -RRSetCurrentConfig (ScreenPtr pScreen, - Rotation rotation, - int rate, - RRScreenSizePtr pSize); -extern _X_EXPORT Rotation -RRGetRotation (ScreenPtr pScreen); +RRSetCurrentConfig(ScreenPtr pScreen, + Rotation rotation, int rate, RRScreenSizePtr pSize); + +extern _X_EXPORT Rotation RRGetRotation(ScreenPtr pScreen); -#endif +#endif /* rrcrtc.c */ @@ -509,72 +490,65 @@ RRGetRotation (ScreenPtr pScreen); * some position or size element changed */ extern _X_EXPORT void -RRCrtcChanged (RRCrtcPtr crtc, Bool layoutChanged); + RRCrtcChanged(RRCrtcPtr crtc, Bool layoutChanged); /* * Create a CRTC */ -extern _X_EXPORT RRCrtcPtr -RRCrtcCreate (ScreenPtr pScreen, void *devPrivate); +extern _X_EXPORT RRCrtcPtr RRCrtcCreate(ScreenPtr pScreen, void *devPrivate); /* * Set the allowed rotations on a CRTC */ extern _X_EXPORT void -RRCrtcSetRotations (RRCrtcPtr crtc, Rotation rotations); + RRCrtcSetRotations(RRCrtcPtr crtc, Rotation rotations); /* * Set whether transforms are allowed on a CRTC */ extern _X_EXPORT void -RRCrtcSetTransformSupport (RRCrtcPtr crtc, Bool transforms); + RRCrtcSetTransformSupport(RRCrtcPtr crtc, Bool transforms); /* * Notify the extension that the Crtc has been reconfigured, * the driver calls this whenever it has updated the mode */ extern _X_EXPORT Bool -RRCrtcNotify (RRCrtcPtr crtc, - RRModePtr mode, - int x, - int y, - Rotation rotation, - RRTransformPtr transform, - int numOutputs, - RROutputPtr *outputs); + +RRCrtcNotify(RRCrtcPtr crtc, + RRModePtr mode, + int x, + int y, + Rotation rotation, + RRTransformPtr transform, int numOutputs, RROutputPtr * outputs); extern _X_EXPORT void -RRDeliverCrtcEvent (ClientPtr client, WindowPtr pWin, RRCrtcPtr crtc); - + RRDeliverCrtcEvent(ClientPtr client, WindowPtr pWin, RRCrtcPtr crtc); + /* * Request that the Crtc be reconfigured */ extern _X_EXPORT Bool -RRCrtcSet (RRCrtcPtr crtc, - RRModePtr mode, - int x, - int y, - Rotation rotation, - int numOutput, - RROutputPtr *outputs); + +RRCrtcSet(RRCrtcPtr crtc, + RRModePtr mode, + int x, + int y, Rotation rotation, int numOutput, RROutputPtr * outputs); /* * Request that the Crtc gamma be changed */ extern _X_EXPORT Bool -RRCrtcGammaSet (RRCrtcPtr crtc, - CARD16 *red, - CARD16 *green, - CARD16 *blue); + RRCrtcGammaSet(RRCrtcPtr crtc, CARD16 *red, CARD16 *green, CARD16 *blue); /* * Request current gamma back from the DDX (if possible). * This includes gamma size. */ - + extern _X_EXPORT Bool -RRCrtcGammaGet(RRCrtcPtr crtc); + RRCrtcGammaGet(RRCrtcPtr crtc); /* * Notify the extension that the Crtc gamma has been changed @@ -583,15 +557,14 @@ RRCrtcGammaGet(RRCrtcPtr crtc); */ extern _X_EXPORT Bool -RRCrtcGammaNotify (RRCrtcPtr crtc); + RRCrtcGammaNotify(RRCrtcPtr crtc); /* * Set the size of the gamma table at server startup time */ extern _X_EXPORT Bool -RRCrtcGammaSetSize (RRCrtcPtr crtc, - int size); + RRCrtcGammaSetSize(RRCrtcPtr crtc, int size); /* * Return the area of the frame buffer scanned out by the crtc, @@ -599,7 +572,7 @@ RRCrtcGammaSetSize (RRCrtcPtr crtc, */ extern _X_EXPORT void -RRCrtcGetScanoutSize(RRCrtcPtr crtc, int *width, int *height); + RRCrtcGetScanoutSize(RRCrtcPtr crtc, int *width, int *height); /* * Compute the complete transformation matrix including @@ -609,145 +582,138 @@ RRCrtcGetScanoutSize(RRCrtcPtr crtc, int *width, int *height); * Return TRUE if the resulting transform is not a simple translation. */ extern _X_EXPORT Bool -RRTransformCompute (int x, - int y, - int width, - int height, - Rotation rotation, - RRTransformPtr rr_transform, - PictTransformPtr transform, - struct pict_f_transform *f_transform, - struct pict_f_transform *f_inverse); +RRTransformCompute(int x, + int y, + int width, + int height, + Rotation rotation, + RRTransformPtr rr_transform, + PictTransformPtr transform, + struct pict_f_transform *f_transform, + struct pict_f_transform *f_inverse); /* * Return crtc transform */ -extern _X_EXPORT RRTransformPtr -RRCrtcGetTransform (RRCrtcPtr crtc); +extern _X_EXPORT RRTransformPtr RRCrtcGetTransform(RRCrtcPtr crtc); /* * Check whether the pending and current transforms are the same */ extern _X_EXPORT Bool -RRCrtcPendingTransform (RRCrtcPtr crtc); + RRCrtcPendingTransform(RRCrtcPtr crtc); /* * Destroy a Crtc at shutdown */ extern _X_EXPORT void -RRCrtcDestroy (RRCrtcPtr crtc); - + RRCrtcDestroy(RRCrtcPtr crtc); /* * Set the pending CRTC transformation */ extern _X_EXPORT int -RRCrtcTransformSet (RRCrtcPtr crtc, - PictTransformPtr transform, - struct pict_f_transform *f_transform, - struct pict_f_transform *f_inverse, - char *filter, - int filter_len, - xFixed *params, - int nparams); + +RRCrtcTransformSet(RRCrtcPtr crtc, + PictTransformPtr transform, + struct pict_f_transform *f_transform, + struct pict_f_transform *f_inverse, + char *filter, int filter_len, xFixed * params, int nparams); /* * Initialize crtc type */ extern _X_EXPORT Bool -RRCrtcInit (void); + RRCrtcInit(void); /* * Initialize crtc type error value */ extern _X_EXPORT void -RRCrtcInitErrorValue (void); + RRCrtcInitErrorValue(void); /* * Crtc dispatch */ extern _X_EXPORT int -ProcRRGetCrtcInfo (ClientPtr client); + ProcRRGetCrtcInfo(ClientPtr client); extern _X_EXPORT int -ProcRRSetCrtcConfig (ClientPtr client); + ProcRRSetCrtcConfig(ClientPtr client); extern _X_EXPORT int -ProcRRGetCrtcGammaSize (ClientPtr client); + ProcRRGetCrtcGammaSize(ClientPtr client); extern _X_EXPORT int -ProcRRGetCrtcGamma (ClientPtr client); + ProcRRGetCrtcGamma(ClientPtr client); extern _X_EXPORT int -ProcRRSetCrtcGamma (ClientPtr client); + ProcRRSetCrtcGamma(ClientPtr client); extern _X_EXPORT int -ProcRRSetCrtcTransform (ClientPtr client); + ProcRRSetCrtcTransform(ClientPtr client); extern _X_EXPORT int -ProcRRGetCrtcTransform (ClientPtr client); + ProcRRGetCrtcTransform(ClientPtr client); int -ProcRRGetPanning (ClientPtr client); + ProcRRGetPanning(ClientPtr client); int -ProcRRSetPanning (ClientPtr client); + ProcRRSetPanning(ClientPtr client); void -RRConstrainCursorHarder (DeviceIntPtr, ScreenPtr, int, int *, int *); + RRConstrainCursorHarder(DeviceIntPtr, ScreenPtr, int, int *, int *); /* rrdispatch.c */ extern _X_EXPORT Bool -RRClientKnowsRates (ClientPtr pClient); + RRClientKnowsRates(ClientPtr pClient); /* rrmode.c */ /* * Find, and if necessary, create a mode */ -extern _X_EXPORT RRModePtr -RRModeGet (xRRModeInfo *modeInfo, - const char *name); +extern _X_EXPORT RRModePtr RRModeGet(xRRModeInfo * modeInfo, const char *name); /* * Destroy a mode. */ extern _X_EXPORT void -RRModeDestroy (RRModePtr mode); + RRModeDestroy(RRModePtr mode); /* * Return a list of modes that are valid for some output in pScreen */ -extern _X_EXPORT RRModePtr * -RRModesForScreen (ScreenPtr pScreen, int *num_ret); - +extern _X_EXPORT RRModePtr *RRModesForScreen(ScreenPtr pScreen, int *num_ret); + /* * Initialize mode type */ extern _X_EXPORT Bool -RRModeInit (void); + RRModeInit(void); /* * Initialize mode type error value */ extern _X_EXPORT void -RRModeInitErrorValue (void); - + RRModeInitErrorValue(void); + extern _X_EXPORT int -ProcRRCreateMode (ClientPtr client); + ProcRRCreateMode(ClientPtr client); extern _X_EXPORT int -ProcRRDestroyMode (ClientPtr client); + ProcRRDestroyMode(ClientPtr client); extern _X_EXPORT int -ProcRRAddOutputMode (ClientPtr client); + ProcRRAddOutputMode(ClientPtr client); extern _X_EXPORT int -ProcRRDeleteOutputMode (ClientPtr client); + ProcRRDeleteOutputMode(ClientPtr client); /* rroutput.c */ @@ -758,143 +724,132 @@ ProcRRDeleteOutputMode (ClientPtr client); * (which crtc is in use) */ extern _X_EXPORT void -RROutputChanged (RROutputPtr output, Bool configChanged); + RROutputChanged(RROutputPtr output, Bool configChanged); /* * Create an output */ extern _X_EXPORT RROutputPtr -RROutputCreate (ScreenPtr pScreen, - const char *name, - int nameLength, - void *devPrivate); +RROutputCreate(ScreenPtr pScreen, + const char *name, int nameLength, void *devPrivate); /* * Notify extension that output parameters have been changed */ extern _X_EXPORT Bool -RROutputSetClones (RROutputPtr output, - RROutputPtr *clones, - int numClones); + RROutputSetClones(RROutputPtr output, RROutputPtr * clones, int numClones); extern _X_EXPORT Bool -RROutputSetModes (RROutputPtr output, - RRModePtr *modes, - int numModes, - int numPreferred); + +RROutputSetModes(RROutputPtr output, + RRModePtr * modes, int numModes, int numPreferred); extern _X_EXPORT int -RROutputAddUserMode (RROutputPtr output, - RRModePtr mode); + RROutputAddUserMode(RROutputPtr output, RRModePtr mode); extern _X_EXPORT int -RROutputDeleteUserMode (RROutputPtr output, - RRModePtr mode); + RROutputDeleteUserMode(RROutputPtr output, RRModePtr mode); extern _X_EXPORT Bool -RROutputSetCrtcs (RROutputPtr output, - RRCrtcPtr *crtcs, - int numCrtcs); + RROutputSetCrtcs(RROutputPtr output, RRCrtcPtr * crtcs, int numCrtcs); extern _X_EXPORT Bool -RROutputSetConnection (RROutputPtr output, - CARD8 connection); + RROutputSetConnection(RROutputPtr output, CARD8 connection); extern _X_EXPORT Bool -RROutputSetSubpixelOrder (RROutputPtr output, - int subpixelOrder); + RROutputSetSubpixelOrder(RROutputPtr output, int subpixelOrder); extern _X_EXPORT Bool -RROutputSetPhysicalSize (RROutputPtr output, - int mmWidth, - int mmHeight); + RROutputSetPhysicalSize(RROutputPtr output, int mmWidth, int mmHeight); extern _X_EXPORT void -RRDeliverOutputEvent(ClientPtr client, WindowPtr pWin, RROutputPtr output); + RRDeliverOutputEvent(ClientPtr client, WindowPtr pWin, RROutputPtr output); extern _X_EXPORT void -RROutputDestroy (RROutputPtr output); + RROutputDestroy(RROutputPtr output); extern _X_EXPORT int -ProcRRGetOutputInfo (ClientPtr client); + ProcRRGetOutputInfo(ClientPtr client); extern _X_EXPORT int -ProcRRSetOutputPrimary (ClientPtr client); + ProcRRSetOutputPrimary(ClientPtr client); extern _X_EXPORT int -ProcRRGetOutputPrimary (ClientPtr client); + ProcRRGetOutputPrimary(ClientPtr client); /* * Initialize output type */ extern _X_EXPORT Bool -RROutputInit (void); + RROutputInit(void); /* * Initialize output type error value */ extern _X_EXPORT void -RROutputInitErrorValue (void); - + RROutputInitErrorValue(void); + /* rrpointer.c */ extern _X_EXPORT void -RRPointerMoved (ScreenPtr pScreen, int x, int y); + RRPointerMoved(ScreenPtr pScreen, int x, int y); extern _X_EXPORT void -RRPointerScreenConfigured (ScreenPtr pScreen); + RRPointerScreenConfigured(ScreenPtr pScreen); /* rrproperty.c */ extern _X_EXPORT void -RRDeleteAllOutputProperties (RROutputPtr output); + RRDeleteAllOutputProperties(RROutputPtr output); extern _X_EXPORT RRPropertyValuePtr -RRGetOutputProperty (RROutputPtr output, Atom property, Bool pending); +RRGetOutputProperty(RROutputPtr output, Atom property, Bool pending); extern _X_EXPORT RRPropertyPtr -RRQueryOutputProperty (RROutputPtr output, Atom property); - +RRQueryOutputProperty(RROutputPtr output, Atom property); + extern _X_EXPORT void -RRDeleteOutputProperty (RROutputPtr output, Atom property); + RRDeleteOutputProperty(RROutputPtr output, Atom property); extern _X_EXPORT Bool -RRPostPendingProperties (RROutputPtr output); - + RRPostPendingProperties(RROutputPtr output); + extern _X_EXPORT int -RRChangeOutputProperty (RROutputPtr output, Atom property, Atom type, - int format, int mode, unsigned long len, - pointer value, Bool sendevent, Bool pending); + +RRChangeOutputProperty(RROutputPtr output, Atom property, Atom type, + int format, int mode, unsigned long len, + pointer value, Bool sendevent, Bool pending); extern _X_EXPORT int -RRConfigureOutputProperty (RROutputPtr output, Atom property, - Bool pending, Bool range, Bool immutable, - int num_values, INT32 *values); + +RRConfigureOutputProperty(RROutputPtr output, Atom property, + Bool pending, Bool range, Bool immutable, + int num_values, INT32 *values); extern _X_EXPORT int -ProcRRChangeOutputProperty (ClientPtr client); + ProcRRChangeOutputProperty(ClientPtr client); extern _X_EXPORT int -ProcRRGetOutputProperty (ClientPtr client); + ProcRRGetOutputProperty(ClientPtr client); extern _X_EXPORT int -ProcRRListOutputProperties (ClientPtr client); + ProcRRListOutputProperties(ClientPtr client); extern _X_EXPORT int -ProcRRQueryOutputProperty (ClientPtr client); + ProcRRQueryOutputProperty(ClientPtr client); extern _X_EXPORT int -ProcRRConfigureOutputProperty (ClientPtr client); + ProcRRConfigureOutputProperty(ClientPtr client); extern _X_EXPORT int -ProcRRDeleteOutputProperty (ClientPtr client); + ProcRRDeleteOutputProperty(ClientPtr client); /* rrxinerama.c */ #ifdef XINERAMA extern _X_EXPORT void -RRXineramaExtensionInit(void); + RRXineramaExtensionInit(void); #endif -#endif /* _RANDRSTR_H_ */ +#endif /* _RANDRSTR_H_ */ /* diff --git a/xorg-server/randr/rrcrtc.c b/xorg-server/randr/rrcrtc.c index 13dd7da7c..36caa5822 100644 --- a/xorg-server/randr/rrcrtc.c +++ b/xorg-server/randr/rrcrtc.c @@ -25,27 +25,26 @@ #include "swaprep.h" #include "mipointer.h" -RESTYPE RRCrtcType; +RESTYPE RRCrtcType; /* * Notify the CRTC of some change */ void -RRCrtcChanged (RRCrtcPtr crtc, Bool layoutChanged) +RRCrtcChanged(RRCrtcPtr crtc, Bool layoutChanged) { - ScreenPtr pScreen = crtc->pScreen; + ScreenPtr pScreen = crtc->pScreen; crtc->changed = TRUE; - if (pScreen) - { - rrScrPriv(pScreen); - - pScrPriv->changed = TRUE; - /* - * Send ConfigureNotify on any layout change - */ - if (layoutChanged) - pScrPriv->layoutChanged = TRUE; + if (pScreen) { + rrScrPriv(pScreen); + + pScrPriv->changed = TRUE; + /* + * Send ConfigureNotify on any layout change + */ + if (layoutChanged) + pScrPriv->layoutChanged = TRUE; } } @@ -53,31 +52,31 @@ RRCrtcChanged (RRCrtcPtr crtc, Bool layoutChanged) * Create a CRTC */ RRCrtcPtr -RRCrtcCreate (ScreenPtr pScreen, void *devPrivate) +RRCrtcCreate(ScreenPtr pScreen, void *devPrivate) { - RRCrtcPtr crtc; - RRCrtcPtr *crtcs; - rrScrPrivPtr pScrPriv; + RRCrtcPtr crtc; + RRCrtcPtr *crtcs; + rrScrPrivPtr pScrPriv; if (!RRInit()) - return NULL; - + return NULL; + pScrPriv = rrGetScrPriv(pScreen); /* make space for the crtc pointer */ if (pScrPriv->numCrtcs) - crtcs = realloc(pScrPriv->crtcs, - (pScrPriv->numCrtcs + 1) * sizeof (RRCrtcPtr)); + crtcs = realloc(pScrPriv->crtcs, + (pScrPriv->numCrtcs + 1) * sizeof(RRCrtcPtr)); else - crtcs = malloc(sizeof (RRCrtcPtr)); + crtcs = malloc(sizeof(RRCrtcPtr)); if (!crtcs) - return FALSE; + return FALSE; pScrPriv->crtcs = crtcs; - - crtc = calloc(1, sizeof (RRCrtcRec)); + + crtc = calloc(1, sizeof(RRCrtcRec)); if (!crtc) - return NULL; - crtc->id = FakeClientID (0); + return NULL; + crtc->id = FakeClientID(0); crtc->pScreen = pScreen; crtc->mode = NULL; crtc->x = 0; @@ -90,19 +89,19 @@ RRCrtcCreate (ScreenPtr pScreen, void *devPrivate) crtc->gammaRed = crtc->gammaBlue = crtc->gammaGreen = NULL; crtc->changed = FALSE; crtc->devPrivate = devPrivate; - RRTransformInit (&crtc->client_pending_transform); - RRTransformInit (&crtc->client_current_transform); - pixman_transform_init_identity (&crtc->transform); - pixman_f_transform_init_identity (&crtc->f_transform); - pixman_f_transform_init_identity (&crtc->f_inverse); + RRTransformInit(&crtc->client_pending_transform); + RRTransformInit(&crtc->client_current_transform); + pixman_transform_init_identity(&crtc->transform); + pixman_f_transform_init_identity(&crtc->f_transform); + pixman_f_transform_init_identity(&crtc->f_inverse); - if (!AddResource (crtc->id, RRCrtcType, (pointer) crtc)) - return NULL; + if (!AddResource(crtc->id, RRCrtcType, (pointer) crtc)) + return NULL; /* attach the screen and crtc together */ crtc->pScreen = pScreen; pScrPriv->crtcs[pScrPriv->numCrtcs++] = crtc; - + return crtc; } @@ -110,7 +109,7 @@ RRCrtcCreate (ScreenPtr pScreen, void *devPrivate) * Set the allowed rotations on a CRTC */ void -RRCrtcSetRotations (RRCrtcPtr crtc, Rotation rotations) +RRCrtcSetRotations(RRCrtcPtr crtc, Rotation rotations) { crtc->rotations = rotations; } @@ -119,7 +118,7 @@ RRCrtcSetRotations (RRCrtcPtr crtc, Rotation rotations) * Set whether transforms are allowed on a CRTC */ void -RRCrtcSetTransformSupport (RRCrtcPtr crtc, Bool transforms) +RRCrtcSetTransformSupport(RRCrtcPtr crtc, Bool transforms) { crtc->transforms = transforms; } @@ -129,167 +128,153 @@ RRCrtcSetTransformSupport (RRCrtcPtr crtc, Bool transforms) * the driver calls this whenever it has updated the mode */ Bool -RRCrtcNotify (RRCrtcPtr crtc, - RRModePtr mode, - int x, - int y, - Rotation rotation, - RRTransformPtr transform, - int numOutputs, - RROutputPtr *outputs) +RRCrtcNotify(RRCrtcPtr crtc, + RRModePtr mode, + int x, + int y, + Rotation rotation, + RRTransformPtr transform, int numOutputs, RROutputPtr * outputs) { - int i, j; - + int i, j; + /* * Check to see if any of the new outputs were * not in the old list and mark them as changed */ - for (i = 0; i < numOutputs; i++) - { - for (j = 0; j < crtc->numOutputs; j++) - if (outputs[i] == crtc->outputs[j]) - break; - if (j == crtc->numOutputs) - { - outputs[i]->crtc = crtc; - RROutputChanged (outputs[i], FALSE); - RRCrtcChanged (crtc, FALSE); - } + for (i = 0; i < numOutputs; i++) { + for (j = 0; j < crtc->numOutputs; j++) + if (outputs[i] == crtc->outputs[j]) + break; + if (j == crtc->numOutputs) { + outputs[i]->crtc = crtc; + RROutputChanged(outputs[i], FALSE); + RRCrtcChanged(crtc, FALSE); + } } /* * Check to see if any of the old outputs are * not in the new list and mark them as changed */ - for (j = 0; j < crtc->numOutputs; j++) - { - for (i = 0; i < numOutputs; i++) - if (outputs[i] == crtc->outputs[j]) - break; - if (i == numOutputs) - { - if (crtc->outputs[j]->crtc == crtc) - crtc->outputs[j]->crtc = NULL; - RROutputChanged (crtc->outputs[j], FALSE); - RRCrtcChanged (crtc, FALSE); - } + for (j = 0; j < crtc->numOutputs; j++) { + for (i = 0; i < numOutputs; i++) + if (outputs[i] == crtc->outputs[j]) + break; + if (i == numOutputs) { + if (crtc->outputs[j]->crtc == crtc) + crtc->outputs[j]->crtc = NULL; + RROutputChanged(crtc->outputs[j], FALSE); + RRCrtcChanged(crtc, FALSE); + } } /* * Reallocate the crtc output array if necessary */ - if (numOutputs != crtc->numOutputs) - { - RROutputPtr *newoutputs; - - if (numOutputs) - { - if (crtc->numOutputs) - newoutputs = realloc(crtc->outputs, - numOutputs * sizeof (RROutputPtr)); - else - newoutputs = malloc(numOutputs * sizeof (RROutputPtr)); - if (!newoutputs) - return FALSE; - } - else - { - free(crtc->outputs); - newoutputs = NULL; - } - crtc->outputs = newoutputs; - crtc->numOutputs = numOutputs; + if (numOutputs != crtc->numOutputs) { + RROutputPtr *newoutputs; + + if (numOutputs) { + if (crtc->numOutputs) + newoutputs = realloc(crtc->outputs, + numOutputs * sizeof(RROutputPtr)); + else + newoutputs = malloc(numOutputs * sizeof(RROutputPtr)); + if (!newoutputs) + return FALSE; + } + else { + free(crtc->outputs); + newoutputs = NULL; + } + crtc->outputs = newoutputs; + crtc->numOutputs = numOutputs; } /* * Copy the new list of outputs into the crtc */ - memcpy (crtc->outputs, outputs, numOutputs * sizeof (RROutputPtr)); + memcpy(crtc->outputs, outputs, numOutputs * sizeof(RROutputPtr)); /* * Update remaining crtc fields */ - if (mode != crtc->mode) - { - if (crtc->mode) - RRModeDestroy (crtc->mode); - crtc->mode = mode; - if (mode != NULL) - mode->refcnt++; - RRCrtcChanged (crtc, TRUE); + if (mode != crtc->mode) { + if (crtc->mode) + RRModeDestroy(crtc->mode); + crtc->mode = mode; + if (mode != NULL) + mode->refcnt++; + RRCrtcChanged(crtc, TRUE); } - if (x != crtc->x) - { - crtc->x = x; - RRCrtcChanged (crtc, TRUE); + if (x != crtc->x) { + crtc->x = x; + RRCrtcChanged(crtc, TRUE); } - if (y != crtc->y) - { - crtc->y = y; - RRCrtcChanged (crtc, TRUE); + if (y != crtc->y) { + crtc->y = y; + RRCrtcChanged(crtc, TRUE); } - if (rotation != crtc->rotation) - { - crtc->rotation = rotation; - RRCrtcChanged (crtc, TRUE); + if (rotation != crtc->rotation) { + crtc->rotation = rotation; + RRCrtcChanged(crtc, TRUE); } - if (!RRTransformEqual (transform, &crtc->client_current_transform)) { - RRTransformCopy (&crtc->client_current_transform, transform); - RRCrtcChanged (crtc, TRUE); + if (!RRTransformEqual(transform, &crtc->client_current_transform)) { + RRTransformCopy(&crtc->client_current_transform, transform); + RRCrtcChanged(crtc, TRUE); } - if (crtc->changed && mode) - { - RRTransformCompute (x, y, - mode->mode.width, mode->mode.height, - rotation, - &crtc->client_current_transform, - &crtc->transform, &crtc->f_transform, - &crtc->f_inverse); + if (crtc->changed && mode) { + RRTransformCompute(x, y, + mode->mode.width, mode->mode.height, + rotation, + &crtc->client_current_transform, + &crtc->transform, &crtc->f_transform, + &crtc->f_inverse); } return TRUE; } void -RRDeliverCrtcEvent (ClientPtr client, WindowPtr pWin, RRCrtcPtr crtc) +RRDeliverCrtcEvent(ClientPtr client, WindowPtr pWin, RRCrtcPtr crtc) { ScreenPtr pScreen = pWin->drawable.pScreen; - rrScrPriv (pScreen); - xRRCrtcChangeNotifyEvent ce; - RRModePtr mode = crtc->mode; - + + rrScrPriv(pScreen); + xRRCrtcChangeNotifyEvent ce; + RRModePtr mode = crtc->mode; + ce.type = RRNotify + RREventBase; ce.subCode = RRNotify_CrtcChange; ce.timestamp = pScrPriv->lastSetTime.milliseconds; ce.window = pWin->drawable.id; ce.crtc = crtc->id; ce.rotation = crtc->rotation; - if (mode) - { - ce.mode = mode->mode.id; - ce.x = crtc->x; - ce.y = crtc->y; - ce.width = mode->mode.width; - ce.height = mode->mode.height; + if (mode) { + ce.mode = mode->mode.id; + ce.x = crtc->x; + ce.y = crtc->y; + ce.width = mode->mode.width; + ce.height = mode->mode.height; } - else - { - ce.mode = None; - ce.x = 0; - ce.y = 0; - ce.width = 0; - ce.height = 0; + else { + ce.mode = None; + ce.x = 0; + ce.y = 0; + ce.width = 0; + ce.height = 0; } - WriteEventsToClient (client, 1, (xEvent *) &ce); + WriteEventsToClient(client, 1, (xEvent *) &ce); } static Bool -RRCrtcPendingProperties (RRCrtcPtr crtc) +RRCrtcPendingProperties(RRCrtcPtr crtc) { - ScreenPtr pScreen = crtc->pScreen; + ScreenPtr pScreen = crtc->pScreen; + rrScrPriv(pScreen); - int o; + int o; - for (o = 0; o < pScrPriv->numOutputs; o++) - { - RROutputPtr output = pScrPriv->outputs[o]; - if (output->crtc == crtc && output->pendingProperties) - return TRUE; + for (o = 0; o < pScrPriv->numOutputs; o++) { + RROutputPtr output = pScrPriv->outputs[o]; + + if (output->crtc == crtc && output->pendingProperties) + return TRUE; } return FALSE; } @@ -304,14 +289,14 @@ crtc_bounds(RRCrtcPtr crtc, int *left, int *right, int *top, int *bottom) case RR_Rotate_0: case RR_Rotate_180: default: - *right = crtc->x + crtc->mode->mode.width; - *bottom = crtc->y + crtc->mode->mode.height; - return; + *right = crtc->x + crtc->mode->mode.width; + *bottom = crtc->y + crtc->mode->mode.height; + return; case RR_Rotate_90: case RR_Rotate_270: - *right = crtc->x + crtc->mode->mode.height; - *bottom = crtc->y + crtc->mode->mode.width; - return; + *right = crtc->x + crtc->mode->mode.height; + *bottom = crtc->y + crtc->mode->mode.width; + return; } } @@ -322,7 +307,7 @@ crtcs_adjacent(const RRCrtcPtr a, const RRCrtcPtr b) /* left, right, top, bottom... */ int al, ar, at, ab; int bl, br, bt, bb; - int cl, cr, ct, cb; /* the overlap, if any */ + int cl, cr, ct, cb; /* the overlap, if any */ crtc_bounds(a, &al, &ar, &at, &ab); crtc_bounds(b, &bl, &br, &bt, &bb); @@ -337,9 +322,10 @@ crtcs_adjacent(const RRCrtcPtr a, const RRCrtcPtr b) /* Depth-first search and mark all CRTCs reachable from cur */ static void -mark_crtcs (rrScrPrivPtr pScrPriv, int *reachable, int cur) +mark_crtcs(rrScrPrivPtr pScrPriv, int *reachable, int cur) { int i; + reachable[cur] = TRUE; for (i = 0; i < pScrPriv->numCrtcs; ++i) { if (reachable[i] || !pScrPriv->crtcs[i]->mode) @@ -350,13 +336,14 @@ mark_crtcs (rrScrPrivPtr pScrPriv, int *reachable, int cur) } static void -RRComputeContiguity (ScreenPtr pScreen) +RRComputeContiguity(ScreenPtr pScreen) { rrScrPriv(pScreen); Bool discontiguous = TRUE; int i, n = pScrPriv->numCrtcs; int *reachable = calloc(n, sizeof(int)); + if (!reachable) goto out; @@ -375,7 +362,7 @@ RRComputeContiguity (ScreenPtr pScreen) discontiguous = FALSE; -out: + out: free(reachable); pScrPriv->discontiguous = discontiguous; } @@ -384,96 +371,87 @@ out: * Request that the Crtc be reconfigured */ Bool -RRCrtcSet (RRCrtcPtr crtc, - RRModePtr mode, - int x, - int y, - Rotation rotation, - int numOutputs, - RROutputPtr *outputs) +RRCrtcSet(RRCrtcPtr crtc, + RRModePtr mode, + int x, + int y, Rotation rotation, int numOutputs, RROutputPtr * outputs) { - ScreenPtr pScreen = crtc->pScreen; - Bool ret = FALSE; - Bool recompute = TRUE; + ScreenPtr pScreen = crtc->pScreen; + Bool ret = FALSE; + Bool recompute = TRUE; + rrScrPriv(pScreen); /* See if nothing changed */ if (crtc->mode == mode && - crtc->x == x && - crtc->y == y && - crtc->rotation == rotation && - crtc->numOutputs == numOutputs && - !memcmp (crtc->outputs, outputs, numOutputs * sizeof (RROutputPtr)) && - !RRCrtcPendingProperties (crtc) && - !RRCrtcPendingTransform (crtc)) - { - recompute = FALSE; - ret = TRUE; + crtc->x == x && + crtc->y == y && + crtc->rotation == rotation && + crtc->numOutputs == numOutputs && + !memcmp(crtc->outputs, outputs, numOutputs * sizeof(RROutputPtr)) && + !RRCrtcPendingProperties(crtc) && !RRCrtcPendingTransform(crtc)) { + recompute = FALSE; + ret = TRUE; } - else - { + else { #if RANDR_12_INTERFACE - if (pScrPriv->rrCrtcSet) - { - ret = (*pScrPriv->rrCrtcSet) (pScreen, crtc, mode, x, y, - rotation, numOutputs, outputs); - } - else + if (pScrPriv->rrCrtcSet) { + ret = (*pScrPriv->rrCrtcSet) (pScreen, crtc, mode, x, y, + rotation, numOutputs, outputs); + } + else #endif - { + { #if RANDR_10_INTERFACE - if (pScrPriv->rrSetConfig) - { - RRScreenSize size; - RRScreenRate rate; - - if (!mode) - { - RRCrtcNotify (crtc, NULL, x, y, rotation, NULL, 0, NULL); - ret = TRUE; - } - else - { - size.width = mode->mode.width; - size.height = mode->mode.height; - if (outputs[0]->mmWidth && outputs[0]->mmHeight) - { - size.mmWidth = outputs[0]->mmWidth; - size.mmHeight = outputs[0]->mmHeight; - } - else - { - size.mmWidth = pScreen->mmWidth; - size.mmHeight = pScreen->mmHeight; - } - size.nRates = 1; - rate.rate = RRVerticalRefresh (&mode->mode); - size.pRates = &rate; - ret = (*pScrPriv->rrSetConfig) (pScreen, rotation, rate.rate, &size); - /* - * Old 1.0 interface tied screen size to mode size - */ - if (ret) - { - RRCrtcNotify (crtc, mode, x, y, rotation, NULL, 1, outputs); - RRScreenSizeNotify (pScreen); - } - } - } + if (pScrPriv->rrSetConfig) { + RRScreenSize size; + RRScreenRate rate; + + if (!mode) { + RRCrtcNotify(crtc, NULL, x, y, rotation, NULL, 0, NULL); + ret = TRUE; + } + else { + size.width = mode->mode.width; + size.height = mode->mode.height; + if (outputs[0]->mmWidth && outputs[0]->mmHeight) { + size.mmWidth = outputs[0]->mmWidth; + size.mmHeight = outputs[0]->mmHeight; + } + else { + size.mmWidth = pScreen->mmWidth; + size.mmHeight = pScreen->mmHeight; + } + size.nRates = 1; + rate.rate = RRVerticalRefresh(&mode->mode); + size.pRates = &rate; + ret = + (*pScrPriv->rrSetConfig) (pScreen, rotation, rate.rate, + &size); + /* + * Old 1.0 interface tied screen size to mode size + */ + if (ret) { + RRCrtcNotify(crtc, mode, x, y, rotation, NULL, 1, + outputs); + RRScreenSizeNotify(pScreen); + } + } + } #endif - } - if (ret) - { - int o; - RRTellChanged (pScreen); - - for (o = 0; o < numOutputs; o++) - RRPostPendingProperties (outputs[o]); - } + } + if (ret) { + int o; + + RRTellChanged(pScreen); + + for (o = 0; o < numOutputs; o++) + RRPostPendingProperties(outputs[o]); + } } if (recompute) - RRComputeContiguity(pScreen); + RRComputeContiguity(pScreen); return ret; } @@ -482,12 +460,12 @@ RRCrtcSet (RRCrtcPtr crtc, * Return crtc transform */ RRTransformPtr -RRCrtcGetTransform (RRCrtcPtr crtc) +RRCrtcGetTransform(RRCrtcPtr crtc) { - RRTransformPtr transform = &crtc->client_pending_transform; + RRTransformPtr transform = &crtc->client_pending_transform; - if (pixman_transform_is_identity (&transform->transform)) - return NULL; + if (pixman_transform_is_identity(&transform->transform)) + return NULL; return transform; } @@ -495,47 +473,44 @@ RRCrtcGetTransform (RRCrtcPtr crtc) * Check whether the pending and current transforms are the same */ Bool -RRCrtcPendingTransform (RRCrtcPtr crtc) +RRCrtcPendingTransform(RRCrtcPtr crtc) { - return memcmp (&crtc->client_current_transform.transform, - &crtc->client_pending_transform.transform, - sizeof (PictTransform)) != 0; + return memcmp(&crtc->client_current_transform.transform, + &crtc->client_pending_transform.transform, + sizeof(PictTransform)) != 0; } /* * Destroy a Crtc at shutdown */ void -RRCrtcDestroy (RRCrtcPtr crtc) +RRCrtcDestroy(RRCrtcPtr crtc) { - FreeResource (crtc->id, 0); + FreeResource(crtc->id, 0); } static int -RRCrtcDestroyResource (pointer value, XID pid) +RRCrtcDestroyResource(pointer value, XID pid) { - RRCrtcPtr crtc = (RRCrtcPtr) value; - ScreenPtr pScreen = crtc->pScreen; + RRCrtcPtr crtc = (RRCrtcPtr) value; + ScreenPtr pScreen = crtc->pScreen; - if (pScreen) - { - rrScrPriv(pScreen); - int i; - - for (i = 0; i < pScrPriv->numCrtcs; i++) - { - if (pScrPriv->crtcs[i] == crtc) - { - memmove (pScrPriv->crtcs + i, pScrPriv->crtcs + i + 1, - (pScrPriv->numCrtcs - (i + 1)) * sizeof (RRCrtcPtr)); - --pScrPriv->numCrtcs; - break; - } - } + if (pScreen) { + rrScrPriv(pScreen); + int i; + + for (i = 0; i < pScrPriv->numCrtcs; i++) { + if (pScrPriv->crtcs[i] == crtc) { + memmove(pScrPriv->crtcs + i, pScrPriv->crtcs + i + 1, + (pScrPriv->numCrtcs - (i + 1)) * sizeof(RRCrtcPtr)); + --pScrPriv->numCrtcs; + break; + } + } } free(crtc->gammaRed); if (crtc->mode) - RRModeDestroy (crtc->mode); + RRModeDestroy(crtc->mode); free(crtc); return 1; } @@ -545,25 +520,22 @@ RRCrtcDestroyResource (pointer value, XID pid) */ Bool -RRCrtcGammaSet (RRCrtcPtr crtc, - CARD16 *red, - CARD16 *green, - CARD16 *blue) +RRCrtcGammaSet(RRCrtcPtr crtc, CARD16 *red, CARD16 *green, CARD16 *blue) { - Bool ret = TRUE; + Bool ret = TRUE; + #if RANDR_12_INTERFACE - ScreenPtr pScreen = crtc->pScreen; + ScreenPtr pScreen = crtc->pScreen; #endif - - memcpy (crtc->gammaRed, red, crtc->gammaSize * sizeof (CARD16)); - memcpy (crtc->gammaGreen, green, crtc->gammaSize * sizeof (CARD16)); - memcpy (crtc->gammaBlue, blue, crtc->gammaSize * sizeof (CARD16)); + + memcpy(crtc->gammaRed, red, crtc->gammaSize * sizeof(CARD16)); + memcpy(crtc->gammaGreen, green, crtc->gammaSize * sizeof(CARD16)); + memcpy(crtc->gammaBlue, blue, crtc->gammaSize * sizeof(CARD16)); #if RANDR_12_INTERFACE - if (pScreen) - { - rrScrPriv(pScreen); - if (pScrPriv->rrCrtcSetGamma) - ret = (*pScrPriv->rrCrtcSetGamma) (pScreen, crtc); + if (pScreen) { + rrScrPriv(pScreen); + if (pScrPriv->rrCrtcSetGamma) + ret = (*pScrPriv->rrCrtcSetGamma) (pScreen, crtc); } #endif return ret; @@ -577,13 +549,13 @@ Bool RRCrtcGammaGet(RRCrtcPtr crtc) { Bool ret = TRUE; + #if RANDR_12_INTERFACE - ScreenPtr pScreen = crtc->pScreen; + ScreenPtr pScreen = crtc->pScreen; #endif #if RANDR_12_INTERFACE - if (pScreen) - { + if (pScreen) { rrScrPriv(pScreen); if (pScrPriv->rrCrtcGetGamma) ret = (*pScrPriv->rrCrtcGetGamma) (pScreen, crtc); @@ -599,21 +571,21 @@ RRCrtcGammaGet(RRCrtcPtr crtc) */ Bool -RRCrtcGammaNotify (RRCrtcPtr crtc) +RRCrtcGammaNotify(RRCrtcPtr crtc) { - return TRUE; /* not much going on here */ + return TRUE; /* not much going on here */ } static void -RRModeGetScanoutSize (RRModePtr mode, PictTransformPtr transform, - int *width, int *height) +RRModeGetScanoutSize(RRModePtr mode, PictTransformPtr transform, + int *width, int *height) { - BoxRec box; + BoxRec box; if (mode == NULL) { - *width = 0; - *height = 0; - return; + *width = 0; + *height = 0; + return; } box.x1 = 0; @@ -621,7 +593,7 @@ RRModeGetScanoutSize (RRModePtr mode, PictTransformPtr transform, box.x2 = mode->mode.width; box.y2 = mode->mode.height; - pixman_transform_bounds (transform, &box); + pixman_transform_bounds(transform, &box); *width = box.x2 - box.x1; *height = box.y2 - box.y1; } @@ -632,7 +604,7 @@ RRModeGetScanoutSize (RRModePtr mode, PictTransformPtr transform, void RRCrtcGetScanoutSize(RRCrtcPtr crtc, int *width, int *height) { - RRModeGetScanoutSize (crtc->mode, &crtc->transform, width, height); + RRModeGetScanoutSize(crtc->mode, &crtc->transform, width, height); } /* @@ -640,25 +612,23 @@ RRCrtcGetScanoutSize(RRCrtcPtr crtc, int *width, int *height) */ Bool -RRCrtcGammaSetSize (RRCrtcPtr crtc, - int size) +RRCrtcGammaSetSize(RRCrtcPtr crtc, int size) { - CARD16 *gamma; + CARD16 *gamma; if (size == crtc->gammaSize) - return TRUE; - if (size) - { - gamma = malloc(size * 3 * sizeof (CARD16)); - if (!gamma) - return FALSE; + return TRUE; + if (size) { + gamma = malloc(size * 3 * sizeof(CARD16)); + if (!gamma) + return FALSE; } else - gamma = NULL; + gamma = NULL; free(crtc->gammaRed); crtc->gammaRed = gamma; crtc->gammaGreen = gamma + size; - crtc->gammaBlue = gamma + size*2; + crtc->gammaBlue = gamma + size * 2; crtc->gammaSize = size; return TRUE; } @@ -668,47 +638,40 @@ RRCrtcGammaSetSize (RRCrtcPtr crtc, */ int -RRCrtcTransformSet (RRCrtcPtr crtc, - PictTransformPtr transform, - struct pixman_f_transform *f_transform, - struct pixman_f_transform *f_inverse, - char *filter_name, - int filter_len, - xFixed *params, - int nparams) +RRCrtcTransformSet(RRCrtcPtr crtc, + PictTransformPtr transform, + struct pixman_f_transform *f_transform, + struct pixman_f_transform *f_inverse, + char *filter_name, + int filter_len, xFixed * params, int nparams) { - PictFilterPtr filter = NULL; - int width = 0, height = 0; + PictFilterPtr filter = NULL; + int width = 0, height = 0; if (!crtc->transforms) - return BadValue; - - if (filter_len) - { - filter = PictureFindFilter (crtc->pScreen, - filter_name, - filter_len); - if (!filter) - return BadName; - if (filter->ValidateParams) - { - if (!filter->ValidateParams (crtc->pScreen, filter->id, - params, nparams, &width, &height)) - return BadMatch; - } - else { - width = filter->width; - height = filter->height; - } + return BadValue; + + if (filter_len) { + filter = PictureFindFilter(crtc->pScreen, filter_name, filter_len); + if (!filter) + return BadName; + if (filter->ValidateParams) { + if (!filter->ValidateParams(crtc->pScreen, filter->id, + params, nparams, &width, &height)) + return BadMatch; + } + else { + width = filter->width; + height = filter->height; + } } - else - { - if (nparams) - return BadMatch; + else { + if (nparams) + return BadMatch; } - if (!RRTransformSetFilter (&crtc->client_pending_transform, - filter, params, nparams, width, height)) - return BadAlloc; + if (!RRTransformSetFilter(&crtc->client_pending_transform, + filter, params, nparams, width, height)) + return BadAlloc; crtc->client_pending_transform.transform = *transform; crtc->client_pending_transform.f_transform = *f_transform; @@ -720,12 +683,12 @@ RRCrtcTransformSet (RRCrtcPtr crtc, * Initialize crtc type */ Bool -RRCrtcInit (void) +RRCrtcInit(void) { - RRCrtcType = CreateNewResourceType (RRCrtcDestroyResource, "CRTC"); + RRCrtcType = CreateNewResourceType(RRCrtcDestroyResource, "CRTC"); if (!RRCrtcType) - return FALSE; - + return FALSE; + return TRUE; } @@ -739,22 +702,22 @@ RRCrtcInitErrorValue(void) } int -ProcRRGetCrtcInfo (ClientPtr client) +ProcRRGetCrtcInfo(ClientPtr client) { REQUEST(xRRGetCrtcInfoReq); - xRRGetCrtcInfoReply rep; - RRCrtcPtr crtc; - CARD8 *extra; - unsigned long extraLen; - ScreenPtr pScreen; - rrScrPrivPtr pScrPriv; - RRModePtr mode; - RROutput *outputs; - RROutput *possible; - int i, j, k; - int width, height; - BoxRec panned_area; - + xRRGetCrtcInfoReply rep; + RRCrtcPtr crtc; + CARD8 *extra; + unsigned long extraLen; + ScreenPtr pScreen; + rrScrPrivPtr pScrPriv; + RRModePtr mode; + RROutput *outputs; + RROutput *possible; + int i, j, k; + int width, height; + BoxRec panned_area; + REQUEST_SIZE_MATCH(xRRGetCrtcInfoReq); VERIFY_RR_CRTC(stuff->crtc, crtc, DixReadAccess); @@ -765,28 +728,27 @@ ProcRRGetCrtcInfo (ClientPtr client) pScrPriv = rrGetScrPriv(pScreen); mode = crtc->mode; - + rep.type = X_Reply; rep.status = RRSetConfigSuccess; rep.sequenceNumber = client->sequence; rep.length = 0; rep.timestamp = pScrPriv->lastSetTime.milliseconds; if (pScrPriv->rrGetPanning && - pScrPriv->rrGetPanning (pScreen, crtc, &panned_area, NULL, NULL) && - (panned_area.x2 > panned_area.x1) && (panned_area.y2 > panned_area.y1)) + pScrPriv->rrGetPanning(pScreen, crtc, &panned_area, NULL, NULL) && + (panned_area.x2 > panned_area.x1) && (panned_area.y2 > panned_area.y1)) { - rep.x = panned_area.x1; - rep.y = panned_area.y1; - rep.width = panned_area.x2 - panned_area.x1; - rep.height = panned_area.y2 - panned_area.y1; + rep.x = panned_area.x1; + rep.y = panned_area.y1; + rep.width = panned_area.x2 - panned_area.x1; + rep.height = panned_area.y2 - panned_area.y1; } - else - { - RRCrtcGetScanoutSize (crtc, &width, &height); - rep.x = crtc->x; - rep.y = crtc->y; - rep.width = width; - rep.height = height; + else { + RRCrtcGetScanoutSize(crtc, &width, &height); + rep.x = crtc->x; + rep.y = crtc->y; + rep.width = width; + rep.height = height; } rep.mode = mode ? mode->mode.id : 0; rep.rotation = crtc->rotation; @@ -794,178 +756,162 @@ ProcRRGetCrtcInfo (ClientPtr client) rep.nOutput = crtc->numOutputs; k = 0; for (i = 0; i < pScrPriv->numOutputs; i++) - for (j = 0; j < pScrPriv->outputs[i]->numCrtcs; j++) - if (pScrPriv->outputs[i]->crtcs[j] == crtc) - k++; + for (j = 0; j < pScrPriv->outputs[i]->numCrtcs; j++) + if (pScrPriv->outputs[i]->crtcs[j] == crtc) + k++; rep.nPossibleOutput = k; - + rep.length = rep.nOutput + rep.nPossibleOutput; extraLen = rep.length << 2; - if (extraLen) - { - extra = malloc(extraLen); - if (!extra) - return BadAlloc; + if (extraLen) { + extra = malloc(extraLen); + if (!extra) + return BadAlloc; } else - extra = NULL; + extra = NULL; outputs = (RROutput *) extra; possible = (RROutput *) (outputs + rep.nOutput); - - for (i = 0; i < crtc->numOutputs; i++) - { - outputs[i] = crtc->outputs[i]->id; - if (client->swapped) - swapl(&outputs[i]); + + for (i = 0; i < crtc->numOutputs; i++) { + outputs[i] = crtc->outputs[i]->id; + if (client->swapped) + swapl(&outputs[i]); } k = 0; for (i = 0; i < pScrPriv->numOutputs; i++) - for (j = 0; j < pScrPriv->outputs[i]->numCrtcs; j++) - if (pScrPriv->outputs[i]->crtcs[j] == crtc) - { - possible[k] = pScrPriv->outputs[i]->id; - if (client->swapped) - swapl(&possible[k]); - k++; - } - + for (j = 0; j < pScrPriv->outputs[i]->numCrtcs; j++) + if (pScrPriv->outputs[i]->crtcs[j] == crtc) { + possible[k] = pScrPriv->outputs[i]->id; + if (client->swapped) + swapl(&possible[k]); + k++; + } + if (client->swapped) { - 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); + 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) - { - WriteToClient (client, extraLen, (char *) extra); - free(extra); + WriteToClient(client, sizeof(xRRGetCrtcInfoReply), (char *) &rep); + if (extraLen) { + WriteToClient(client, extraLen, (char *) extra); + free(extra); } - + return Success; } int -ProcRRSetCrtcConfig (ClientPtr client) +ProcRRSetCrtcConfig(ClientPtr client) { REQUEST(xRRSetCrtcConfigReq); - xRRSetCrtcConfigReply rep; - ScreenPtr pScreen; - rrScrPrivPtr pScrPriv; - RRCrtcPtr crtc; - RRModePtr mode; - int numOutputs; - RROutputPtr *outputs = NULL; - RROutput *outputIds; - TimeStamp configTime; - TimeStamp time; - Rotation rotation; - int rc, i, j; - + xRRSetCrtcConfigReply rep; + ScreenPtr pScreen; + rrScrPrivPtr pScrPriv; + RRCrtcPtr crtc; + RRModePtr mode; + int numOutputs; + RROutputPtr *outputs = NULL; + RROutput *outputIds; + TimeStamp configTime; + TimeStamp time; + Rotation rotation; + int rc, i, j; + REQUEST_AT_LEAST_SIZE(xRRSetCrtcConfigReq); - numOutputs = (stuff->length - bytes_to_int32(SIZEOF (xRRSetCrtcConfigReq))); - + numOutputs = (stuff->length - bytes_to_int32(SIZEOF(xRRSetCrtcConfigReq))); + VERIFY_RR_CRTC(stuff->crtc, crtc, DixSetAttrAccess); - if (stuff->mode == None) - { - mode = NULL; - if (numOutputs > 0) - return BadMatch; + if (stuff->mode == None) { + mode = NULL; + if (numOutputs > 0) + return BadMatch; } - else - { - VERIFY_RR_MODE(stuff->mode, mode, DixSetAttrAccess); - if (numOutputs == 0) - return BadMatch; + else { + VERIFY_RR_MODE(stuff->mode, mode, DixSetAttrAccess); + if (numOutputs == 0) + return BadMatch; } - if (numOutputs) - { - outputs = malloc(numOutputs * sizeof (RROutputPtr)); - if (!outputs) - return BadAlloc; + if (numOutputs) { + outputs = malloc(numOutputs * sizeof(RROutputPtr)); + if (!outputs) + return BadAlloc; } else - outputs = NULL; - + outputs = NULL; + outputIds = (RROutput *) (stuff + 1); - for (i = 0; i < numOutputs; i++) - { - rc = dixLookupResourceByType((pointer *)(outputs + i), outputIds[i], - RROutputType, client, DixSetAttrAccess); - if (rc != Success) - { - free(outputs); - return rc; - } - /* validate crtc for this output */ - for (j = 0; j < outputs[i]->numCrtcs; j++) - if (outputs[i]->crtcs[j] == crtc) - break; - if (j == outputs[i]->numCrtcs) - { - free(outputs); - return BadMatch; - } - /* validate mode for this output */ - for (j = 0; j < outputs[i]->numModes + outputs[i]->numUserModes; j++) - { - RRModePtr m = (j < outputs[i]->numModes ? - outputs[i]->modes[j] : - outputs[i]->userModes[j - outputs[i]->numModes]); - if (m == mode) - break; - } - if (j == outputs[i]->numModes + outputs[i]->numUserModes) - { - free(outputs); - return BadMatch; - } + for (i = 0; i < numOutputs; i++) { + rc = dixLookupResourceByType((pointer *) (outputs + i), outputIds[i], + RROutputType, client, DixSetAttrAccess); + if (rc != Success) { + free(outputs); + return rc; + } + /* validate crtc for this output */ + for (j = 0; j < outputs[i]->numCrtcs; j++) + if (outputs[i]->crtcs[j] == crtc) + break; + if (j == outputs[i]->numCrtcs) { + free(outputs); + return BadMatch; + } + /* validate mode for this output */ + for (j = 0; j < outputs[i]->numModes + outputs[i]->numUserModes; j++) { + RRModePtr m = (j < outputs[i]->numModes ? + outputs[i]->modes[j] : + outputs[i]->userModes[j - outputs[i]->numModes]); + if (m == mode) + break; + } + if (j == outputs[i]->numModes + outputs[i]->numUserModes) { + free(outputs); + return BadMatch; + } } /* validate clones */ - for (i = 0; i < numOutputs; i++) - { - for (j = 0; j < numOutputs; j++) - { - int k; - if (i == j) - continue; - for (k = 0; k < outputs[i]->numClones; k++) - { - if (outputs[i]->clones[k] == outputs[j]) - break; - } - if (k == outputs[i]->numClones) - { - free(outputs); - return BadMatch; - } - } + for (i = 0; i < numOutputs; i++) { + for (j = 0; j < numOutputs; j++) { + int k; + + if (i == j) + continue; + for (k = 0; k < outputs[i]->numClones; k++) { + if (outputs[i]->clones[k] == outputs[j]) + break; + } + if (k == outputs[i]->numClones) { + free(outputs); + return BadMatch; + } + } } pScreen = crtc->pScreen; pScrPriv = rrGetScrPriv(pScreen); - + time = ClientTimeToServerTime(stuff->timestamp); configTime = ClientTimeToServerTime(stuff->configTimestamp); - - if (!pScrPriv) - { - time = currentTime; - rep.status = RRSetConfigFailed; - goto sendReply; + + if (!pScrPriv) { + time = currentTime; + rep.status = RRSetConfigFailed; + goto sendReply; } - + /* * Validate requested rotation */ @@ -977,108 +923,102 @@ ProcRRSetCrtcConfig (ClientPtr client) case RR_Rotate_90: case RR_Rotate_180: case RR_Rotate_270: - break; + break; default: - /* - * Invalid rotation - */ - client->errorValue = stuff->rotation; - free(outputs); - return BadValue; + /* + * Invalid rotation + */ + client->errorValue = stuff->rotation; + free(outputs); + return BadValue; } - if (mode) - { - if ((~crtc->rotations) & rotation) - { - /* - * requested rotation or reflection not supported by screen - */ - client->errorValue = stuff->rotation; - free(outputs); - return BadMatch; - } - + if (mode) { + if ((~crtc->rotations) & rotation) { + /* + * requested rotation or reflection not supported by screen + */ + client->errorValue = stuff->rotation; + free(outputs); + return BadMatch; + } + #ifdef RANDR_12_INTERFACE - /* - * Check screen size bounds if the DDX provides a 1.2 interface - * for setting screen size. Else, assume the CrtcSet sets - * the size along with the mode. If the driver supports transforms, - * then it must allow crtcs to display a subset of the screen, so - * only do this check for drivers without transform support. - */ - if (pScrPriv->rrScreenSetSize && !crtc->transforms) - { - int source_width; - int source_height; - PictTransform transform; - struct pixman_f_transform f_transform, f_inverse; - - RRTransformCompute (stuff->x, stuff->y, - mode->mode.width, mode->mode.height, - rotation, - &crtc->client_pending_transform, - &transform, &f_transform, &f_inverse); - - RRModeGetScanoutSize (mode, &transform, &source_width, &source_height); - if (stuff->x + source_width > pScreen->width) - { - client->errorValue = stuff->x; - free(outputs); - return BadValue; - } - - if (stuff->y + source_height > pScreen->height) - { - client->errorValue = stuff->y; - free(outputs); - return BadValue; - } - } + /* + * Check screen size bounds if the DDX provides a 1.2 interface + * for setting screen size. Else, assume the CrtcSet sets + * the size along with the mode. If the driver supports transforms, + * then it must allow crtcs to display a subset of the screen, so + * only do this check for drivers without transform support. + */ + if (pScrPriv->rrScreenSetSize && !crtc->transforms) { + int source_width; + int source_height; + PictTransform transform; + struct pixman_f_transform f_transform, f_inverse; + + RRTransformCompute(stuff->x, stuff->y, + mode->mode.width, mode->mode.height, + rotation, + &crtc->client_pending_transform, + &transform, &f_transform, &f_inverse); + + RRModeGetScanoutSize(mode, &transform, &source_width, + &source_height); + if (stuff->x + source_width > pScreen->width) { + client->errorValue = stuff->x; + free(outputs); + return BadValue; + } + + if (stuff->y + source_height > pScreen->height) { + client->errorValue = stuff->y; + free(outputs); + return BadValue; + } + } #endif } - - if (!RRCrtcSet (crtc, mode, stuff->x, stuff->y, - rotation, numOutputs, outputs)) - { - rep.status = RRSetConfigFailed; - goto sendReply; + + if (!RRCrtcSet(crtc, mode, stuff->x, stuff->y, + rotation, numOutputs, outputs)) { + rep.status = RRSetConfigFailed; + goto sendReply; } rep.status = RRSetConfigSuccess; pScrPriv->lastSetTime = time; - -sendReply: + + sendReply: free(outputs); - + rep.type = X_Reply; /* rep.status has already been filled in */ rep.length = 0; rep.sequenceNumber = client->sequence; rep.newTimestamp = pScrPriv->lastSetTime.milliseconds; - if (client->swapped) - { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - swapl(&rep.newTimestamp); + if (client->swapped) { + swaps(&rep.sequenceNumber); + swapl(&rep.length); + swapl(&rep.newTimestamp); } - WriteToClient(client, sizeof(xRRSetCrtcConfigReply), (char *)&rep); - + WriteToClient(client, sizeof(xRRSetCrtcConfigReply), (char *) &rep); + return Success; } int -ProcRRGetPanning (ClientPtr client) +ProcRRGetPanning(ClientPtr client) { REQUEST(xRRGetPanningReq); - xRRGetPanningReply rep; - RRCrtcPtr crtc; - ScreenPtr pScreen; - rrScrPrivPtr pScrPriv; - BoxRec total; - BoxRec tracking; - INT16 border[4]; - + xRRGetPanningReply rep; + RRCrtcPtr crtc; + ScreenPtr pScreen; + rrScrPrivPtr pScrPriv; + BoxRec total; + BoxRec tracking; + INT16 border[4]; + REQUEST_SIZE_MATCH(xRRGetPanningReq); VERIFY_RR_CRTC(stuff->crtc, crtc, DixReadAccess); @@ -1089,7 +1029,7 @@ ProcRRGetPanning (ClientPtr client) pScrPriv = rrGetScrPriv(pScreen); if (!pScrPriv) - return RRErrorBase + BadRRCrtc; + return RRErrorBase + BadRRCrtc; memset(&rep, 0, sizeof(rep)); rep.type = X_Reply; @@ -1099,55 +1039,55 @@ ProcRRGetPanning (ClientPtr client) rep.timestamp = pScrPriv->lastSetTime.milliseconds; if (pScrPriv->rrGetPanning && - pScrPriv->rrGetPanning (pScreen, crtc, &total, &tracking, border)) { - rep.left = total.x1; - rep.top = total.y1; - rep.width = total.x2 - total.x1; - rep.height = total.y2 - total.y1; - rep.track_left = tracking.x1; - rep.track_top = tracking.y1; - rep.track_width = tracking.x2 - tracking.x1; - rep.track_height = tracking.y2 - tracking.y1; - rep.border_left = border[0]; - rep.border_top = border[1]; - rep.border_right = border[2]; - rep.border_bottom = border[3]; + pScrPriv->rrGetPanning(pScreen, crtc, &total, &tracking, border)) { + rep.left = total.x1; + rep.top = total.y1; + rep.width = total.x2 - total.x1; + rep.height = total.y2 - total.y1; + rep.track_left = tracking.x1; + rep.track_top = tracking.y1; + rep.track_width = tracking.x2 - tracking.x1; + rep.track_height = tracking.y2 - tracking.y1; + rep.border_left = border[0]; + rep.border_top = border[1]; + rep.border_right = border[2]; + rep.border_bottom = border[3]; } if (client->swapped) { - 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); + 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); + WriteToClient(client, sizeof(xRRGetPanningReply), (char *) &rep); return Success; } int -ProcRRSetPanning (ClientPtr client) +ProcRRSetPanning(ClientPtr client) { REQUEST(xRRSetPanningReq); - xRRSetPanningReply rep; - RRCrtcPtr crtc; - ScreenPtr pScreen; - rrScrPrivPtr pScrPriv; - TimeStamp time; - BoxRec total; - BoxRec tracking; - INT16 border[4]; - + xRRSetPanningReply rep; + RRCrtcPtr crtc; + ScreenPtr pScreen; + rrScrPrivPtr pScrPriv; + TimeStamp time; + BoxRec total; + BoxRec tracking; + INT16 border[4]; + REQUEST_SIZE_MATCH(xRRSetPanningReq); VERIFY_RR_CRTC(stuff->crtc, crtc, DixReadAccess); @@ -1158,57 +1098,57 @@ ProcRRSetPanning (ClientPtr client) pScrPriv = rrGetScrPriv(pScreen); if (!pScrPriv) { - time = currentTime; - rep.status = RRSetConfigFailed; - goto sendReply; + time = currentTime; + rep.status = RRSetConfigFailed; + goto sendReply; } - + time = ClientTimeToServerTime(stuff->timestamp); - + if (!pScrPriv->rrGetPanning) - return RRErrorBase + BadRRCrtc; + return RRErrorBase + BadRRCrtc; - total.x1 = stuff->left; - total.y1 = stuff->top; - total.x2 = total.x1 + stuff->width; - total.y2 = total.y1 + stuff->height; + total.x1 = stuff->left; + total.y1 = stuff->top; + total.x2 = total.x1 + stuff->width; + total.y2 = total.y1 + stuff->height; tracking.x1 = stuff->track_left; tracking.y1 = stuff->track_top; tracking.x2 = tracking.x1 + stuff->track_width; tracking.y2 = tracking.y1 + stuff->track_height; - border[0] = stuff->border_left; - border[1] = stuff->border_top; - border[2] = stuff->border_right; - border[3] = stuff->border_bottom; + border[0] = stuff->border_left; + border[1] = stuff->border_top; + border[2] = stuff->border_right; + border[3] = stuff->border_bottom; - if (! pScrPriv->rrSetPanning (pScreen, crtc, &total, &tracking, border)) - return BadMatch; + if (!pScrPriv->rrSetPanning(pScreen, crtc, &total, &tracking, border)) + return BadMatch; pScrPriv->lastSetTime = time; rep.status = RRSetConfigSuccess; -sendReply: + sendReply: rep.type = X_Reply; rep.sequenceNumber = client->sequence; rep.length = 0; rep.newTimestamp = pScrPriv->lastSetTime.milliseconds; if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - swapl(&rep.newTimestamp); + swaps(&rep.sequenceNumber); + swapl(&rep.length); + swapl(&rep.newTimestamp); } - WriteToClient(client, sizeof(xRRSetPanningReply), (char *)&rep); + WriteToClient(client, sizeof(xRRSetPanningReply), (char *) &rep); return Success; } int -ProcRRGetCrtcGammaSize (ClientPtr client) +ProcRRGetCrtcGammaSize(ClientPtr client) { REQUEST(xRRGetCrtcGammaSizeReq); - xRRGetCrtcGammaSizeReply reply; - RRCrtcPtr crtc; + xRRGetCrtcGammaSizeReply reply; + RRCrtcPtr crtc; REQUEST_SIZE_MATCH(xRRGetCrtcGammaSizeReq); VERIFY_RR_CRTC(stuff->crtc, crtc, DixReadAccess); @@ -1222,23 +1162,23 @@ ProcRRGetCrtcGammaSize (ClientPtr client) reply.length = 0; reply.size = crtc->gammaSize; if (client->swapped) { - swaps(&reply.sequenceNumber); - swapl(&reply.length); - swaps(&reply.size); + swaps(&reply.sequenceNumber); + swapl(&reply.length); + swaps(&reply.size); } - WriteToClient (client, sizeof (xRRGetCrtcGammaSizeReply), (char *) &reply); + WriteToClient(client, sizeof(xRRGetCrtcGammaSizeReply), (char *) &reply); return Success; } int -ProcRRGetCrtcGamma (ClientPtr client) +ProcRRGetCrtcGamma(ClientPtr client) { REQUEST(xRRGetCrtcGammaReq); - xRRGetCrtcGammaReply reply; - RRCrtcPtr crtc; - unsigned long len; - char *extra = NULL; - + xRRGetCrtcGammaReply reply; + RRCrtcPtr crtc; + unsigned long len; + char *extra = NULL; + REQUEST_SIZE_MATCH(xRRGetCrtcGammaReq); VERIFY_RR_CRTC(stuff->crtc, crtc, DixReadAccess); @@ -1247,11 +1187,11 @@ ProcRRGetCrtcGamma (ClientPtr client) return RRErrorBase + BadRRCrtc; len = crtc->gammaSize * 3 * 2; - + if (crtc->gammaSize) { - extra = malloc(len); - if (!extra) - return BadAlloc; + extra = malloc(len); + if (!extra) + return BadAlloc; } reply.type = X_Reply; @@ -1259,44 +1199,43 @@ ProcRRGetCrtcGamma (ClientPtr client) reply.length = bytes_to_int32(len); reply.size = crtc->gammaSize; if (client->swapped) { - swaps(&reply.sequenceNumber); - swapl(&reply.length); - swaps(&reply.size); + swaps(&reply.sequenceNumber); + swapl(&reply.length); + swaps(&reply.size); } - WriteToClient (client, sizeof (xRRGetCrtcGammaReply), (char *) &reply); - if (crtc->gammaSize) - { - memcpy(extra, crtc->gammaRed, len); - client->pSwapReplyFunc = (ReplySwapPtr)CopySwap16Write; - WriteSwappedDataToClient (client, len, extra); - free(extra); + WriteToClient(client, sizeof(xRRGetCrtcGammaReply), (char *) &reply); + if (crtc->gammaSize) { + memcpy(extra, crtc->gammaRed, len); + client->pSwapReplyFunc = (ReplySwapPtr) CopySwap16Write; + WriteSwappedDataToClient(client, len, extra); + free(extra); } return Success; } int -ProcRRSetCrtcGamma (ClientPtr client) +ProcRRSetCrtcGamma(ClientPtr client) { REQUEST(xRRSetCrtcGammaReq); - RRCrtcPtr crtc; - unsigned long len; - CARD16 *red, *green, *blue; - + RRCrtcPtr crtc; + unsigned long len; + CARD16 *red, *green, *blue; + REQUEST_AT_LEAST_SIZE(xRRSetCrtcGammaReq); VERIFY_RR_CRTC(stuff->crtc, crtc, DixReadAccess); - - len = client->req_len - bytes_to_int32(sizeof (xRRSetCrtcGammaReq)); + + len = client->req_len - bytes_to_int32(sizeof(xRRSetCrtcGammaReq)); if (len < (stuff->size * 3 + 1) >> 1) - return BadLength; + return BadLength; if (stuff->size != crtc->gammaSize) - return BadMatch; - + return BadMatch; + red = (CARD16 *) (stuff + 1); green = red + crtc->gammaSize; blue = green + crtc->gammaSize; - - RRCrtcGammaSet (crtc, red, green, blue); + + RRCrtcGammaSet(crtc, red, green, blue); return Success; } @@ -1304,111 +1243,110 @@ ProcRRSetCrtcGamma (ClientPtr client) /* Version 1.3 additions */ int -ProcRRSetCrtcTransform (ClientPtr client) +ProcRRSetCrtcTransform(ClientPtr client) { REQUEST(xRRSetCrtcTransformReq); - RRCrtcPtr crtc; - PictTransform transform; + RRCrtcPtr crtc; + PictTransform transform; struct pixman_f_transform f_transform, f_inverse; - char *filter; - int nbytes; - xFixed *params; - int nparams; + char *filter; + int nbytes; + xFixed *params; + int nparams; REQUEST_AT_LEAST_SIZE(xRRSetCrtcTransformReq); VERIFY_RR_CRTC(stuff->crtc, crtc, DixReadAccess); - PictTransform_from_xRenderTransform (&transform, &stuff->transform); - pixman_f_transform_from_pixman_transform (&f_transform, &transform); - if (!pixman_f_transform_invert (&f_inverse, &f_transform)) - return BadMatch; + PictTransform_from_xRenderTransform(&transform, &stuff->transform); + pixman_f_transform_from_pixman_transform(&f_transform, &transform); + if (!pixman_f_transform_invert(&f_inverse, &f_transform)) + return BadMatch; filter = (char *) (stuff + 1); nbytes = stuff->nbytesFilter; params = (xFixed *) (filter + pad_to_int32(nbytes)); nparams = ((xFixed *) stuff + client->req_len) - params; if (nparams < 0) - return BadLength; + return BadLength; - return RRCrtcTransformSet (crtc, &transform, &f_transform, &f_inverse, - filter, nbytes, params, nparams); + return RRCrtcTransformSet(crtc, &transform, &f_transform, &f_inverse, + filter, nbytes, params, nparams); } - #define CrtcTransformExtra (SIZEOF(xRRGetCrtcTransformReply) - 32) - + static int -transform_filter_length (RRTransformPtr transform) +transform_filter_length(RRTransformPtr transform) { - int nbytes, nparams; + int nbytes, nparams; if (transform->filter == NULL) - return 0; - nbytes = strlen (transform->filter->name); + return 0; + nbytes = strlen(transform->filter->name); nparams = transform->nparams; - return pad_to_int32(nbytes) + (nparams * sizeof (xFixed)); + return pad_to_int32(nbytes) + (nparams * sizeof(xFixed)); } static int -transform_filter_encode (ClientPtr client, char *output, - CARD16 *nbytesFilter, - CARD16 *nparamsFilter, - RRTransformPtr transform) +transform_filter_encode(ClientPtr client, char *output, + CARD16 *nbytesFilter, + CARD16 *nparamsFilter, RRTransformPtr transform) { - int nbytes, nparams; + int nbytes, nparams; if (transform->filter == NULL) { - *nbytesFilter = 0; - *nparamsFilter = 0; - return 0; + *nbytesFilter = 0; + *nparamsFilter = 0; + return 0; } - nbytes = strlen (transform->filter->name); + nbytes = strlen(transform->filter->name); nparams = transform->nparams; *nbytesFilter = nbytes; *nparamsFilter = nparams; - memcpy (output, transform->filter->name, nbytes); + memcpy(output, transform->filter->name, nbytes); while ((nbytes & 3) != 0) - output[nbytes++] = 0; - memcpy (output + nbytes, transform->params, nparams * sizeof (xFixed)); + output[nbytes++] = 0; + memcpy(output + nbytes, transform->params, nparams * sizeof(xFixed)); if (client->swapped) { - swaps(nbytesFilter); - swaps(nparamsFilter); - SwapLongs ((CARD32 *) (output + nbytes), nparams); + swaps(nbytesFilter); + swaps(nparamsFilter); + SwapLongs((CARD32 *) (output + nbytes), nparams); } - nbytes += nparams * sizeof (xFixed); + nbytes += nparams * sizeof(xFixed); return nbytes; } static void -transform_encode (ClientPtr client, xRenderTransform *wire, PictTransform *pict) +transform_encode(ClientPtr client, xRenderTransform * wire, + PictTransform * pict) { - xRenderTransform_from_PictTransform (wire, pict); + xRenderTransform_from_PictTransform(wire, pict); if (client->swapped) - SwapLongs ((CARD32 *) wire, bytes_to_int32(sizeof(xRenderTransform))); + SwapLongs((CARD32 *) wire, bytes_to_int32(sizeof(xRenderTransform))); } int -ProcRRGetCrtcTransform (ClientPtr client) +ProcRRGetCrtcTransform(ClientPtr client) { REQUEST(xRRGetCrtcTransformReq); - xRRGetCrtcTransformReply *reply; - RRCrtcPtr crtc; - int nextra; - RRTransformPtr current, pending; - char *extra; + xRRGetCrtcTransformReply *reply; + RRCrtcPtr crtc; + int nextra; + RRTransformPtr current, pending; + char *extra; - REQUEST_SIZE_MATCH (xRRGetCrtcTransformReq); + REQUEST_SIZE_MATCH(xRRGetCrtcTransformReq); VERIFY_RR_CRTC(stuff->crtc, crtc, DixReadAccess); pending = &crtc->client_pending_transform; current = &crtc->client_current_transform; - nextra = (transform_filter_length (pending) + - transform_filter_length (current)); + nextra = (transform_filter_length(pending) + + transform_filter_length(current)); - reply = malloc(sizeof (xRRGetCrtcTransformReply) + nextra); + reply = malloc(sizeof(xRRGetCrtcTransformReply) + nextra); if (!reply) - return BadAlloc; + return BadAlloc; extra = (char *) (reply + 1); reply->type = X_Reply; @@ -1417,75 +1355,75 @@ ProcRRGetCrtcTransform (ClientPtr client) reply->hasTransforms = crtc->transforms; - transform_encode (client, &reply->pendingTransform, &pending->transform); - extra += transform_filter_encode (client, extra, - &reply->pendingNbytesFilter, - &reply->pendingNparamsFilter, - pending); + transform_encode(client, &reply->pendingTransform, &pending->transform); + extra += transform_filter_encode(client, extra, + &reply->pendingNbytesFilter, + &reply->pendingNparamsFilter, pending); - transform_encode (client, &reply->currentTransform, ¤t->transform); - extra += transform_filter_encode (client, extra, - &reply->currentNbytesFilter, - &reply->currentNparamsFilter, - current); + transform_encode(client, &reply->currentTransform, ¤t->transform); + extra += transform_filter_encode(client, extra, + &reply->currentNbytesFilter, + &reply->currentNparamsFilter, current); if (client->swapped) { - swaps(&reply->sequenceNumber); - swapl(&reply->length); + swaps(&reply->sequenceNumber); + swapl(&reply->length); } - WriteToClient (client, sizeof (xRRGetCrtcTransformReply) + nextra, (char *) reply); + WriteToClient(client, sizeof(xRRGetCrtcTransformReply) + nextra, + (char *) reply); free(reply); return Success; } void -RRConstrainCursorHarder(DeviceIntPtr pDev, ScreenPtr pScreen, int mode, int *x, int *y) +RRConstrainCursorHarder(DeviceIntPtr pDev, ScreenPtr pScreen, int mode, int *x, + int *y) { - rrScrPriv (pScreen); + rrScrPriv(pScreen); int i; /* intentional dead space -> let it float */ if (pScrPriv->discontiguous) - return; + return; /* if we're moving inside a crtc, we're fine */ for (i = 0; i < pScrPriv->numCrtcs; i++) { - RRCrtcPtr crtc = pScrPriv->crtcs[i]; + RRCrtcPtr crtc = pScrPriv->crtcs[i]; - int left, right, top, bottom; + int left, right, top, bottom; - if (!crtc->mode) - continue; + if (!crtc->mode) + continue; - crtc_bounds(crtc, &left, &right, &top, &bottom); + crtc_bounds(crtc, &left, &right, &top, &bottom); - if ((*x >= left) && (*x < right) && (*y >= top) && (*y < bottom)) - return; + if ((*x >= left) && (*x < right) && (*y >= top) && (*y < bottom)) + return; } /* if we're trying to escape, clamp to the CRTC we're coming from */ for (i = 0; i < pScrPriv->numCrtcs; i++) { - RRCrtcPtr crtc = pScrPriv->crtcs[i]; - int nx, ny; - int left, right, top, bottom; - - if (!crtc->mode) - continue; - - crtc_bounds(crtc, &left, &right, &top, &bottom); - miPointerGetPosition(pDev, &nx, &ny); - - if ((nx >= left) && (nx < right) && (ny >= top) && (ny < bottom)) { - if (*x < left) - *x = left; - if (*x >= right) - *x = right - 1; - if (*y < top) - *y = top; - if (*y >= bottom) - *y = bottom - 1; - - return; - } + RRCrtcPtr crtc = pScrPriv->crtcs[i]; + int nx, ny; + int left, right, top, bottom; + + if (!crtc->mode) + continue; + + crtc_bounds(crtc, &left, &right, &top, &bottom); + miPointerGetPosition(pDev, &nx, &ny); + + if ((nx >= left) && (nx < right) && (ny >= top) && (ny < bottom)) { + if (*x < left) + *x = left; + if (*x >= right) + *x = right - 1; + if (*y < top) + *y = top; + if (*y >= bottom) + *y = bottom - 1; + + return; + } } } diff --git a/xorg-server/randr/rrdispatch.c b/xorg-server/randr/rrdispatch.c index 5a6a85287..85cf03738 100644 --- a/xorg-server/randr/rrdispatch.c +++ b/xorg-server/randr/rrdispatch.c @@ -24,7 +24,7 @@ #include "protocol-versions.h" Bool -RRClientKnowsRates (ClientPtr pClient) +RRClientKnowsRates(ClientPtr pClient) { rrClientPriv(pClient); @@ -33,9 +33,9 @@ RRClientKnowsRates (ClientPtr pClient) } static int -ProcRRQueryVersion (ClientPtr client) +ProcRRQueryVersion(ClientPtr client) { - xRRQueryVersionReply rep = {0}; + xRRQueryVersionReply rep = { 0 }; REQUEST(xRRQueryVersionReq); rrClientPriv(client); @@ -47,209 +47,198 @@ ProcRRQueryVersion (ClientPtr client) rep.sequenceNumber = client->sequence; if (version_compare(stuff->majorVersion, stuff->minorVersion, - SERVER_RANDR_MAJOR_VERSION, SERVER_RANDR_MINOR_VERSION) < 0) - { - rep.majorVersion = stuff->majorVersion; - rep.minorVersion = stuff->minorVersion; - } else - { + SERVER_RANDR_MAJOR_VERSION, + SERVER_RANDR_MINOR_VERSION) < 0) { + rep.majorVersion = stuff->majorVersion; + rep.minorVersion = stuff->minorVersion; + } + else { rep.majorVersion = SERVER_RANDR_MAJOR_VERSION; rep.minorVersion = SERVER_RANDR_MINOR_VERSION; } if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - swapl(&rep.majorVersion); - swapl(&rep.minorVersion); + swaps(&rep.sequenceNumber); + swapl(&rep.length); + swapl(&rep.majorVersion); + swapl(&rep.minorVersion); } - WriteToClient(client, sizeof(xRRQueryVersionReply), (char *)&rep); + WriteToClient(client, sizeof(xRRQueryVersionReply), (char *) &rep); return Success; } static int -ProcRRSelectInput (ClientPtr client) +ProcRRSelectInput(ClientPtr client) { REQUEST(xRRSelectInputReq); rrClientPriv(client); - RRTimesPtr pTimes; - WindowPtr pWin; - RREventPtr pRREvent, *pHead; - XID clientResource; - int rc; + RRTimesPtr pTimes; + WindowPtr pWin; + RREventPtr pRREvent, *pHead; + XID clientResource; + int rc; REQUEST_SIZE_MATCH(xRRSelectInputReq); rc = dixLookupWindow(&pWin, stuff->window, client, DixReceiveAccess); if (rc != Success) - return rc; - rc = dixLookupResourceByType((pointer *)&pHead, pWin->drawable.id, - RREventType, client, DixWriteAccess); + return rc; + rc = dixLookupResourceByType((pointer *) &pHead, pWin->drawable.id, + RREventType, client, DixWriteAccess); if (rc != Success && rc != BadValue) - return rc; - - if (stuff->enable & (RRScreenChangeNotifyMask| - RRCrtcChangeNotifyMask| - RROutputChangeNotifyMask| - RROutputPropertyNotifyMask)) - { - ScreenPtr pScreen = pWin->drawable.pScreen; - rrScrPriv (pScreen); - - pRREvent = NULL; - if (pHead) - { - /* check for existing entry. */ - for (pRREvent = *pHead; pRREvent; pRREvent = pRREvent->next) - if (pRREvent->client == client) - break; - } - - if (!pRREvent) - { - /* build the entry */ - pRREvent = (RREventPtr) malloc(sizeof (RREventRec)); - if (!pRREvent) - return BadAlloc; - pRREvent->next = 0; - pRREvent->client = client; - pRREvent->window = pWin; - pRREvent->mask = stuff->enable; - /* - * add a resource that will be deleted when - * the client goes away - */ - clientResource = FakeClientID (client->index); - pRREvent->clientResource = clientResource; - if (!AddResource (clientResource, RRClientType, (pointer)pRREvent)) - return BadAlloc; - /* - * create a resource to contain a pointer to the list - * of clients selecting input. This must be indirect as - * the list may be arbitrarily rearranged which cannot be - * done through the resource database. - */ - if (!pHead) - { - pHead = (RREventPtr *) malloc(sizeof (RREventPtr)); - if (!pHead || - !AddResource (pWin->drawable.id, RREventType, (pointer)pHead)) - { - FreeResource (clientResource, RT_NONE); - return BadAlloc; - } - *pHead = 0; - } - pRREvent->next = *pHead; - *pHead = pRREvent; - } - /* - * Now see if the client needs an event - */ - if (pScrPriv) - { - pTimes = &((RRTimesPtr) (pRRClient + 1))[pScreen->myNum]; - if (CompareTimeStamps (pTimes->setTime, - pScrPriv->lastSetTime) != 0 || - CompareTimeStamps (pTimes->configTime, - pScrPriv->lastConfigTime) != 0) - { - if (pRREvent->mask & RRScreenChangeNotifyMask) - { - RRDeliverScreenEvent (client, pWin, pScreen); - } - - if (pRREvent->mask & RRCrtcChangeNotifyMask) - { - int i; - - for (i = 0; i < pScrPriv->numCrtcs; i++) - { - RRDeliverCrtcEvent (client, pWin, pScrPriv->crtcs[i]); - } - } - - if (pRREvent->mask & RROutputChangeNotifyMask) - { - int i; - - for (i = 0; i < pScrPriv->numOutputs; i++) - { - RRDeliverOutputEvent (client, pWin, pScrPriv->outputs[i]); - } - } - - /* We don't check for RROutputPropertyNotifyMask, as randrproto.txt doesn't - * say if there ought to be notifications of changes to output properties - * if those changes occurred before the time RRSelectInput is called. - */ - } - } + return rc; + + if (stuff->enable & (RRScreenChangeNotifyMask | + RRCrtcChangeNotifyMask | + RROutputChangeNotifyMask | + RROutputPropertyNotifyMask)) { + ScreenPtr pScreen = pWin->drawable.pScreen; + + rrScrPriv(pScreen); + + pRREvent = NULL; + if (pHead) { + /* check for existing entry. */ + for (pRREvent = *pHead; pRREvent; pRREvent = pRREvent->next) + if (pRREvent->client == client) + break; + } + + if (!pRREvent) { + /* build the entry */ + pRREvent = (RREventPtr) malloc(sizeof(RREventRec)); + if (!pRREvent) + return BadAlloc; + pRREvent->next = 0; + pRREvent->client = client; + pRREvent->window = pWin; + pRREvent->mask = stuff->enable; + /* + * add a resource that will be deleted when + * the client goes away + */ + clientResource = FakeClientID(client->index); + pRREvent->clientResource = clientResource; + if (!AddResource(clientResource, RRClientType, (pointer) pRREvent)) + return BadAlloc; + /* + * create a resource to contain a pointer to the list + * of clients selecting input. This must be indirect as + * the list may be arbitrarily rearranged which cannot be + * done through the resource database. + */ + if (!pHead) { + pHead = (RREventPtr *) malloc(sizeof(RREventPtr)); + if (!pHead || + !AddResource(pWin->drawable.id, RREventType, + (pointer) pHead)) { + FreeResource(clientResource, RT_NONE); + return BadAlloc; + } + *pHead = 0; + } + pRREvent->next = *pHead; + *pHead = pRREvent; + } + /* + * Now see if the client needs an event + */ + if (pScrPriv) { + pTimes = &((RRTimesPtr) (pRRClient + 1))[pScreen->myNum]; + if (CompareTimeStamps(pTimes->setTime, + pScrPriv->lastSetTime) != 0 || + CompareTimeStamps(pTimes->configTime, + pScrPriv->lastConfigTime) != 0) { + if (pRREvent->mask & RRScreenChangeNotifyMask) { + RRDeliverScreenEvent(client, pWin, pScreen); + } + + if (pRREvent->mask & RRCrtcChangeNotifyMask) { + int i; + + for (i = 0; i < pScrPriv->numCrtcs; i++) { + RRDeliverCrtcEvent(client, pWin, pScrPriv->crtcs[i]); + } + } + + if (pRREvent->mask & RROutputChangeNotifyMask) { + int i; + + for (i = 0; i < pScrPriv->numOutputs; i++) { + RRDeliverOutputEvent(client, pWin, + pScrPriv->outputs[i]); + } + } + + /* We don't check for RROutputPropertyNotifyMask, as randrproto.txt doesn't + * say if there ought to be notifications of changes to output properties + * if those changes occurred before the time RRSelectInput is called. + */ + } + } } - else if (stuff->enable == 0) - { - /* delete the interest */ - if (pHead) { - RREventPtr pNewRREvent = 0; - for (pRREvent = *pHead; pRREvent; pRREvent = pRREvent->next) { - if (pRREvent->client == client) - break; - pNewRREvent = pRREvent; - } - if (pRREvent) { - FreeResource (pRREvent->clientResource, RRClientType); - if (pNewRREvent) - pNewRREvent->next = pRREvent->next; - else - *pHead = pRREvent->next; - free(pRREvent); - } - } + else if (stuff->enable == 0) { + /* delete the interest */ + if (pHead) { + RREventPtr pNewRREvent = 0; + + for (pRREvent = *pHead; pRREvent; pRREvent = pRREvent->next) { + if (pRREvent->client == client) + break; + pNewRREvent = pRREvent; + } + if (pRREvent) { + FreeResource(pRREvent->clientResource, RRClientType); + if (pNewRREvent) + pNewRREvent->next = pRREvent->next; + else + *pHead = pRREvent->next; + free(pRREvent); + } + } } - else - { - client->errorValue = stuff->enable; - return BadValue; + else { + client->errorValue = stuff->enable; + return BadValue; } return Success; } -int (*ProcRandrVector[RRNumberRequests])(ClientPtr) = { - ProcRRQueryVersion, /* 0 */ +int (*ProcRandrVector[RRNumberRequests]) (ClientPtr) = { + ProcRRQueryVersion, /* 0 */ /* we skip 1 to make old clients fail pretty immediately */ - NULL, /* 1 ProcRandrOldGetScreenInfo */ + NULL, /* 1 ProcRandrOldGetScreenInfo */ /* V1.0 apps share the same set screen config request id */ - ProcRRSetScreenConfig, /* 2 */ - NULL, /* 3 ProcRandrOldScreenChangeSelectInput */ + ProcRRSetScreenConfig, /* 2 */ + NULL, /* 3 ProcRandrOldScreenChangeSelectInput */ /* 3 used to be ScreenChangeSelectInput; deprecated */ - ProcRRSelectInput, /* 4 */ - ProcRRGetScreenInfo, /* 5 */ + ProcRRSelectInput, /* 4 */ + ProcRRGetScreenInfo, /* 5 */ /* V1.2 additions */ - ProcRRGetScreenSizeRange, /* 6 */ - ProcRRSetScreenSize, /* 7 */ - ProcRRGetScreenResources, /* 8 */ - ProcRRGetOutputInfo, /* 9 */ - ProcRRListOutputProperties, /* 10 */ - ProcRRQueryOutputProperty, /* 11 */ - ProcRRConfigureOutputProperty, /* 12 */ - ProcRRChangeOutputProperty, /* 13 */ - ProcRRDeleteOutputProperty, /* 14 */ - ProcRRGetOutputProperty, /* 15 */ - ProcRRCreateMode, /* 16 */ - ProcRRDestroyMode, /* 17 */ - ProcRRAddOutputMode, /* 18 */ - ProcRRDeleteOutputMode, /* 19 */ - ProcRRGetCrtcInfo, /* 20 */ - ProcRRSetCrtcConfig, /* 21 */ - ProcRRGetCrtcGammaSize, /* 22 */ - ProcRRGetCrtcGamma, /* 23 */ - ProcRRSetCrtcGamma, /* 24 */ + ProcRRGetScreenSizeRange, /* 6 */ + ProcRRSetScreenSize, /* 7 */ + ProcRRGetScreenResources, /* 8 */ + ProcRRGetOutputInfo, /* 9 */ + ProcRRListOutputProperties, /* 10 */ + ProcRRQueryOutputProperty, /* 11 */ + ProcRRConfigureOutputProperty, /* 12 */ + ProcRRChangeOutputProperty, /* 13 */ + ProcRRDeleteOutputProperty, /* 14 */ + ProcRRGetOutputProperty, /* 15 */ + ProcRRCreateMode, /* 16 */ + ProcRRDestroyMode, /* 17 */ + ProcRRAddOutputMode, /* 18 */ + ProcRRDeleteOutputMode, /* 19 */ + ProcRRGetCrtcInfo, /* 20 */ + ProcRRSetCrtcConfig, /* 21 */ + ProcRRGetCrtcGammaSize, /* 22 */ + ProcRRGetCrtcGamma, /* 23 */ + ProcRRSetCrtcGamma, /* 24 */ /* V1.3 additions */ - ProcRRGetScreenResourcesCurrent, /* 25 */ - ProcRRSetCrtcTransform, /* 26 */ - ProcRRGetCrtcTransform, /* 27 */ - ProcRRGetPanning, /* 28 */ - ProcRRSetPanning, /* 29 */ - ProcRRSetOutputPrimary, /* 30 */ - ProcRRGetOutputPrimary, /* 31 */ + ProcRRGetScreenResourcesCurrent, /* 25 */ + ProcRRSetCrtcTransform, /* 26 */ + ProcRRGetCrtcTransform, /* 27 */ + ProcRRGetPanning, /* 28 */ + ProcRRSetPanning, /* 29 */ + ProcRRSetOutputPrimary, /* 30 */ + ProcRRGetOutputPrimary, /* 31 */ }; - diff --git a/xorg-server/randr/rrinfo.c b/xorg-server/randr/rrinfo.c index 02aea5245..114ec3471 100644 --- a/xorg-server/randr/rrinfo.c +++ b/xorg-server/randr/rrinfo.c @@ -24,46 +24,45 @@ #ifdef RANDR_10_INTERFACE static RRModePtr -RROldModeAdd (RROutputPtr output, RRScreenSizePtr size, int refresh) +RROldModeAdd(RROutputPtr output, RRScreenSizePtr size, int refresh) { - ScreenPtr pScreen = output->pScreen; + ScreenPtr pScreen = output->pScreen; + rrScrPriv(pScreen); - xRRModeInfo modeInfo; - char name[100]; - RRModePtr mode; - int i; - RRModePtr *modes; - - memset (&modeInfo, '\0', sizeof (modeInfo)); - snprintf (name, sizeof(name), "%dx%d", size->width, size->height); - + xRRModeInfo modeInfo; + char name[100]; + RRModePtr mode; + int i; + RRModePtr *modes; + + memset(&modeInfo, '\0', sizeof(modeInfo)); + snprintf(name, sizeof(name), "%dx%d", size->width, size->height); + modeInfo.width = size->width; modeInfo.height = size->height; modeInfo.hTotal = size->width; modeInfo.vTotal = size->height; modeInfo.dotClock = ((CARD32) size->width * (CARD32) size->height * - (CARD32) refresh); - modeInfo.nameLength = strlen (name); - mode = RRModeGet (&modeInfo, name); + (CARD32) refresh); + modeInfo.nameLength = strlen(name); + mode = RRModeGet(&modeInfo, name); if (!mode) - return NULL; + return NULL; for (i = 0; i < output->numModes; i++) - if (output->modes[i] == mode) - { - RRModeDestroy (mode); - return mode; - } - + if (output->modes[i] == mode) { + RRModeDestroy(mode); + return mode; + } + if (output->numModes) - modes = realloc(output->modes, - (output->numModes + 1) * sizeof (RRModePtr)); + modes = realloc(output->modes, + (output->numModes + 1) * sizeof(RRModePtr)); else - modes = malloc(sizeof (RRModePtr)); - if (!modes) - { - RRModeDestroy (mode); - FreeResource (mode->mode.id, 0); - return NULL; + modes = malloc(sizeof(RRModePtr)); + if (!modes) { + RRModeDestroy(mode); + FreeResource(mode->mode.id, 0); + return NULL; } modes[output->numModes++] = mode; output->modes = modes; @@ -74,101 +73,95 @@ RROldModeAdd (RROutputPtr output, RRScreenSizePtr size, int refresh) } static void -RRScanOldConfig (ScreenPtr pScreen, Rotation rotations) +RRScanOldConfig(ScreenPtr pScreen, Rotation rotations) { rrScrPriv(pScreen); - RROutputPtr output; - RRCrtcPtr crtc; - RRModePtr mode, newMode = NULL; - int i; - CARD16 minWidth = MAXSHORT, minHeight = MAXSHORT; - CARD16 maxWidth = 0, maxHeight = 0; - + RROutputPtr output; + RRCrtcPtr crtc; + RRModePtr mode, newMode = NULL; + int i; + CARD16 minWidth = MAXSHORT, minHeight = MAXSHORT; + CARD16 maxWidth = 0, maxHeight = 0; + /* * First time through, create a crtc and output and hook * them together */ - if (pScrPriv->numOutputs == 0 && - pScrPriv->numCrtcs == 0) - { - crtc = RRCrtcCreate (pScreen, NULL); - if (!crtc) - return; - output = RROutputCreate (pScreen, "default", 7, NULL); - if (!output) - return; - RROutputSetCrtcs (output, &crtc, 1); - RROutputSetConnection (output, RR_Connected); - RROutputSetSubpixelOrder (output, PictureGetSubpixelOrder (pScreen)); + if (pScrPriv->numOutputs == 0 && pScrPriv->numCrtcs == 0) { + crtc = RRCrtcCreate(pScreen, NULL); + if (!crtc) + return; + output = RROutputCreate(pScreen, "default", 7, NULL); + if (!output) + return; + RROutputSetCrtcs(output, &crtc, 1); + RROutputSetConnection(output, RR_Connected); + RROutputSetSubpixelOrder(output, PictureGetSubpixelOrder(pScreen)); } output = pScrPriv->outputs[0]; if (!output) - return; + return; crtc = pScrPriv->crtcs[0]; if (!crtc) - return; + return; /* check rotations */ - if (rotations != crtc->rotations) - { + if (rotations != crtc->rotations) { crtc->rotations = rotations; - crtc->changed = TRUE; - pScrPriv->changed = TRUE; + crtc->changed = TRUE; + pScrPriv->changed = TRUE; } - + /* regenerate mode list */ - for (i = 0; i < pScrPriv->nSizes; i++) - { - RRScreenSizePtr size = &pScrPriv->pSizes[i]; - int r; - - if (size->nRates) - { - for (r = 0; r < size->nRates; r++) - { - mode = RROldModeAdd (output, size, size->pRates[r].rate); - if (i == pScrPriv->size && - size->pRates[r].rate == pScrPriv->rate) - { - newMode = mode; - } - } - free(size->pRates); - } - else - { - mode = RROldModeAdd (output, size, 0); - if (i == pScrPriv->size) - newMode = mode; - } + for (i = 0; i < pScrPriv->nSizes; i++) { + RRScreenSizePtr size = &pScrPriv->pSizes[i]; + int r; + + if (size->nRates) { + for (r = 0; r < size->nRates; r++) { + mode = RROldModeAdd(output, size, size->pRates[r].rate); + if (i == pScrPriv->size && + size->pRates[r].rate == pScrPriv->rate) { + newMode = mode; + } + } + free(size->pRates); + } + else { + mode = RROldModeAdd(output, size, 0); + if (i == pScrPriv->size) + newMode = mode; + } } if (pScrPriv->nSizes) - free(pScrPriv->pSizes); + free(pScrPriv->pSizes); pScrPriv->pSizes = NULL; pScrPriv->nSizes = 0; - + /* find size bounds */ - for (i = 0; i < output->numModes + output->numUserModes; i++) - { - RRModePtr mode = (i < output->numModes ? - output->modes[i] : - output->userModes[i-output->numModes]); - CARD16 width = mode->mode.width; - CARD16 height = mode->mode.height; - - if (width < minWidth) minWidth = width; - if (width > maxWidth) maxWidth = width; - if (height < minHeight) minHeight = height; - if (height > maxHeight) maxHeight = height; + for (i = 0; i < output->numModes + output->numUserModes; i++) { + RRModePtr mode = (i < output->numModes ? + output->modes[i] : + output->userModes[i - output->numModes]); + CARD16 width = mode->mode.width; + CARD16 height = mode->mode.height; + + if (width < minWidth) + minWidth = width; + if (width > maxWidth) + maxWidth = width; + if (height < minHeight) + minHeight = height; + if (height > maxHeight) + maxHeight = height; } - RRScreenSetSizeRange (pScreen, minWidth, minHeight, maxWidth, maxHeight); + RRScreenSetSizeRange(pScreen, minWidth, minHeight, maxWidth, maxHeight); /* notice current mode */ if (newMode) - RRCrtcNotify (crtc, newMode, 0, 0, pScrPriv->rotation, - NULL, 1, &output); + RRCrtcNotify(crtc, newMode, 0, 0, pScrPriv->rotation, NULL, 1, &output); } #endif @@ -176,37 +169,37 @@ RRScanOldConfig (ScreenPtr pScreen, Rotation rotations) * Poll the driver for changed information */ Bool -RRGetInfo (ScreenPtr pScreen, Bool force_query) +RRGetInfo(ScreenPtr pScreen, Bool force_query) { - rrScrPriv (pScreen); - Rotation rotations; - int i; + rrScrPriv(pScreen); + Rotation rotations; + int i; /* Return immediately if we don't need to re-query and we already have the * information. */ if (!force_query) { - if (pScrPriv->numCrtcs != 0 || pScrPriv->numOutputs != 0) - return TRUE; + if (pScrPriv->numCrtcs != 0 || pScrPriv->numOutputs != 0) + return TRUE; } for (i = 0; i < pScrPriv->numOutputs; i++) - pScrPriv->outputs[i]->changed = FALSE; + pScrPriv->outputs[i]->changed = FALSE; for (i = 0; i < pScrPriv->numCrtcs; i++) - pScrPriv->crtcs[i]->changed = FALSE; - + pScrPriv->crtcs[i]->changed = FALSE; + rotations = 0; pScrPriv->changed = FALSE; pScrPriv->configChanged = FALSE; - + if (!(*pScrPriv->rrGetInfo) (pScreen, &rotations)) - return FALSE; + return FALSE; #if RANDR_10_INTERFACE if (pScrPriv->nSizes) - RRScanOldConfig (pScreen, rotations); + RRScanOldConfig(pScreen, rotations); #endif - RRTellChanged (pScreen); + RRTellChanged(pScreen); return TRUE; } @@ -214,25 +207,22 @@ RRGetInfo (ScreenPtr pScreen, Bool force_query) * Register the range of sizes for the screen */ void -RRScreenSetSizeRange (ScreenPtr pScreen, - CARD16 minWidth, - CARD16 minHeight, - CARD16 maxWidth, - CARD16 maxHeight) +RRScreenSetSizeRange(ScreenPtr pScreen, + CARD16 minWidth, + CARD16 minHeight, CARD16 maxWidth, CARD16 maxHeight) { - rrScrPriv (pScreen); + rrScrPriv(pScreen); if (!pScrPriv) - return; + return; if (pScrPriv->minWidth == minWidth && pScrPriv->minHeight == minHeight && - pScrPriv->maxWidth == maxWidth && pScrPriv->maxHeight == maxHeight) - { - return; + pScrPriv->maxWidth == maxWidth && pScrPriv->maxHeight == maxHeight) { + return; } - - pScrPriv->minWidth = minWidth; + + pScrPriv->minWidth = minWidth; pScrPriv->minHeight = minHeight; - pScrPriv->maxWidth = maxWidth; + pScrPriv->maxWidth = maxWidth; pScrPriv->maxHeight = maxHeight; pScrPriv->changed = TRUE; pScrPriv->configChanged = TRUE; @@ -240,73 +230,67 @@ RRScreenSetSizeRange (ScreenPtr pScreen, #ifdef RANDR_10_INTERFACE static Bool -RRScreenSizeMatches (RRScreenSizePtr a, - RRScreenSizePtr b) +RRScreenSizeMatches(RRScreenSizePtr a, RRScreenSizePtr b) { if (a->width != b->width) - return FALSE; + return FALSE; if (a->height != b->height) - return FALSE; + return FALSE; if (a->mmWidth != b->mmWidth) - return FALSE; + return FALSE; if (a->mmHeight != b->mmHeight) - return FALSE; + return FALSE; return TRUE; } RRScreenSizePtr -RRRegisterSize (ScreenPtr pScreen, - short width, - short height, - short mmWidth, - short mmHeight) +RRRegisterSize(ScreenPtr pScreen, + short width, short height, short mmWidth, short mmHeight) { - rrScrPriv (pScreen); - int i; - RRScreenSize tmp; + rrScrPriv(pScreen); + int i; + RRScreenSize tmp; RRScreenSizePtr pNew; if (!pScrPriv) - return 0; - + return 0; + tmp.id = 0; tmp.width = width; - tmp.height= height; + tmp.height = height; tmp.mmWidth = mmWidth; tmp.mmHeight = mmHeight; tmp.pRates = 0; tmp.nRates = 0; for (i = 0; i < pScrPriv->nSizes; i++) - if (RRScreenSizeMatches (&tmp, &pScrPriv->pSizes[i])) - return &pScrPriv->pSizes[i]; + if (RRScreenSizeMatches(&tmp, &pScrPriv->pSizes[i])) + return &pScrPriv->pSizes[i]; pNew = realloc(pScrPriv->pSizes, - (pScrPriv->nSizes + 1) * sizeof (RRScreenSize)); + (pScrPriv->nSizes + 1) * sizeof(RRScreenSize)); if (!pNew) - return 0; + return 0; pNew[pScrPriv->nSizes++] = tmp; pScrPriv->pSizes = pNew; - return &pNew[pScrPriv->nSizes-1]; + return &pNew[pScrPriv->nSizes - 1]; } -Bool RRRegisterRate (ScreenPtr pScreen, - RRScreenSizePtr pSize, - int rate) +Bool +RRRegisterRate(ScreenPtr pScreen, RRScreenSizePtr pSize, int rate) { rrScrPriv(pScreen); - int i; + int i; RRScreenRatePtr pNew, pRate; if (!pScrPriv) - return FALSE; - + return FALSE; + for (i = 0; i < pSize->nRates; i++) - if (pSize->pRates[i].rate == rate) - return TRUE; + if (pSize->pRates[i].rate == rate) + return TRUE; - pNew = realloc(pSize->pRates, - (pSize->nRates + 1) * sizeof (RRScreenRate)); + pNew = realloc(pSize->pRates, (pSize->nRates + 1) * sizeof(RRScreenRate)); if (!pNew) - return FALSE; + return FALSE; pRate = &pNew[pSize->nRates++]; pRate->rate = rate; pSize->pRates = pNew; @@ -316,24 +300,22 @@ Bool RRRegisterRate (ScreenPtr pScreen, Rotation RRGetRotation(ScreenPtr pScreen) { - RROutputPtr output = RRFirstOutput (pScreen); + RROutputPtr output = RRFirstOutput(pScreen); if (!output) - return RR_Rotate_0; + return RR_Rotate_0; return output->crtc->rotation; } void -RRSetCurrentConfig (ScreenPtr pScreen, - Rotation rotation, - int rate, - RRScreenSizePtr pSize) +RRSetCurrentConfig(ScreenPtr pScreen, + Rotation rotation, int rate, RRScreenSizePtr pSize) { - rrScrPriv (pScreen); + rrScrPriv(pScreen); if (!pScrPriv) - return; + return; pScrPriv->size = pSize - pScrPriv->pSizes; pScrPriv->rotation = rotation; pScrPriv->rate = rate; diff --git a/xorg-server/randr/rrmode.c b/xorg-server/randr/rrmode.c index 63a2d2a74..b637c06b9 100644 --- a/xorg-server/randr/rrmode.c +++ b/xorg-server/randr/rrmode.c @@ -22,69 +22,78 @@ #include "randrstr.h" -RESTYPE RRModeType; +RESTYPE RRModeType; static Bool -RRModeEqual (xRRModeInfo *a, xRRModeInfo *b) +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; + 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 int num_modes; +static RRModePtr *modes; static RRModePtr -RRModeCreate (xRRModeInfo *modeInfo, - const char *name, - ScreenPtr userScreen) +RRModeCreate(xRRModeInfo * modeInfo, const char *name, ScreenPtr userScreen) { - RRModePtr mode, *newModes; - - if (!RRInit ()) - return NULL; + RRModePtr mode, *newModes; - mode = malloc(sizeof (RRModeRec) + modeInfo->nameLength + 1); + if (!RRInit()) + return NULL; + + mode = malloc(sizeof(RRModeRec) + modeInfo->nameLength + 1); if (!mode) - return NULL; + return NULL; mode->refcnt = 1; mode->mode = *modeInfo; mode->name = (char *) (mode + 1); - memcpy (mode->name, name, modeInfo->nameLength); + 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)); + newModes = realloc(modes, (num_modes + 1) * sizeof(RRModePtr)); else - newModes = malloc(sizeof (RRModePtr)); + newModes = malloc(sizeof(RRModePtr)); - if (!newModes) - { - free(mode); - return NULL; + if (!newModes) { + free(mode); + return NULL; } mode->mode.id = FakeClientID(0); - if (!AddResource (mode->mode.id, RRModeType, (pointer) mode)) - return NULL; + if (!AddResource(mode->mode.id, RRModeType, (pointer) mode)) + return NULL; modes = newModes; modes[num_modes++] = mode; - + /* * give the caller a reference to this mode */ @@ -93,170 +102,155 @@ RRModeCreate (xRRModeInfo *modeInfo, } static RRModePtr -RRModeFindByName (const char *name, - CARD16 nameLength) +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; - } + 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) +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; - } + 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); + return RRModeCreate(modeInfo, name, NULL); } static RRModePtr -RRModeCreateUser (ScreenPtr pScreen, - xRRModeInfo *modeInfo, - const char *name, - int *error) +RRModeCreateUser(ScreenPtr pScreen, + xRRModeInfo * modeInfo, const char *name, int *error) { - RRModePtr mode; + RRModePtr mode; - mode = RRModeFindByName (name, modeInfo->nameLength); - if (mode) - { - *error = BadName; - return NULL; + mode = RRModeFindByName(name, modeInfo->nameLength); + if (mode) { + *error = BadName; + return NULL; } - - mode = RRModeCreate (modeInfo, name, pScreen); - if (!mode) - { - *error = BadAlloc; - return NULL; + + mode = RRModeCreate(modeInfo, name, pScreen); + if (!mode) { + *error = BadAlloc; + return NULL; } *error = Success; return mode; } RRModePtr * -RRModesForScreen (ScreenPtr pScreen, int *num_ret) +RRModesForScreen(ScreenPtr pScreen, int *num_ret) { rrScrPriv(pScreen); - int o, c, m; - RRModePtr *screen_modes; - int num_screen_modes = 0; + int o, c, m; + RRModePtr *screen_modes; + int num_screen_modes = 0; - screen_modes = malloc((num_modes ? num_modes : 1) * sizeof (RRModePtr)); + screen_modes = malloc((num_modes ? num_modes : 1) * sizeof(RRModePtr)); if (!screen_modes) - return NULL; - + 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; - } + 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; + 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; + 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) +RRModeDestroy(RRModePtr mode) { - int m; - + 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; - } + 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) +RRModeDestroyResource(pointer value, XID pid) { - RRModeDestroy ((RRModePtr) value); + RRModeDestroy((RRModePtr) value); return 1; } @@ -264,14 +258,14 @@ RRModeDestroyResource (pointer value, XID pid) * Initialize mode type */ Bool -RRModeInit (void) +RRModeInit(void) { - assert (num_modes == 0); - assert (modes == NULL); - RRModeType = CreateNewResourceType (RRModeDestroyResource, "MODE"); + assert(num_modes == 0); + assert(modes == NULL); + RRModeType = CreateNewResourceType(RRModeDestroyResource, "MODE"); if (!RRModeType) - return FALSE; - + return FALSE; + return TRUE; } @@ -285,97 +279,96 @@ RRModeInitErrorValue(void) } int -ProcRRCreateMode (ClientPtr client) +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); + 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; + 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))); + 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; + return BadLength; - mode = RRModeCreateUser (pScreen, modeInfo, name, &error); + mode = RRModeCreateUser(pScreen, modeInfo, name, &error); if (!mode) - return error; + 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); + if (client->swapped) { + swaps(&rep.sequenceNumber); + swapl(&rep.length); + swapl(&rep.mode); } - WriteToClient(client, sizeof(xRRCreateModeReply), (char *)&rep); + WriteToClient(client, sizeof(xRRCreateModeReply), (char *) &rep); /* Drop out reference to this mode */ - RRModeDestroy (mode); + RRModeDestroy(mode); return Success; } int -ProcRRDestroyMode (ClientPtr client) +ProcRRDestroyMode(ClientPtr client) { REQUEST(xRRDestroyModeReq); - RRModePtr mode; - + RRModePtr mode; + REQUEST_SIZE_MATCH(xRRDestroyModeReq); VERIFY_RR_MODE(stuff->mode, mode, DixDestroyAccess); if (!mode->userScreen) - return BadMatch; + return BadMatch; if (mode->refcnt > 1) - return BadAccess; - FreeResource (stuff->mode, 0); + return BadAccess; + FreeResource(stuff->mode, 0); return Success; } int -ProcRRAddOutputMode (ClientPtr client) +ProcRRAddOutputMode(ClientPtr client) { REQUEST(xRRAddOutputModeReq); - RRModePtr mode; - RROutputPtr output; - + 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); + + return RROutputAddUserMode(output, mode); } int -ProcRRDeleteOutputMode (ClientPtr client) +ProcRRDeleteOutputMode(ClientPtr client) { REQUEST(xRRDeleteOutputModeReq); - RRModePtr mode; - RROutputPtr output; - + 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); + + return RROutputDeleteUserMode(output, mode); } diff --git a/xorg-server/randr/rroutput.c b/xorg-server/randr/rroutput.c index b57be198f..0890c55b5 100644 --- a/xorg-server/randr/rroutput.c +++ b/xorg-server/randr/rroutput.c @@ -23,23 +23,22 @@ #include "randrstr.h" -RESTYPE RROutputType; +RESTYPE RROutputType; /* * Notify the output of some change */ void -RROutputChanged (RROutputPtr output, Bool configChanged) +RROutputChanged(RROutputPtr output, Bool configChanged) { - ScreenPtr pScreen = output->pScreen; - + ScreenPtr pScreen = output->pScreen; + output->changed = TRUE; - if (pScreen) - { - rrScrPriv (pScreen); - pScrPriv->changed = TRUE; - if (configChanged) - pScrPriv->configChanged = TRUE; + if (pScreen) { + rrScrPriv(pScreen); + pScrPriv->changed = TRUE; + if (configChanged) + pScrPriv->configChanged = TRUE; } } @@ -48,38 +47,36 @@ RROutputChanged (RROutputPtr output, Bool configChanged) */ RROutputPtr -RROutputCreate (ScreenPtr pScreen, - const char *name, - int nameLength, - void *devPrivate) +RROutputCreate(ScreenPtr pScreen, + const char *name, int nameLength, void *devPrivate) { - RROutputPtr output; - RROutputPtr *outputs; - rrScrPrivPtr pScrPriv; + RROutputPtr output; + RROutputPtr *outputs; + rrScrPrivPtr pScrPriv; if (!RRInit()) - return NULL; - + return NULL; + pScrPriv = rrGetScrPriv(pScreen); if (pScrPriv->numOutputs) - outputs = realloc(pScrPriv->outputs, - (pScrPriv->numOutputs + 1) * sizeof (RROutputPtr)); + outputs = realloc(pScrPriv->outputs, + (pScrPriv->numOutputs + 1) * sizeof(RROutputPtr)); else - outputs = malloc(sizeof (RROutputPtr)); + outputs = malloc(sizeof(RROutputPtr)); if (!outputs) - return FALSE; + return FALSE; pScrPriv->outputs = outputs; - - output = malloc(sizeof (RROutputRec) + nameLength + 1); + + output = malloc(sizeof(RROutputRec) + nameLength + 1); if (!output) - return NULL; - output->id = FakeClientID (0); + return NULL; + output->id = FakeClientID(0); output->pScreen = pScreen; output->name = (char *) (output + 1); output->nameLength = nameLength; - memcpy (output->name, name, nameLength); + memcpy(output->name, name, nameLength); output->name[nameLength] = '\0'; output->connection = RR_UnknownConnection; output->subpixelOrder = SubPixelUnknown; @@ -99,9 +96,9 @@ RROutputCreate (ScreenPtr pScreen, output->pendingProperties = FALSE; output->changed = FALSE; output->devPrivate = devPrivate; - - if (!AddResource (output->id, RROutputType, (pointer) output)) - return NULL; + + if (!AddResource(output->id, RROutputType, (pointer) output)) + return NULL; pScrPriv->outputs[pScrPriv->numOutputs++] = output; return output; @@ -111,300 +108,273 @@ RROutputCreate (ScreenPtr pScreen, * Notify extension that output parameters have been changed */ Bool -RROutputSetClones (RROutputPtr output, - RROutputPtr *clones, - int numClones) +RROutputSetClones(RROutputPtr output, RROutputPtr * clones, int numClones) { - RROutputPtr *newClones; - int i; - - if (numClones == output->numClones) - { - for (i = 0; i < numClones; i++) - if (output->clones[i] != clones[i]) - break; - if (i == numClones) - return TRUE; + RROutputPtr *newClones; + int i; + + if (numClones == output->numClones) { + for (i = 0; i < numClones; i++) + if (output->clones[i] != clones[i]) + break; + if (i == numClones) + return TRUE; } - if (numClones) - { - newClones = malloc(numClones * sizeof (RROutputPtr)); - if (!newClones) - return FALSE; + if (numClones) { + newClones = malloc(numClones * sizeof(RROutputPtr)); + if (!newClones) + return FALSE; } else - newClones = NULL; + newClones = NULL; free(output->clones); - memcpy (newClones, clones, numClones * sizeof (RROutputPtr)); + memcpy(newClones, clones, numClones * sizeof(RROutputPtr)); output->clones = newClones; output->numClones = numClones; - RROutputChanged (output, TRUE); + RROutputChanged(output, TRUE); return TRUE; } Bool -RROutputSetModes (RROutputPtr output, - RRModePtr *modes, - int numModes, - int numPreferred) +RROutputSetModes(RROutputPtr output, + RRModePtr * modes, int numModes, int numPreferred) { - RRModePtr *newModes; - int i; - - if (numModes == output->numModes && numPreferred == output->numPreferred) - { - for (i = 0; i < numModes; i++) - if (output->modes[i] != modes[i]) - break; - if (i == numModes) - { - for (i = 0; i < numModes; i++) - RRModeDestroy (modes[i]); - return TRUE; - } + RRModePtr *newModes; + int i; + + if (numModes == output->numModes && numPreferred == output->numPreferred) { + for (i = 0; i < numModes; i++) + if (output->modes[i] != modes[i]) + break; + if (i == numModes) { + for (i = 0; i < numModes; i++) + RRModeDestroy(modes[i]); + return TRUE; + } } - if (numModes) - { - newModes = malloc(numModes * sizeof (RRModePtr)); - if (!newModes) - return FALSE; + if (numModes) { + newModes = malloc(numModes * sizeof(RRModePtr)); + if (!newModes) + return FALSE; } else - newModes = NULL; - if (output->modes) - { - for (i = 0; i < output->numModes; i++) - RRModeDestroy (output->modes[i]); - free(output->modes); + newModes = NULL; + if (output->modes) { + for (i = 0; i < output->numModes; i++) + RRModeDestroy(output->modes[i]); + free(output->modes); } - memcpy (newModes, modes, numModes * sizeof (RRModePtr)); + memcpy(newModes, modes, numModes * sizeof(RRModePtr)); output->modes = newModes; output->numModes = numModes; output->numPreferred = numPreferred; - RROutputChanged (output, TRUE); + RROutputChanged(output, TRUE); return TRUE; } int -RROutputAddUserMode (RROutputPtr output, - RRModePtr mode) +RROutputAddUserMode(RROutputPtr output, RRModePtr mode) { - int m; - ScreenPtr pScreen = output->pScreen; + int m; + ScreenPtr pScreen = output->pScreen; + rrScrPriv(pScreen); - RRModePtr *newModes; + RRModePtr *newModes; /* Check to see if this mode is already listed for this output */ - for (m = 0; m < output->numModes + output->numUserModes; m++) - { - RRModePtr e = (m < output->numModes ? - output->modes[m] : - output->userModes[m - output->numModes]); - if (mode == e) - return Success; + for (m = 0; m < output->numModes + output->numUserModes; m++) { + RRModePtr e = (m < output->numModes ? + output->modes[m] : + output->userModes[m - output->numModes]); + if (mode == e) + return Success; } /* Check with the DDX to see if this mode is OK */ if (pScrPriv->rrOutputValidateMode) - if (!pScrPriv->rrOutputValidateMode (pScreen, output, mode)) - return BadMatch; + if (!pScrPriv->rrOutputValidateMode(pScreen, output, mode)) + return BadMatch; if (output->userModes) - newModes = realloc(output->userModes, - (output->numUserModes + 1) * sizeof (RRModePtr)); + newModes = realloc(output->userModes, + (output->numUserModes + 1) * sizeof(RRModePtr)); else - newModes = malloc(sizeof (RRModePtr)); + newModes = malloc(sizeof(RRModePtr)); if (!newModes) - return BadAlloc; + return BadAlloc; output->userModes = newModes; output->userModes[output->numUserModes++] = mode; ++mode->refcnt; - RROutputChanged (output, TRUE); - RRTellChanged (pScreen); + RROutputChanged(output, TRUE); + RRTellChanged(pScreen); return Success; } int -RROutputDeleteUserMode (RROutputPtr output, - RRModePtr mode) +RROutputDeleteUserMode(RROutputPtr output, RRModePtr mode) { - int m; - + int m; + /* Find this mode in the user mode list */ - for (m = 0; m < output->numUserModes; m++) - { - RRModePtr e = output->userModes[m]; + for (m = 0; m < output->numUserModes; m++) { + RRModePtr e = output->userModes[m]; - if (mode == e) - break; + if (mode == e) + break; } /* Not there, access error */ if (m == output->numUserModes) - return BadAccess; + return BadAccess; /* make sure the mode isn't active for this output */ if (output->crtc && output->crtc->mode == mode) - return BadMatch; + return BadMatch; - memmove (output->userModes + m, output->userModes + m + 1, - (output->numUserModes - m - 1) * sizeof (RRModePtr)); + memmove(output->userModes + m, output->userModes + m + 1, + (output->numUserModes - m - 1) * sizeof(RRModePtr)); output->numUserModes--; - RRModeDestroy (mode); + RRModeDestroy(mode); return Success; } Bool -RROutputSetCrtcs (RROutputPtr output, - RRCrtcPtr *crtcs, - int numCrtcs) +RROutputSetCrtcs(RROutputPtr output, RRCrtcPtr * crtcs, int numCrtcs) { - RRCrtcPtr *newCrtcs; - int i; - - if (numCrtcs == output->numCrtcs) - { - for (i = 0; i < numCrtcs; i++) - if (output->crtcs[i] != crtcs[i]) - break; - if (i == numCrtcs) - return TRUE; + RRCrtcPtr *newCrtcs; + int i; + + if (numCrtcs == output->numCrtcs) { + for (i = 0; i < numCrtcs; i++) + if (output->crtcs[i] != crtcs[i]) + break; + if (i == numCrtcs) + return TRUE; } - if (numCrtcs) - { - newCrtcs = malloc(numCrtcs * sizeof (RRCrtcPtr)); - if (!newCrtcs) - return FALSE; + if (numCrtcs) { + newCrtcs = malloc(numCrtcs * sizeof(RRCrtcPtr)); + if (!newCrtcs) + return FALSE; } else - newCrtcs = NULL; + newCrtcs = NULL; free(output->crtcs); - memcpy (newCrtcs, crtcs, numCrtcs * sizeof (RRCrtcPtr)); + memcpy(newCrtcs, crtcs, numCrtcs * sizeof(RRCrtcPtr)); output->crtcs = newCrtcs; output->numCrtcs = numCrtcs; - RROutputChanged (output, TRUE); + RROutputChanged(output, TRUE); return TRUE; } Bool -RROutputSetConnection (RROutputPtr output, - CARD8 connection) +RROutputSetConnection(RROutputPtr output, CARD8 connection) { if (output->connection == connection) - return TRUE; + return TRUE; output->connection = connection; - RROutputChanged (output, TRUE); + RROutputChanged(output, TRUE); return TRUE; } Bool -RROutputSetSubpixelOrder (RROutputPtr output, - int subpixelOrder) +RROutputSetSubpixelOrder(RROutputPtr output, int subpixelOrder) { if (output->subpixelOrder == subpixelOrder) - return TRUE; + return TRUE; output->subpixelOrder = subpixelOrder; - RROutputChanged (output, FALSE); + RROutputChanged(output, FALSE); return TRUE; } Bool -RROutputSetPhysicalSize (RROutputPtr output, - int mmWidth, - int mmHeight) +RROutputSetPhysicalSize(RROutputPtr output, int mmWidth, int mmHeight) { if (output->mmWidth == mmWidth && output->mmHeight == mmHeight) - return TRUE; + return TRUE; output->mmWidth = mmWidth; output->mmHeight = mmHeight; - RROutputChanged (output, FALSE); + RROutputChanged(output, FALSE); return TRUE; } - void RRDeliverOutputEvent(ClientPtr client, WindowPtr pWin, RROutputPtr output) { ScreenPtr pScreen = pWin->drawable.pScreen; - rrScrPriv (pScreen); - xRROutputChangeNotifyEvent oe; - RRCrtcPtr crtc = output->crtc; - RRModePtr mode = crtc ? crtc->mode : 0; - + + rrScrPriv(pScreen); + xRROutputChangeNotifyEvent oe; + RRCrtcPtr crtc = output->crtc; + RRModePtr mode = crtc ? crtc->mode : 0; + oe.type = RRNotify + RREventBase; oe.subCode = RRNotify_OutputChange; oe.timestamp = pScrPriv->lastSetTime.milliseconds; oe.configTimestamp = pScrPriv->lastConfigTime.milliseconds; oe.window = pWin->drawable.id; oe.output = output->id; - if (crtc) - { - oe.crtc = crtc->id; - oe.mode = mode ? mode->mode.id : None; - oe.rotation = crtc->rotation; + if (crtc) { + oe.crtc = crtc->id; + oe.mode = mode ? mode->mode.id : None; + oe.rotation = crtc->rotation; } - else - { - oe.crtc = None; - oe.mode = None; - oe.rotation = RR_Rotate_0; + else { + oe.crtc = None; + oe.mode = None; + oe.rotation = RR_Rotate_0; } oe.connection = output->connection; oe.subpixelOrder = output->subpixelOrder; - WriteEventsToClient (client, 1, (xEvent *) &oe); + WriteEventsToClient(client, 1, (xEvent *) &oe); } /* * Destroy a Output at shutdown */ void -RROutputDestroy (RROutputPtr output) +RROutputDestroy(RROutputPtr output) { - FreeResource (output->id, 0); + FreeResource(output->id, 0); } static int -RROutputDestroyResource (pointer value, XID pid) +RROutputDestroyResource(pointer value, XID pid) { - RROutputPtr output = (RROutputPtr) value; - ScreenPtr pScreen = output->pScreen; - int m; - - if (pScreen) - { - rrScrPriv(pScreen); - int i; - - if (pScrPriv->primaryOutput == output) - pScrPriv->primaryOutput = NULL; - - for (i = 0; i < pScrPriv->numOutputs; i++) - { - if (pScrPriv->outputs[i] == output) - { - memmove (pScrPriv->outputs + i, pScrPriv->outputs + i + 1, - (pScrPriv->numOutputs - (i + 1)) * sizeof (RROutputPtr)); - --pScrPriv->numOutputs; - break; - } - } + RROutputPtr output = (RROutputPtr) value; + ScreenPtr pScreen = output->pScreen; + int m; + + if (pScreen) { + rrScrPriv(pScreen); + int i; + + if (pScrPriv->primaryOutput == output) + pScrPriv->primaryOutput = NULL; + + for (i = 0; i < pScrPriv->numOutputs; i++) { + if (pScrPriv->outputs[i] == output) { + memmove(pScrPriv->outputs + i, pScrPriv->outputs + i + 1, + (pScrPriv->numOutputs - (i + 1)) * sizeof(RROutputPtr)); + --pScrPriv->numOutputs; + break; + } + } } - if (output->modes) - { - for (m = 0; m < output->numModes; m++) - RRModeDestroy (output->modes[m]); - free(output->modes); + if (output->modes) { + for (m = 0; m < output->numModes; m++) + RRModeDestroy(output->modes[m]); + free(output->modes); } - + for (m = 0; m < output->numUserModes; m++) - RRModeDestroy (output->userModes[m]); + RRModeDestroy(output->userModes[m]); free(output->userModes); free(output->crtcs); free(output->clones); - RRDeleteAllOutputProperties (output); + RRDeleteAllOutputProperties(output); free(output); return 1; } @@ -413,11 +383,11 @@ RROutputDestroyResource (pointer value, XID pid) * Initialize output type */ Bool -RROutputInit (void) +RROutputInit(void) { - RROutputType = CreateNewResourceType (RROutputDestroyResource, "OUTPUT"); + RROutputType = CreateNewResourceType(RROutputDestroyResource, "OUTPUT"); if (!RROutputType) - return FALSE; + return FALSE; return TRUE; } @@ -434,21 +404,21 @@ RROutputInitErrorValue(void) #define OutputInfoExtra (SIZEOF(xRRGetOutputInfoReply) - 32) int -ProcRRGetOutputInfo (ClientPtr client) +ProcRRGetOutputInfo(ClientPtr client) { REQUEST(xRRGetOutputInfoReq); - xRRGetOutputInfoReply rep; - RROutputPtr output; - CARD8 *extra; - unsigned long extraLen; - ScreenPtr pScreen; - rrScrPrivPtr pScrPriv; - RRCrtc *crtcs; - RRMode *modes; - RROutput *clones; - char *name; - int i; - + xRRGetOutputInfoReply rep; + RROutputPtr output; + CARD8 *extra; + unsigned long extraLen; + ScreenPtr pScreen; + rrScrPrivPtr pScrPriv; + RRCrtc *crtcs; + RRMode *modes; + RROutput *clones; + char *name; + int i; + REQUEST_SIZE_MATCH(xRRGetOutputInfoReq); VERIFY_RR_OUTPUT(stuff->output, output, DixReadAccess); @@ -469,88 +439,81 @@ ProcRRGetOutputInfo (ClientPtr client) rep.nPreferred = output->numPreferred; rep.nClones = output->numClones; rep.nameLength = output->nameLength; - + extraLen = ((output->numCrtcs + - output->numModes + output->numUserModes + - output->numClones + - bytes_to_int32(rep.nameLength)) << 2); - - if (extraLen) - { - rep.length += bytes_to_int32(extraLen); - extra = malloc(extraLen); - if (!extra) - return BadAlloc; + output->numModes + output->numUserModes + + output->numClones + bytes_to_int32(rep.nameLength)) << 2); + + if (extraLen) { + rep.length += bytes_to_int32(extraLen); + extra = malloc(extraLen); + if (!extra) + return BadAlloc; } else - extra = NULL; + extra = NULL; crtcs = (RRCrtc *) extra; modes = (RRMode *) (crtcs + output->numCrtcs); clones = (RROutput *) (modes + output->numModes + output->numUserModes); name = (char *) (clones + output->numClones); - - for (i = 0; i < output->numCrtcs; i++) - { - crtcs[i] = output->crtcs[i]->id; - if (client->swapped) - swapl(&crtcs[i]); + + for (i = 0; i < output->numCrtcs; i++) { + crtcs[i] = output->crtcs[i]->id; + if (client->swapped) + swapl(&crtcs[i]); } - for (i = 0; i < output->numModes + output->numUserModes; i++) - { - if (i < output->numModes) - modes[i] = output->modes[i]->mode.id; - else - modes[i] = output->userModes[i - output->numModes]->mode.id; - if (client->swapped) - swapl(&modes[i]); + for (i = 0; i < output->numModes + output->numUserModes; i++) { + if (i < output->numModes) + modes[i] = output->modes[i]->mode.id; + else + modes[i] = output->userModes[i - output->numModes]->mode.id; + if (client->swapped) + swapl(&modes[i]); } - for (i = 0; i < output->numClones; i++) - { - clones[i] = output->clones[i]->id; - if (client->swapped) - swapl(&clones[i]); + for (i = 0; i < output->numClones; i++) { + clones[i] = output->clones[i]->id; + if (client->swapped) + swapl(&clones[i]); } - memcpy (name, output->name, output->nameLength); + memcpy(name, output->name, output->nameLength); if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - swapl(&rep.timestamp); - swapl(&rep.crtc); - swapl(&rep.mmWidth); - swapl(&rep.mmHeight); - swaps(&rep.nCrtcs); - swaps(&rep.nModes); - swaps(&rep.nClones); - swaps(&rep.nameLength); + swaps(&rep.sequenceNumber); + swapl(&rep.length); + swapl(&rep.timestamp); + swapl(&rep.crtc); + swapl(&rep.mmWidth); + swapl(&rep.mmHeight); + swaps(&rep.nCrtcs); + swaps(&rep.nModes); + swaps(&rep.nClones); + swaps(&rep.nameLength); } - WriteToClient(client, sizeof(xRRGetOutputInfoReply), (char *)&rep); - if (extraLen) - { - WriteToClient (client, extraLen, (char *) extra); - free(extra); + WriteToClient(client, sizeof(xRRGetOutputInfoReply), (char *) &rep); + if (extraLen) { + WriteToClient(client, extraLen, (char *) extra); + free(extra); } - + return Success; } static void -RRSetPrimaryOutput(ScreenPtr pScreen, rrScrPrivPtr pScrPriv, - RROutputPtr output) +RRSetPrimaryOutput(ScreenPtr pScreen, rrScrPrivPtr pScrPriv, RROutputPtr output) { if (pScrPriv->primaryOutput == output) - return; + return; /* clear the old primary */ if (pScrPriv->primaryOutput) { - RROutputChanged(pScrPriv->primaryOutput, 0); - pScrPriv->primaryOutput = NULL; + RROutputChanged(pScrPriv->primaryOutput, 0); + pScrPriv->primaryOutput = NULL; } /* set the new primary */ if (output) { - pScrPriv->primaryOutput = output; - RROutputChanged(output, 0); + pScrPriv->primaryOutput = output; + RROutputChanged(output, 0); } pScrPriv->layoutChanged = TRUE; @@ -571,15 +534,15 @@ ProcRRSetOutputPrimary(ClientPtr client) rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); if (rc != Success) - return rc; + return rc; if (stuff->output) { - VERIFY_RR_OUTPUT(stuff->output, output, DixReadAccess); + VERIFY_RR_OUTPUT(stuff->output, output, DixReadAccess); - if (output->pScreen != pWin->drawable.pScreen) { - client->errorValue = stuff->window; - return BadMatch; - } + if (output->pScreen != pWin->drawable.pScreen) { + client->errorValue = stuff->window; + return BadMatch; + } } pScrPriv = rrGetScrPriv(pWin->drawable.pScreen); @@ -602,11 +565,11 @@ ProcRRGetOutputPrimary(ClientPtr client) rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); if (rc != Success) - return rc; + return rc; pScrPriv = rrGetScrPriv(pWin->drawable.pScreen); if (pScrPriv) - primary = pScrPriv->primaryOutput; + primary = pScrPriv->primaryOutput; memset(&rep, 0, sizeof(rep)); rep.type = X_Reply; @@ -614,8 +577,8 @@ ProcRRGetOutputPrimary(ClientPtr client) rep.output = primary ? primary->id : None; if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.output); + swaps(&rep.sequenceNumber); + swapl(&rep.output); } WriteToClient(client, sizeof(xRRGetOutputPrimaryReply), &rep); diff --git a/xorg-server/randr/rrpointer.c b/xorg-server/randr/rrpointer.c index 6b934c0c6..ec803e9d1 100644 --- a/xorg-server/randr/rrpointer.c +++ b/xorg-server/randr/rrpointer.c @@ -32,19 +32,19 @@ */ static Bool -RRCrtcContainsPosition (RRCrtcPtr crtc, int x, int y) +RRCrtcContainsPosition(RRCrtcPtr crtc, int x, int y) { - RRModePtr mode = crtc->mode; - int scan_width, scan_height; + RRModePtr mode = crtc->mode; + int scan_width, scan_height; if (!mode) - return FALSE; + return FALSE; - RRCrtcGetScanoutSize (crtc, &scan_width, &scan_height); + RRCrtcGetScanoutSize(crtc, &scan_width, &scan_height); if (crtc->x <= x && x < crtc->x + scan_width && - crtc->y <= y && y < crtc->y + scan_height) - return TRUE; + crtc->y <= y && y < crtc->y + scan_height) + return TRUE; return FALSE; } @@ -52,81 +52,79 @@ RRCrtcContainsPosition (RRCrtcPtr crtc, int x, int y) * Find the CRTC nearest the specified position, ignoring 'skip' */ static void -RRPointerToNearestCrtc (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y, RRCrtcPtr skip) +RRPointerToNearestCrtc(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y, + RRCrtcPtr skip) { - rrScrPriv (pScreen); - int c; - RRCrtcPtr nearest = NULL; - int best = 0; - int best_dx = 0, best_dy = 0; - - for (c = 0; c < pScrPriv->numCrtcs; c++) - { - RRCrtcPtr crtc = pScrPriv->crtcs[c]; - RRModePtr mode = crtc->mode; - int dx, dy; - int dist; - int scan_width, scan_height; - - if (!mode) - continue; - if (crtc == skip) - continue; - - RRCrtcGetScanoutSize (crtc, &scan_width, &scan_height); - - if (x < crtc->x) - dx = crtc->x - x; - else if (x > crtc->x + scan_width) - dx = x - (crtc->x + scan_width); - else - dx = 0; - if (y < crtc->y) - dy = crtc->y - x; - else if (y > crtc->y + scan_height) - dy = y - (crtc->y + scan_height); - else - dy = 0; - dist = dx + dy; - if (!nearest || dist < best) - { - nearest = crtc; - best_dx = dx; - best_dy = dy; - } + rrScrPriv(pScreen); + int c; + RRCrtcPtr nearest = NULL; + int best = 0; + int best_dx = 0, best_dy = 0; + + for (c = 0; c < pScrPriv->numCrtcs; c++) { + RRCrtcPtr crtc = pScrPriv->crtcs[c]; + RRModePtr mode = crtc->mode; + int dx, dy; + int dist; + int scan_width, scan_height; + + if (!mode) + continue; + if (crtc == skip) + continue; + + RRCrtcGetScanoutSize(crtc, &scan_width, &scan_height); + + if (x < crtc->x) + dx = crtc->x - x; + else if (x > crtc->x + scan_width) + dx = x - (crtc->x + scan_width); + else + dx = 0; + if (y < crtc->y) + dy = crtc->y - x; + else if (y > crtc->y + scan_height) + dy = y - (crtc->y + scan_height); + else + dy = 0; + dist = dx + dy; + if (!nearest || dist < best) { + nearest = crtc; + best_dx = dx; + best_dy = dy; + } } if (best_dx || best_dy) - (*pScreen->SetCursorPosition) (pDev, pScreen, x + best_dx, y + best_dy, TRUE); + (*pScreen->SetCursorPosition) (pDev, pScreen, x + best_dx, y + best_dy, + TRUE); pScrPriv->pointerCrtc = nearest; } void -RRPointerMoved (ScreenPtr pScreen, int x, int y) +RRPointerMoved(ScreenPtr pScreen, int x, int y) { - rrScrPriv (pScreen); - RRCrtcPtr pointerCrtc = pScrPriv->pointerCrtc; - int c; + rrScrPriv(pScreen); + RRCrtcPtr pointerCrtc = pScrPriv->pointerCrtc; + int c; /* Check last known CRTC */ - if (pointerCrtc && RRCrtcContainsPosition (pointerCrtc, x, y)) - return; - + if (pointerCrtc && RRCrtcContainsPosition(pointerCrtc, x, y)) + return; + /* Check all CRTCs */ - for (c = 0; c < pScrPriv->numCrtcs; c++) - { - RRCrtcPtr crtc = pScrPriv->crtcs[c]; - - if (RRCrtcContainsPosition (crtc, x, y)) - { - /* Remember containing CRTC */ - pScrPriv->pointerCrtc = crtc; - return; - } + for (c = 0; c < pScrPriv->numCrtcs; c++) { + RRCrtcPtr crtc = pScrPriv->crtcs[c]; + + if (RRCrtcContainsPosition(crtc, x, y)) { + /* Remember containing CRTC */ + pScrPriv->pointerCrtc = crtc; + return; + } } /* None contain pointer, find nearest */ ErrorF("RRPointerMoved: Untested, may cause \"bogus pointer event\"\n"); - RRPointerToNearestCrtc (inputInfo.pointer, pScreen, x, y, pointerCrtc); + RRPointerToNearestCrtc(inputInfo.pointer, pScreen, x, y, pointerCrtc); } /* @@ -134,24 +132,21 @@ RRPointerMoved (ScreenPtr pScreen, int x, int y) * CRTC */ void -RRPointerScreenConfigured (ScreenPtr pScreen) +RRPointerScreenConfigured(ScreenPtr pScreen) { - WindowPtr pRoot; - ScreenPtr pCurrentScreen; - int x, y; + WindowPtr pRoot; + ScreenPtr pCurrentScreen; + int x, y; DeviceIntPtr pDev; - for (pDev = inputInfo.devices; pDev; pDev = pDev->next) - { - if (IsPointerDevice(pDev)) - { + for (pDev = inputInfo.devices; pDev; pDev = pDev->next) { + if (IsPointerDevice(pDev)) { pRoot = GetCurrentRootWindow(pDev); pCurrentScreen = pRoot ? pRoot->drawable.pScreen : NULL; - if (pScreen == pCurrentScreen) - { + if (pScreen == pCurrentScreen) { GetSpritePosition(pDev, &x, &y); - RRPointerToNearestCrtc (pDev, pScreen, x, y, NULL); + RRPointerToNearestCrtc(pDev, pScreen, x, y, NULL); } } } diff --git a/xorg-server/randr/rrproperty.c b/xorg-server/randr/rrproperty.c index d0a90203b..75948fccb 100644 --- a/xorg-server/randr/rrproperty.c +++ b/xorg-server/randr/rrproperty.c @@ -30,31 +30,31 @@ DeliverPropertyEvent(WindowPtr pWin, void *value) xRROutputPropertyNotifyEvent *event = value; RREventPtr *pHead, pRREvent; - dixLookupResourceByType((pointer *)&pHead, pWin->drawable.id, - RREventType, serverClient, DixReadAccess); + dixLookupResourceByType((pointer *) &pHead, pWin->drawable.id, + RREventType, serverClient, DixReadAccess); if (!pHead) - return WT_WALKCHILDREN; + return WT_WALKCHILDREN; - for (pRREvent = *pHead; pRREvent; pRREvent = pRREvent->next) - { - if (!(pRREvent->mask & RROutputPropertyNotifyMask)) - continue; + for (pRREvent = *pHead; pRREvent; pRREvent = pRREvent->next) { + if (!(pRREvent->mask & RROutputPropertyNotifyMask)) + continue; - event->window = pRREvent->window->drawable.id; - WriteEventsToClient(pRREvent->client, 1, (xEvent *)event); + event->window = pRREvent->window->drawable.id; + WriteEventsToClient(pRREvent->client, 1, (xEvent *) event); } return WT_WALKCHILDREN; } -static void RRDeliverPropertyEvent(ScreenPtr pScreen, xEvent *event) +static void +RRDeliverPropertyEvent(ScreenPtr pScreen, xEvent *event) { if (!(dispatchException & (DE_RESET | DE_TERMINATE))) - WalkTree(pScreen, DeliverPropertyEvent, event); + WalkTree(pScreen, DeliverPropertyEvent, event); } static void -RRDestroyOutputProperty (RRPropertyPtr prop) +RRDestroyOutputProperty(RRPropertyPtr prop) { free(prop->valid_values); free(prop->current.data); @@ -63,9 +63,10 @@ RRDestroyOutputProperty (RRPropertyPtr prop) } static void -RRDeleteProperty(RROutputRec *output, RRPropertyRec *prop) +RRDeleteProperty(RROutputRec * output, RRPropertyRec * prop) { xRROutputPropertyNotifyEvent event; + event.type = RREventBase + RRNotify; event.subCode = RRNotify_OutputProperty; event.output = output->id; @@ -73,7 +74,7 @@ RRDeleteProperty(RROutputRec *output, RRPropertyRec *prop) event.atom = prop->propertyName; event.timestamp = currentTime.milliseconds; - RRDeliverPropertyEvent(output->pScreen, (xEvent *)&event); + RRDeliverPropertyEvent(output->pScreen, (xEvent *) &event); RRDestroyOutputProperty(prop); } @@ -84,13 +85,13 @@ RRDeleteAllOutputProperties(RROutputPtr output) RRPropertyPtr prop, next; for (prop = output->properties; prop; prop = next) { - next = prop->next; + next = prop->next; RRDeleteProperty(output, prop); } } static void -RRInitOutputPropertyValue (RRPropertyValuePtr property_value) +RRInitOutputPropertyValue(RRPropertyValuePtr property_value) { property_value->type = None; property_value->format = 0; @@ -99,13 +100,13 @@ RRInitOutputPropertyValue (RRPropertyValuePtr property_value) } static RRPropertyPtr -RRCreateOutputProperty (Atom property) +RRCreateOutputProperty(Atom property) { - RRPropertyPtr prop; + RRPropertyPtr prop; - prop = (RRPropertyPtr)malloc(sizeof(RRPropertyRec)); + prop = (RRPropertyPtr) malloc(sizeof(RRPropertyRec)); if (!prop) - return NULL; + return NULL; prop->next = NULL; prop->propertyName = property; prop->is_pending = FALSE; @@ -113,8 +114,8 @@ RRCreateOutputProperty (Atom property) prop->immutable = FALSE; prop->num_valid = 0; prop->valid_values = NULL; - RRInitOutputPropertyValue (&prop->current); - RRInitOutputPropertyValue (&prop->pending); + RRInitOutputPropertyValue(&prop->current); + RRInitOutputPropertyValue(&prop->pending); return prop; } @@ -124,7 +125,7 @@ RRDeleteOutputProperty(RROutputPtr output, Atom property) RRPropertyRec *prop, **prev; for (prev = &output->properties; (prop = *prev); prev = &(prop->next)) - if (prop->propertyName == property) { + if (prop->propertyName == property) { *prev = prop->next; RRDeleteProperty(output, prop); return; @@ -132,240 +133,230 @@ RRDeleteOutputProperty(RROutputPtr output, Atom property) } int -RRChangeOutputProperty (RROutputPtr output, Atom property, Atom type, - int format, int mode, unsigned long len, - pointer value, Bool sendevent, Bool pending) +RRChangeOutputProperty(RROutputPtr output, Atom property, Atom type, + int format, int mode, unsigned long len, + pointer value, Bool sendevent, Bool pending) { - RRPropertyPtr prop; - xRROutputPropertyNotifyEvent event; - rrScrPrivPtr pScrPriv = rrGetScrPriv(output->pScreen); - int size_in_bytes; - int total_size; - unsigned long total_len; - RRPropertyValuePtr prop_value; - RRPropertyValueRec new_value; - Bool add = FALSE; + RRPropertyPtr prop; + xRROutputPropertyNotifyEvent event; + rrScrPrivPtr pScrPriv = rrGetScrPriv(output->pScreen); + int size_in_bytes; + int total_size; + unsigned long total_len; + RRPropertyValuePtr prop_value; + RRPropertyValueRec new_value; + Bool add = FALSE; size_in_bytes = format >> 3; /* first see if property already exists */ - prop = RRQueryOutputProperty (output, property); - if (!prop) /* just add to list */ - { - prop = RRCreateOutputProperty (property); - if (!prop) - return BadAlloc; - add = TRUE; - mode = PropModeReplace; + prop = RRQueryOutputProperty(output, property); + if (!prop) { /* just add to list */ + prop = RRCreateOutputProperty(property); + if (!prop) + return BadAlloc; + add = TRUE; + mode = PropModeReplace; } if (pending && prop->is_pending) - prop_value = &prop->pending; + prop_value = &prop->pending; else - prop_value = &prop->current; + prop_value = &prop->current; /* To append or prepend to a property the request format and type - must match those of the already defined property. The - existing format and type are irrelevant when using the mode - "PropModeReplace" since they will be written over. */ + must match those of the already defined property. The + existing format and type are irrelevant when using the mode + "PropModeReplace" since they will be written over. */ if ((format != prop_value->format) && (mode != PropModeReplace)) - return BadMatch; + return BadMatch; if ((prop_value->type != type) && (mode != PropModeReplace)) - return BadMatch; + return BadMatch; new_value = *prop_value; if (mode == PropModeReplace) - total_len = len; + total_len = len; else - total_len = prop_value->size + len; - - if (mode == PropModeReplace || len > 0) - { - pointer new_data = NULL, old_data = NULL; - - total_size = total_len * size_in_bytes; - new_value.data = (pointer)malloc(total_size); - if (!new_value.data && total_size) - { - if (add) - RRDestroyOutputProperty (prop); - return BadAlloc; - } - new_value.size = len; - new_value.type = type; - new_value.format = format; - - switch (mode) { - case PropModeReplace: - new_data = new_value.data; - old_data = NULL; - break; - case PropModeAppend: - new_data = (pointer) (((char *) new_value.data) + - (prop_value->size * size_in_bytes)); - old_data = new_value.data; - break; - case PropModePrepend: - new_data = new_value.data; - old_data = (pointer) (((char *) new_value.data) + - (prop_value->size * size_in_bytes)); - break; - } - if (new_data) - memcpy ((char *) new_data, (char *) value, len * size_in_bytes); - if (old_data) - memcpy ((char *) old_data, (char *) prop_value->data, - prop_value->size * size_in_bytes); - - if (pending && pScrPriv->rrOutputSetProperty && - !pScrPriv->rrOutputSetProperty(output->pScreen, output, - prop->propertyName, &new_value)) - { - free(new_value.data); - return BadValue; - } - free(prop_value->data); - *prop_value = new_value; - } - - else if (len == 0) - { - /* do nothing */ - } - - if (add) - { - prop->next = output->properties; - output->properties = prop; + total_len = prop_value->size + len; + + if (mode == PropModeReplace || len > 0) { + pointer new_data = NULL, old_data = NULL; + + total_size = total_len * size_in_bytes; + new_value.data = (pointer) malloc(total_size); + if (!new_value.data && total_size) { + if (add) + RRDestroyOutputProperty(prop); + return BadAlloc; + } + new_value.size = len; + new_value.type = type; + new_value.format = format; + + switch (mode) { + case PropModeReplace: + new_data = new_value.data; + old_data = NULL; + break; + case PropModeAppend: + new_data = (pointer) (((char *) new_value.data) + + (prop_value->size * size_in_bytes)); + old_data = new_value.data; + break; + case PropModePrepend: + new_data = new_value.data; + old_data = (pointer) (((char *) new_value.data) + + (prop_value->size * size_in_bytes)); + break; + } + if (new_data) + memcpy((char *) new_data, (char *) value, len * size_in_bytes); + if (old_data) + memcpy((char *) old_data, (char *) prop_value->data, + prop_value->size * size_in_bytes); + + if (pending && pScrPriv->rrOutputSetProperty && + !pScrPriv->rrOutputSetProperty(output->pScreen, output, + prop->propertyName, &new_value)) { + free(new_value.data); + return BadValue; + } + free(prop_value->data); + *prop_value = new_value; + } + + else if (len == 0) { + /* do nothing */ + } + + if (add) { + prop->next = output->properties; + output->properties = prop; } if (pending && prop->is_pending) - output->pendingProperties = TRUE; - - if (sendevent) - { - event.type = RREventBase + RRNotify; - event.subCode = RRNotify_OutputProperty; - event.output = output->id; - event.state = PropertyNewValue; - event.atom = prop->propertyName; - event.timestamp = currentTime.milliseconds; - RRDeliverPropertyEvent (output->pScreen, (xEvent *)&event); + output->pendingProperties = TRUE; + + if (sendevent) { + event.type = RREventBase + RRNotify; + event.subCode = RRNotify_OutputProperty; + event.output = output->id; + event.state = PropertyNewValue; + event.atom = prop->propertyName; + event.timestamp = currentTime.milliseconds; + RRDeliverPropertyEvent(output->pScreen, (xEvent *) &event); } return Success; } Bool -RRPostPendingProperties (RROutputPtr output) +RRPostPendingProperties(RROutputPtr output) { - RRPropertyValuePtr pending_value; - RRPropertyValuePtr current_value; - RRPropertyPtr property; - Bool ret = TRUE; + RRPropertyValuePtr pending_value; + RRPropertyValuePtr current_value; + RRPropertyPtr property; + Bool ret = TRUE; if (!output->pendingProperties) - return TRUE; - + return TRUE; + output->pendingProperties = FALSE; - for (property = output->properties; property; property = property->next) - { - /* Skip non-pending properties */ - if (!property->is_pending) - continue; - - pending_value = &property->pending; - current_value = &property->current; - - /* - * If the pending and current values are equal, don't mark it - * as changed (which would deliver an event) - */ - if (pending_value->type == current_value->type && - pending_value->format == current_value->format && - pending_value->size == current_value->size && - !memcmp (pending_value->data, current_value->data, - pending_value->size * (pending_value->format / 8))) - continue; - - if (RRChangeOutputProperty (output, property->propertyName, - pending_value->type, pending_value->format, - PropModeReplace, pending_value->size, - pending_value->data, TRUE, - FALSE) != Success) - ret = FALSE; + for (property = output->properties; property; property = property->next) { + /* Skip non-pending properties */ + if (!property->is_pending) + continue; + + pending_value = &property->pending; + current_value = &property->current; + + /* + * If the pending and current values are equal, don't mark it + * as changed (which would deliver an event) + */ + if (pending_value->type == current_value->type && + pending_value->format == current_value->format && + pending_value->size == current_value->size && + !memcmp(pending_value->data, current_value->data, + pending_value->size * (pending_value->format / 8))) + continue; + + if (RRChangeOutputProperty(output, property->propertyName, + pending_value->type, pending_value->format, + PropModeReplace, pending_value->size, + pending_value->data, TRUE, FALSE) != Success) + ret = FALSE; } return ret; } RRPropertyPtr -RRQueryOutputProperty (RROutputPtr output, Atom property) +RRQueryOutputProperty(RROutputPtr output, Atom property) { - RRPropertyPtr prop; - + RRPropertyPtr prop; + for (prop = output->properties; prop; prop = prop->next) - if (prop->propertyName == property) - return prop; + if (prop->propertyName == property) + return prop; return NULL; } - + RRPropertyValuePtr -RRGetOutputProperty (RROutputPtr output, Atom property, Bool pending) +RRGetOutputProperty(RROutputPtr output, Atom property, Bool pending) { - RRPropertyPtr prop = RRQueryOutputProperty (output, property); - rrScrPrivPtr pScrPriv = rrGetScrPriv(output->pScreen); + RRPropertyPtr prop = RRQueryOutputProperty(output, property); + rrScrPrivPtr pScrPriv = rrGetScrPriv(output->pScreen); if (!prop) - return NULL; + return NULL; if (pending && prop->is_pending) - return &prop->pending; + return &prop->pending; else { #if RANDR_13_INTERFACE - /* If we can, try to update the property value first */ - if (pScrPriv->rrOutputGetProperty) - pScrPriv->rrOutputGetProperty(output->pScreen, output, - prop->propertyName); + /* If we can, try to update the property value first */ + if (pScrPriv->rrOutputGetProperty) + pScrPriv->rrOutputGetProperty(output->pScreen, output, + prop->propertyName); #endif - return &prop->current; + return &prop->current; } } int -RRConfigureOutputProperty (RROutputPtr output, Atom property, - Bool pending, Bool range, Bool immutable, - int num_values, INT32 *values) +RRConfigureOutputProperty(RROutputPtr output, Atom property, + Bool pending, Bool range, Bool immutable, + int num_values, INT32 *values) { - RRPropertyPtr prop = RRQueryOutputProperty (output, property); - Bool add = FALSE; - INT32 *new_values; + RRPropertyPtr prop = RRQueryOutputProperty(output, property); + Bool add = FALSE; + INT32 *new_values; + + if (!prop) { + prop = RRCreateOutputProperty(property); + if (!prop) + return BadAlloc; + add = TRUE; + } + else if (prop->immutable && !immutable) + return BadAccess; - if (!prop) - { - prop = RRCreateOutputProperty (property); - if (!prop) - return BadAlloc; - add = TRUE; - } else if (prop->immutable && !immutable) - return BadAccess; - /* * ranges must have even number of values */ if (range && (num_values & 1)) - return BadMatch; + return BadMatch; - new_values = malloc(num_values * sizeof (INT32)); + new_values = malloc(num_values * sizeof(INT32)); if (!new_values && num_values) - return BadAlloc; + return BadAlloc; if (num_values) - memcpy (new_values, values, num_values * sizeof (INT32)); - + memcpy(new_values, values, num_values * sizeof(INT32)); + /* * Property moving from pending to non-pending * loses any pending values */ - if (prop->is_pending && !pending) - { - free(prop->pending.data); - RRInitOutputPropertyValue (&prop->pending); + if (prop->is_pending && !pending) { + free(prop->pending.data); + RRInitOutputPropertyValue(&prop->pending); } prop->is_pending = pending; @@ -376,51 +367,49 @@ RRConfigureOutputProperty (RROutputPtr output, Atom property, prop->valid_values = new_values; if (add) { - prop->next = output->properties; - output->properties = prop; + prop->next = output->properties; + output->properties = prop; } return Success; } int -ProcRRListOutputProperties (ClientPtr client) +ProcRRListOutputProperties(ClientPtr client) { REQUEST(xRRListOutputPropertiesReq); - Atom *pAtoms = NULL, *temppAtoms; - xRRListOutputPropertiesReply rep; - int numProps = 0; - RROutputPtr output; - RRPropertyPtr prop; - + Atom *pAtoms = NULL, *temppAtoms; + xRRListOutputPropertiesReply rep; + int numProps = 0; + RROutputPtr output; + RRPropertyPtr prop; + REQUEST_SIZE_MATCH(xRRListOutputPropertiesReq); VERIFY_RR_OUTPUT(stuff->output, output, DixReadAccess); for (prop = output->properties; prop; prop = prop->next) - numProps++; + numProps++; if (numProps) - if(!(pAtoms = (Atom *)malloc(numProps * sizeof(Atom)))) + if (!(pAtoms = (Atom *) malloc(numProps * sizeof(Atom)))) return BadAlloc; rep.type = X_Reply; rep.length = bytes_to_int32(numProps * sizeof(Atom)); rep.sequenceNumber = client->sequence; rep.nAtoms = numProps; - if (client->swapped) - { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - swaps(&rep.nAtoms); + if (client->swapped) { + swaps(&rep.sequenceNumber); + swapl(&rep.length); + swaps(&rep.nAtoms); } temppAtoms = pAtoms; for (prop = output->properties; prop; prop = prop->next) - *temppAtoms++ = prop->propertyName; + *temppAtoms++ = prop->propertyName; - WriteToClient(client, sizeof(xRRListOutputPropertiesReply), (char*)&rep); - if (numProps) - { - client->pSwapReplyFunc = (ReplySwapPtr)Swap32Write; + WriteToClient(client, sizeof(xRRListOutputPropertiesReply), (char *) &rep); + if (numProps) { + client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; WriteSwappedDataToClient(client, numProps * sizeof(Atom), pAtoms); free(pAtoms); } @@ -428,26 +417,26 @@ ProcRRListOutputProperties (ClientPtr client) } int -ProcRRQueryOutputProperty (ClientPtr client) +ProcRRQueryOutputProperty(ClientPtr client) { REQUEST(xRRQueryOutputPropertyReq); - xRRQueryOutputPropertyReply rep; - RROutputPtr output; - RRPropertyPtr prop; + xRRQueryOutputPropertyReply rep; + RROutputPtr output; + RRPropertyPtr prop; char *extra = NULL; - + REQUEST_SIZE_MATCH(xRRQueryOutputPropertyReq); VERIFY_RR_OUTPUT(stuff->output, output, DixReadAccess); - - prop = RRQueryOutputProperty (output, stuff->property); + + prop = RRQueryOutputProperty(output, stuff->property); if (!prop) - return BadName; - + return BadName; + if (prop->num_valid) { - extra = malloc(prop->num_valid * sizeof(INT32)); - if (!extra) - return BadAlloc; + extra = malloc(prop->num_valid * sizeof(INT32)); + if (!extra) + return BadAlloc; } rep.type = X_Reply; rep.length = prop->num_valid; @@ -455,124 +444,116 @@ ProcRRQueryOutputProperty (ClientPtr client) rep.pending = prop->is_pending; rep.range = prop->range; rep.immutable = prop->immutable; - if (client->swapped) - { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - } - WriteToClient (client, sizeof (xRRQueryOutputPropertyReply), (char*)&rep); - if (prop->num_valid) - { + if (client->swapped) { + swaps(&rep.sequenceNumber); + swapl(&rep.length); + } + WriteToClient(client, sizeof(xRRQueryOutputPropertyReply), (char *) &rep); + if (prop->num_valid) { memcpy(extra, prop->valid_values, prop->num_valid * sizeof(INT32)); - client->pSwapReplyFunc = (ReplySwapPtr)Swap32Write; + client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; WriteSwappedDataToClient(client, prop->num_valid * sizeof(INT32), - extra); + extra); free(extra); } return Success; } int -ProcRRConfigureOutputProperty (ClientPtr client) +ProcRRConfigureOutputProperty(ClientPtr client) { REQUEST(xRRConfigureOutputPropertyReq); - RROutputPtr output; - int num_valid; - + RROutputPtr output; + int num_valid; + REQUEST_AT_LEAST_SIZE(xRRConfigureOutputPropertyReq); VERIFY_RR_OUTPUT(stuff->output, output, DixReadAccess); - - num_valid = stuff->length - bytes_to_int32(sizeof (xRRConfigureOutputPropertyReq)); - return RRConfigureOutputProperty (output, stuff->property, - stuff->pending, stuff->range, - FALSE, num_valid, - (INT32 *) (stuff + 1)); + + num_valid = + stuff->length - bytes_to_int32(sizeof(xRRConfigureOutputPropertyReq)); + return RRConfigureOutputProperty(output, stuff->property, stuff->pending, + stuff->range, FALSE, num_valid, + (INT32 *) (stuff + 1)); } int -ProcRRChangeOutputProperty (ClientPtr client) +ProcRRChangeOutputProperty(ClientPtr client) { REQUEST(xRRChangeOutputPropertyReq); - RROutputPtr output; - char format, mode; - unsigned long len; - int sizeInBytes; - int totalSize; - int err; + RROutputPtr output; + char format, mode; + unsigned long len; + int sizeInBytes; + int totalSize; + int err; REQUEST_AT_LEAST_SIZE(xRRChangeOutputPropertyReq); UpdateCurrentTime(); format = stuff->format; mode = stuff->mode; if ((mode != PropModeReplace) && (mode != PropModeAppend) && - (mode != PropModePrepend)) - { - client->errorValue = mode; - return BadValue; - } - if ((format != 8) && (format != 16) && (format != 32)) - { - client->errorValue = format; + (mode != PropModePrepend)) { + client->errorValue = mode; + return BadValue; + } + if ((format != 8) && (format != 16) && (format != 32)) { + client->errorValue = format; return BadValue; } len = stuff->nUnits; if (len > bytes_to_int32((0xffffffff - sizeof(xChangePropertyReq)))) - return BadLength; - sizeInBytes = format>>3; + return BadLength; + sizeInBytes = format >> 3; totalSize = len * sizeInBytes; REQUEST_FIXED_SIZE(xRRChangeOutputPropertyReq, totalSize); VERIFY_RR_OUTPUT(stuff->output, output, DixReadAccess); - - if (!ValidAtom(stuff->property)) - { - client->errorValue = stuff->property; - return BadAtom; + + if (!ValidAtom(stuff->property)) { + client->errorValue = stuff->property; + return BadAtom; } - if (!ValidAtom(stuff->type)) - { - client->errorValue = stuff->type; - return BadAtom; + if (!ValidAtom(stuff->type)) { + client->errorValue = stuff->type; + return BadAtom; } err = RRChangeOutputProperty(output, stuff->property, - stuff->type, (int)format, - (int)mode, len, (pointer)&stuff[1], TRUE, TRUE); + stuff->type, (int) format, + (int) mode, len, (pointer) &stuff[1], TRUE, + TRUE); if (err != Success) - return err; + return err; else - return Success; + return Success; } int -ProcRRDeleteOutputProperty (ClientPtr client) +ProcRRDeleteOutputProperty(ClientPtr client) { REQUEST(xRRDeleteOutputPropertyReq); - RROutputPtr output; - RRPropertyPtr prop; + RROutputPtr output; + RRPropertyPtr prop; REQUEST_SIZE_MATCH(xRRDeleteOutputPropertyReq); UpdateCurrentTime(); VERIFY_RR_OUTPUT(stuff->output, output, DixReadAccess); - if (!ValidAtom(stuff->property)) - { - client->errorValue = stuff->property; - return BadAtom; + if (!ValidAtom(stuff->property)) { + client->errorValue = stuff->property; + return BadAtom; } prop = RRQueryOutputProperty(output, stuff->property); - if (!prop) - { - client->errorValue = stuff->property; - return BadName; + if (!prop) { + client->errorValue = stuff->property; + return BadName; } - if (prop->immutable) - { - client->errorValue = stuff->property; - return BadAccess; + if (prop->immutable) { + client->errorValue = stuff->property; + return BadAccess; } RRDeleteOutputProperty(output, stuff->property); @@ -580,162 +561,156 @@ ProcRRDeleteOutputProperty (ClientPtr client) } int -ProcRRGetOutputProperty (ClientPtr client) +ProcRRGetOutputProperty(ClientPtr client) { REQUEST(xRRGetOutputPropertyReq); - RRPropertyPtr prop, *prev; - RRPropertyValuePtr prop_value; - unsigned long n, len, ind; - RROutputPtr output; - xRRGetOutputPropertyReply reply; - char *extra = NULL; + RRPropertyPtr prop, *prev; + RRPropertyValuePtr prop_value; + unsigned long n, len, ind; + RROutputPtr output; + xRRGetOutputPropertyReply reply; + char *extra = NULL; REQUEST_SIZE_MATCH(xRRGetOutputPropertyReq); if (stuff->delete) - UpdateCurrentTime(); + UpdateCurrentTime(); VERIFY_RR_OUTPUT(stuff->output, output, - stuff->delete ? DixWriteAccess : DixReadAccess); + stuff->delete ? DixWriteAccess : DixReadAccess); - if (!ValidAtom(stuff->property)) - { - client->errorValue = stuff->property; - return BadAtom; + if (!ValidAtom(stuff->property)) { + client->errorValue = stuff->property; + return BadAtom; } - if ((stuff->delete != xTrue) && (stuff->delete != xFalse)) - { - client->errorValue = stuff->delete; - return BadValue; + if ((stuff->delete != xTrue) && (stuff->delete != xFalse)) { + client->errorValue = stuff->delete; + return BadValue; } - if ((stuff->type != AnyPropertyType) && !ValidAtom(stuff->type)) - { - client->errorValue = stuff->type; - return BadAtom; + if ((stuff->type != AnyPropertyType) && !ValidAtom(stuff->type)) { + client->errorValue = stuff->type; + return BadAtom; } for (prev = &output->properties; (prop = *prev); prev = &prop->next) - if (prop->propertyName == stuff->property) - break; + if (prop->propertyName == stuff->property) + break; reply.type = X_Reply; reply.sequenceNumber = client->sequence; - if (!prop) - { - reply.nItems = 0; - reply.length = 0; - reply.bytesAfter = 0; - reply.propertyType = None; - reply.format = 0; - if (client->swapped) { - swaps(&reply.sequenceNumber); - swapl(&reply.length); - swapl(&reply.propertyType); - swapl(&reply.bytesAfter); - swapl(&reply.nItems); - } - WriteToClient(client, sizeof(xRRGetOutputPropertyReply), &reply); - return Success; + if (!prop) { + reply.nItems = 0; + reply.length = 0; + reply.bytesAfter = 0; + reply.propertyType = None; + reply.format = 0; + if (client->swapped) { + swaps(&reply.sequenceNumber); + swapl(&reply.length); + swapl(&reply.propertyType); + swapl(&reply.bytesAfter); + swapl(&reply.nItems); + } + WriteToClient(client, sizeof(xRRGetOutputPropertyReply), &reply); + return Success; } if (prop->immutable && stuff->delete) - return BadAccess; + return BadAccess; prop_value = RRGetOutputProperty(output, stuff->property, stuff->pending); if (!prop_value) - return BadAtom; + return BadAtom; /* If the request type and actual type don't match. Return the - property information, but not the data. */ - - if (((stuff->type != prop_value->type) && - (stuff->type != AnyPropertyType)) - ) - { - reply.bytesAfter = prop_value->size; - reply.format = prop_value->format; - reply.length = 0; - reply.nItems = 0; - reply.propertyType = prop_value->type; - if (client->swapped) { - swaps(&reply.sequenceNumber); - swapl(&reply.length); - swapl(&reply.propertyType); - swapl(&reply.bytesAfter); - swapl(&reply.nItems); - } - WriteToClient(client, sizeof(xRRGetOutputPropertyReply), &reply); - return Success; + property information, but not the data. */ + + if (((stuff->type != prop_value->type) && (stuff->type != AnyPropertyType)) + ) { + reply.bytesAfter = prop_value->size; + reply.format = prop_value->format; + reply.length = 0; + reply.nItems = 0; + reply.propertyType = prop_value->type; + if (client->swapped) { + swaps(&reply.sequenceNumber); + swapl(&reply.length); + swapl(&reply.propertyType); + swapl(&reply.bytesAfter); + swapl(&reply.nItems); + } + WriteToClient(client, sizeof(xRRGetOutputPropertyReply), &reply); + return Success; } /* * Return type, format, value to client */ - n = (prop_value->format/8) * prop_value->size; /* size (bytes) of prop */ - ind = stuff->longOffset << 2; + n = (prop_value->format / 8) * prop_value->size; /* size (bytes) of prop */ + ind = stuff->longOffset << 2; - /* If longOffset is invalid such that it causes "len" to - be negative, it's a value error. */ + /* If longOffset is invalid such that it causes "len" to + be negative, it's a value error. */ - if (n < ind) - { - client->errorValue = stuff->longOffset; - return BadValue; + if (n < ind) { + client->errorValue = stuff->longOffset; + return BadValue; } len = min(n - ind, 4 * stuff->longLength); if (len) { - extra = malloc(len); - if (!extra) - return BadAlloc; + extra = malloc(len); + if (!extra) + return BadAlloc; } reply.bytesAfter = n - (ind + len); reply.format = prop_value->format; reply.length = bytes_to_int32(len); if (prop_value->format) - reply.nItems = len / (prop_value->format / 8); + reply.nItems = len / (prop_value->format / 8); else - reply.nItems = 0; + reply.nItems = 0; reply.propertyType = prop_value->type; - if (stuff->delete && (reply.bytesAfter == 0)) - { - xRROutputPropertyNotifyEvent event; + if (stuff->delete && (reply.bytesAfter == 0)) { + xRROutputPropertyNotifyEvent event; - event.type = RREventBase + RRNotify; - event.subCode = RRNotify_OutputProperty; - event.output = output->id; - event.state = PropertyDelete; - event.atom = prop->propertyName; - event.timestamp = currentTime.milliseconds; - RRDeliverPropertyEvent (output->pScreen, (xEvent *)&event); + event.type = RREventBase + RRNotify; + event.subCode = RRNotify_OutputProperty; + event.output = output->id; + event.state = PropertyDelete; + event.atom = prop->propertyName; + event.timestamp = currentTime.milliseconds; + RRDeliverPropertyEvent(output->pScreen, (xEvent *) &event); } if (client->swapped) { - swaps(&reply.sequenceNumber); - swapl(&reply.length); - swapl(&reply.propertyType); - swapl(&reply.bytesAfter); - swapl(&reply.nItems); + swaps(&reply.sequenceNumber); + swapl(&reply.length); + swapl(&reply.propertyType); + swapl(&reply.bytesAfter); + swapl(&reply.nItems); } WriteToClient(client, sizeof(xGenericReply), &reply); - if (len) - { - memcpy(extra, (char *)prop_value->data + ind, len); - switch (reply.format) { - case 32: client->pSwapReplyFunc = (ReplySwapPtr)CopySwap32Write; break; - case 16: client->pSwapReplyFunc = (ReplySwapPtr)CopySwap16Write; break; - default: client->pSwapReplyFunc = (ReplySwapPtr)WriteToClient; break; - } - WriteSwappedDataToClient(client, len, - extra); - free(extra); - } - - if (stuff->delete && (reply.bytesAfter == 0)) - { /* delete the Property */ - *prev = prop->next; - RRDestroyOutputProperty (prop); + if (len) { + memcpy(extra, (char *) prop_value->data + ind, len); + switch (reply.format) { + case 32: + client->pSwapReplyFunc = (ReplySwapPtr) CopySwap32Write; + break; + case 16: + client->pSwapReplyFunc = (ReplySwapPtr) CopySwap16Write; + break; + default: + client->pSwapReplyFunc = (ReplySwapPtr) WriteToClient; + break; + } + WriteSwappedDataToClient(client, len, extra); + free(extra); + } + + if (stuff->delete && (reply.bytesAfter == 0)) { /* delete the Property */ + *prev = prop->next; + RRDestroyOutputProperty(prop); } return Success; } - diff --git a/xorg-server/randr/rrscreen.c b/xorg-server/randr/rrscreen.c index ab4675734..f570afaf4 100644 --- a/xorg-server/randr/rrscreen.c +++ b/xorg-server/randr/rrscreen.c @@ -22,47 +22,44 @@ #include "randrstr.h" -static const int padlength[4] = {0, 3, 2, 1}; +static const int padlength[4] = { 0, 3, 2, 1 }; static CARD16 -RR10CurrentSizeID (ScreenPtr pScreen); + RR10CurrentSizeID(ScreenPtr pScreen); /* * Edit connection information block so that new clients * see the current screen size on connect */ static void -RREditConnectionInfo (ScreenPtr pScreen) +RREditConnectionInfo(ScreenPtr pScreen) { - xConnSetup *connSetup; - char *vendor; - xPixmapFormat *formats; - xWindowRoot *root; - xDepth *depth; - xVisualType *visual; - int screen = 0; - int d; + xConnSetup *connSetup; + char *vendor; + xPixmapFormat *formats; + xWindowRoot *root; + xDepth *depth; + xVisualType *visual; + int screen = 0; + int d; connSetup = (xConnSetup *) ConnectionInfo; - vendor = (char *) connSetup + sizeof (xConnSetup); + vendor = (char *) connSetup + sizeof(xConnSetup); formats = (xPixmapFormat *) ((char *) vendor + - connSetup->nbytesVendor + - padlength[connSetup->nbytesVendor & 3]); + connSetup->nbytesVendor + + padlength[connSetup->nbytesVendor & 3]); root = (xWindowRoot *) ((char *) formats + - sizeof (xPixmapFormat) * screenInfo.numPixmapFormats); - while (screen != pScreen->myNum) - { - depth = (xDepth *) ((char *) root + - sizeof (xWindowRoot)); - for (d = 0; d < root->nDepths; d++) - { - visual = (xVisualType *) ((char *) depth + - sizeof (xDepth)); - depth = (xDepth *) ((char *) visual + - depth->nVisuals * sizeof (xVisualType)); - } - root = (xWindowRoot *) ((char *) depth); - screen++; + sizeof(xPixmapFormat) * + screenInfo.numPixmapFormats); + while (screen != pScreen->myNum) { + depth = (xDepth *) ((char *) root + sizeof(xWindowRoot)); + for (d = 0; d < root->nDepths; d++) { + visual = (xVisualType *) ((char *) depth + sizeof(xDepth)); + depth = (xDepth *) ((char *) visual + + depth->nVisuals * sizeof(xVisualType)); + } + root = (xWindowRoot *) ((char *) depth); + screen++; } root->pixWidth = pScreen->width; root->pixHeight = pScreen->height; @@ -71,10 +68,10 @@ RREditConnectionInfo (ScreenPtr pScreen) } void -RRSendConfigNotify (ScreenPtr pScreen) +RRSendConfigNotify(ScreenPtr pScreen) { - WindowPtr pWin = pScreen->root; - xEvent event; + WindowPtr pWin = pScreen->root; + xEvent event; event.u.u.type = ConfigureNotify; event.u.configureNotify.window = pWin->drawable.id; @@ -83,45 +80,46 @@ RRSendConfigNotify (ScreenPtr pScreen) event.u.configureNotify.y = 0; /* XXX xinerama stuff ? */ - + event.u.configureNotify.width = pWin->drawable.width; event.u.configureNotify.height = pWin->drawable.height; - event.u.configureNotify.borderWidth = wBorderWidth (pWin); + event.u.configureNotify.borderWidth = wBorderWidth(pWin); event.u.configureNotify.override = pWin->overrideRedirect; DeliverEvents(pWin, &event, 1, NullWindow); } void -RRDeliverScreenEvent (ClientPtr client, WindowPtr pWin, ScreenPtr pScreen) +RRDeliverScreenEvent(ClientPtr client, WindowPtr pWin, ScreenPtr pScreen) { - rrScrPriv (pScreen); - xRRScreenChangeNotifyEvent se; - RRCrtcPtr crtc = pScrPriv->numCrtcs ? pScrPriv->crtcs[0] : NULL; - WindowPtr pRoot = pScreen->root; - + rrScrPriv(pScreen); + xRRScreenChangeNotifyEvent se; + RRCrtcPtr crtc = pScrPriv->numCrtcs ? pScrPriv->crtcs[0] : NULL; + WindowPtr pRoot = pScreen->root; + se.type = RRScreenChangeNotify + RREventBase; se.rotation = (CARD8) (crtc ? crtc->rotation : RR_Rotate_0); se.timestamp = pScrPriv->lastSetTime.milliseconds; se.configTimestamp = pScrPriv->lastConfigTime.milliseconds; - se.root = pRoot->drawable.id; + se.root = pRoot->drawable.id; se.window = pWin->drawable.id; - se.subpixelOrder = PictureGetSubpixelOrder (pScreen); + se.subpixelOrder = PictureGetSubpixelOrder(pScreen); - se.sizeID = RR10CurrentSizeID (pScreen); + se.sizeID = RR10CurrentSizeID(pScreen); if (se.rotation & (RR_Rotate_90 | RR_Rotate_270)) { - se.widthInPixels = pScreen->height; - se.heightInPixels = pScreen->width; - se.widthInMillimeters = pScreen->mmHeight; - se.heightInMillimeters = pScreen->mmWidth; - } else { - se.widthInPixels = pScreen->width; - se.heightInPixels = pScreen->height; - se.widthInMillimeters = pScreen->mmWidth; - se.heightInMillimeters = pScreen->mmHeight; - } - - WriteEventsToClient (client, 1, (xEvent *) &se); + se.widthInPixels = pScreen->height; + se.heightInPixels = pScreen->width; + se.widthInMillimeters = pScreen->mmHeight; + se.heightInMillimeters = pScreen->mmWidth; + } + else { + se.widthInPixels = pScreen->width; + se.heightInPixels = pScreen->height; + se.widthInMillimeters = pScreen->mmWidth; + se.heightInMillimeters = pScreen->mmHeight; + } + + WriteEventsToClient(client, 1, (xEvent *) &se); } /* @@ -130,7 +128,7 @@ RRDeliverScreenEvent (ClientPtr client, WindowPtr pWin, ScreenPtr pScreen) * the size of the screen */ void -RRScreenSizeNotify (ScreenPtr pScreen) +RRScreenSizeNotify(ScreenPtr pScreen) { rrScrPriv(pScreen); /* @@ -138,11 +136,11 @@ RRScreenSizeNotify (ScreenPtr pScreen) * pixel size */ if (pScrPriv->width == pScreen->width && - pScrPriv->height == pScreen->height && - pScrPriv->mmWidth == pScreen->mmWidth && - pScrPriv->mmHeight == pScreen->mmHeight) - return; - + pScrPriv->height == pScreen->height && + pScrPriv->mmWidth == pScreen->mmWidth && + pScrPriv->mmHeight == pScreen->mmHeight) + return; + pScrPriv->width = pScreen->width; pScrPriv->height = pScreen->height; pScrPriv->mmWidth = pScreen->mmWidth; @@ -150,41 +148,35 @@ RRScreenSizeNotify (ScreenPtr pScreen) pScrPriv->changed = TRUE; /* pScrPriv->sizeChanged = TRUE; */ - RRTellChanged (pScreen); - RRSendConfigNotify (pScreen); - RREditConnectionInfo (pScreen); - - RRPointerScreenConfigured (pScreen); + RRTellChanged(pScreen); + RRSendConfigNotify(pScreen); + RREditConnectionInfo(pScreen); + + RRPointerScreenConfigured(pScreen); /* * Fix pointer bounds and location */ - ScreenRestructured (pScreen); + ScreenRestructured(pScreen); } /* * Request that the screen be resized */ Bool -RRScreenSizeSet (ScreenPtr pScreen, - CARD16 width, - CARD16 height, - CARD32 mmWidth, - CARD32 mmHeight) +RRScreenSizeSet(ScreenPtr pScreen, + CARD16 width, CARD16 height, CARD32 mmWidth, CARD32 mmHeight) { rrScrPriv(pScreen); #if RANDR_12_INTERFACE - if (pScrPriv->rrScreenSetSize) - { - return (*pScrPriv->rrScreenSetSize) (pScreen, - width, height, - mmWidth, mmHeight); + if (pScrPriv->rrScreenSetSize) { + return (*pScrPriv->rrScreenSetSize) (pScreen, + width, height, mmWidth, mmHeight); } #endif #if RANDR_10_INTERFACE - if (pScrPriv->rrSetConfig) - { - return TRUE; /* can't set size separately */ + if (pScrPriv->rrSetConfig) { + return TRUE; /* can't set size separately */ } #endif return FALSE; @@ -194,114 +186,105 @@ RRScreenSizeSet (ScreenPtr pScreen, * Retrieve valid screen size range */ int -ProcRRGetScreenSizeRange (ClientPtr client) +ProcRRGetScreenSizeRange(ClientPtr client) { REQUEST(xRRGetScreenSizeRangeReq); - xRRGetScreenSizeRangeReply rep; - WindowPtr pWin; - ScreenPtr pScreen; - rrScrPrivPtr pScrPriv; - int rc; - + xRRGetScreenSizeRangeReply rep; + WindowPtr pWin; + ScreenPtr pScreen; + rrScrPrivPtr pScrPriv; + int rc; + REQUEST_SIZE_MATCH(xRRGetScreenInfoReq); rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); if (rc != Success) - return rc; + return rc; pScreen = pWin->drawable.pScreen; pScrPriv = rrGetScrPriv(pScreen); - + rep.type = X_Reply; rep.pad = 0; rep.sequenceNumber = client->sequence; rep.length = 0; - - if (pScrPriv) - { - if (!RRGetInfo (pScreen, FALSE)) - return BadAlloc; - rep.minWidth = pScrPriv->minWidth; - rep.minHeight = pScrPriv->minHeight; - rep.maxWidth = pScrPriv->maxWidth; - rep.maxHeight = pScrPriv->maxHeight; + + if (pScrPriv) { + if (!RRGetInfo(pScreen, FALSE)) + return BadAlloc; + rep.minWidth = pScrPriv->minWidth; + rep.minHeight = pScrPriv->minHeight; + rep.maxWidth = pScrPriv->maxWidth; + rep.maxHeight = pScrPriv->maxHeight; } - else - { - rep.maxWidth = rep.minWidth = pScreen->width; - rep.maxHeight = rep.minHeight = pScreen->height; - } - if (client->swapped) - { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - swaps(&rep.minWidth); - swaps(&rep.minHeight); - swaps(&rep.maxWidth); - swaps(&rep.maxHeight); - } - WriteToClient(client, sizeof(xRRGetScreenSizeRangeReply), (char *)&rep); + else { + rep.maxWidth = rep.minWidth = pScreen->width; + rep.maxHeight = rep.minHeight = pScreen->height; + } + if (client->swapped) { + 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; } int -ProcRRSetScreenSize (ClientPtr client) +ProcRRSetScreenSize(ClientPtr client) { REQUEST(xRRSetScreenSizeReq); - WindowPtr pWin; - ScreenPtr pScreen; - rrScrPrivPtr pScrPriv; - int i, rc; - + WindowPtr pWin; + ScreenPtr pScreen; + rrScrPrivPtr pScrPriv; + int i, rc; + REQUEST_SIZE_MATCH(xRRSetScreenSizeReq); rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); if (rc != Success) - return rc; + return rc; pScreen = pWin->drawable.pScreen; pScrPriv = rrGetScrPriv(pScreen); - if (stuff->width < pScrPriv->minWidth || pScrPriv->maxWidth < stuff->width) - { - client->errorValue = stuff->width; - return BadValue; - } - if (stuff->height < pScrPriv->minHeight || - pScrPriv->maxHeight < stuff->height) - { - client->errorValue = stuff->height; - return BadValue; - } - for (i = 0; i < pScrPriv->numCrtcs; i++) - { - RRCrtcPtr crtc = pScrPriv->crtcs[i]; - RRModePtr mode = crtc->mode; - if (mode) - { - int source_width = mode->mode.width; - int source_height = mode->mode.height; - Rotation rotation = crtc->rotation; - - if (rotation == RR_Rotate_90 || rotation == RR_Rotate_270) - { - source_width = mode->mode.height; - source_height = mode->mode.width; - } - - if (crtc->x + source_width > stuff->width || - crtc->y + source_height > stuff->height) - return BadMatch; - } - } - if (stuff->widthInMillimeters == 0 || stuff->heightInMillimeters == 0) - { - client->errorValue = 0; - return BadValue; - } - if (!RRScreenSizeSet (pScreen, - stuff->width, stuff->height, - stuff->widthInMillimeters, - stuff->heightInMillimeters)) - { - return BadMatch; + if (stuff->width < pScrPriv->minWidth || pScrPriv->maxWidth < stuff->width) { + client->errorValue = stuff->width; + return BadValue; + } + if (stuff->height < pScrPriv->minHeight || + pScrPriv->maxHeight < stuff->height) { + client->errorValue = stuff->height; + return BadValue; + } + for (i = 0; i < pScrPriv->numCrtcs; i++) { + RRCrtcPtr crtc = pScrPriv->crtcs[i]; + RRModePtr mode = crtc->mode; + + if (mode) { + int source_width = mode->mode.width; + int source_height = mode->mode.height; + Rotation rotation = crtc->rotation; + + if (rotation == RR_Rotate_90 || rotation == RR_Rotate_270) { + source_width = mode->mode.height; + source_height = mode->mode.width; + } + + if (crtc->x + source_width > stuff->width || + crtc->y + source_height > stuff->height) + return BadMatch; + } + } + if (stuff->widthInMillimeters == 0 || stuff->heightInMillimeters == 0) { + client->errorValue = 0; + return BadValue; + } + if (!RRScreenSizeSet(pScreen, + stuff->width, stuff->height, + stuff->widthInMillimeters, + stuff->heightInMillimeters)) { + return BadMatch; } return Success; } @@ -310,494 +293,464 @@ static int rrGetScreenResources(ClientPtr client, Bool query) { REQUEST(xRRGetScreenResourcesReq); - xRRGetScreenResourcesReply rep; - WindowPtr pWin; - ScreenPtr pScreen; - rrScrPrivPtr pScrPriv; - CARD8 *extra; - unsigned long extraLen; - int i, rc, has_primary = 0; - RRCrtc *crtcs; - RROutput *outputs; - xRRModeInfo *modeinfos; - CARD8 *names; - + xRRGetScreenResourcesReply rep; + WindowPtr pWin; + ScreenPtr pScreen; + rrScrPrivPtr pScrPriv; + CARD8 *extra; + unsigned long extraLen; + int i, rc, has_primary = 0; + RRCrtc *crtcs; + RROutput *outputs; + xRRModeInfo *modeinfos; + CARD8 *names; + REQUEST_SIZE_MATCH(xRRGetScreenResourcesReq); rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); if (rc != Success) - return rc; - + return rc; + pScreen = pWin->drawable.pScreen; pScrPriv = rrGetScrPriv(pScreen); rep.pad = 0; - + if (query && pScrPriv) - if (!RRGetInfo (pScreen, query)) - return BadAlloc; - - if (!pScrPriv) - { - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.length = 0; - rep.timestamp = currentTime.milliseconds; - rep.configTimestamp = currentTime.milliseconds; - rep.nCrtcs = 0; - rep.nOutputs = 0; - rep.nModes = 0; - rep.nbytesNames = 0; - extra = NULL; - extraLen = 0; + if (!RRGetInfo(pScreen, query)) + return BadAlloc; + + if (!pScrPriv) { + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.length = 0; + rep.timestamp = currentTime.milliseconds; + rep.configTimestamp = currentTime.milliseconds; + rep.nCrtcs = 0; + rep.nOutputs = 0; + rep.nModes = 0; + rep.nbytesNames = 0; + extra = NULL; + extraLen = 0; } - else - { - RRModePtr *modes; - int num_modes; - - modes = RRModesForScreen (pScreen, &num_modes); - if (!modes) - return BadAlloc; - - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.length = 0; - rep.timestamp = pScrPriv->lastSetTime.milliseconds; - rep.configTimestamp = pScrPriv->lastConfigTime.milliseconds; - rep.nCrtcs = pScrPriv->numCrtcs; - rep.nOutputs = pScrPriv->numOutputs; - rep.nModes = num_modes; - rep.nbytesNames = 0; - - for (i = 0; i < num_modes; i++) - rep.nbytesNames += modes[i]->mode.nameLength; - - rep.length = (pScrPriv->numCrtcs + - pScrPriv->numOutputs + - num_modes * bytes_to_int32(SIZEOF(xRRModeInfo)) + - bytes_to_int32(rep.nbytesNames)); - - extraLen = rep.length << 2; - if (extraLen) - { - extra = malloc(extraLen); - if (!extra) - { - free(modes); - return BadAlloc; - } - } - else - extra = NULL; - - crtcs = (RRCrtc *) extra; - outputs = (RROutput *) (crtcs + pScrPriv->numCrtcs); - modeinfos = (xRRModeInfo *) (outputs + pScrPriv->numOutputs); - names = (CARD8 *) (modeinfos + num_modes); - - if (pScrPriv->primaryOutput && pScrPriv->primaryOutput->crtc) - { - has_primary = 1; - crtcs[0] = pScrPriv->primaryOutput->crtc->id; - if (client->swapped) - swapl(&crtcs[0]); - } - - for (i = 0; i < pScrPriv->numCrtcs; i++) - { - if (has_primary && - pScrPriv->primaryOutput->crtc == pScrPriv->crtcs[i]) - { - has_primary = 0; - continue; - } - crtcs[i + has_primary] = pScrPriv->crtcs[i]->id; - if (client->swapped) - swapl(&crtcs[i + has_primary]); - } - - for (i = 0; i < pScrPriv->numOutputs; i++) - { - outputs[i] = pScrPriv->outputs[i]->id; - if (client->swapped) - swapl(&outputs[i]); - } - - for (i = 0; i < num_modes; i++) - { - RRModePtr mode = modes[i]; - modeinfos[i] = mode->mode; - if (client->swapped) - { - 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); - names += mode->mode.nameLength; - } + else { + RRModePtr *modes; + int num_modes; + + modes = RRModesForScreen(pScreen, &num_modes); + if (!modes) + return BadAlloc; + + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.length = 0; + rep.timestamp = pScrPriv->lastSetTime.milliseconds; + rep.configTimestamp = pScrPriv->lastConfigTime.milliseconds; + rep.nCrtcs = pScrPriv->numCrtcs; + rep.nOutputs = pScrPriv->numOutputs; + rep.nModes = num_modes; + rep.nbytesNames = 0; + + for (i = 0; i < num_modes; i++) + rep.nbytesNames += modes[i]->mode.nameLength; + + rep.length = (pScrPriv->numCrtcs + + pScrPriv->numOutputs + + num_modes * bytes_to_int32(SIZEOF(xRRModeInfo)) + + bytes_to_int32(rep.nbytesNames)); + + extraLen = rep.length << 2; + if (extraLen) { + extra = malloc(extraLen); + if (!extra) { + free(modes); + return BadAlloc; + } + } + else + extra = NULL; + + crtcs = (RRCrtc *) extra; + outputs = (RROutput *) (crtcs + pScrPriv->numCrtcs); + modeinfos = (xRRModeInfo *) (outputs + pScrPriv->numOutputs); + names = (CARD8 *) (modeinfos + num_modes); + + if (pScrPriv->primaryOutput && pScrPriv->primaryOutput->crtc) { + has_primary = 1; + crtcs[0] = pScrPriv->primaryOutput->crtc->id; + if (client->swapped) + swapl(&crtcs[0]); + } + + for (i = 0; i < pScrPriv->numCrtcs; i++) { + if (has_primary && + pScrPriv->primaryOutput->crtc == pScrPriv->crtcs[i]) { + has_primary = 0; + continue; + } + crtcs[i + has_primary] = pScrPriv->crtcs[i]->id; + if (client->swapped) + swapl(&crtcs[i + has_primary]); + } + + for (i = 0; i < pScrPriv->numOutputs; i++) { + outputs[i] = pScrPriv->outputs[i]->id; + if (client->swapped) + swapl(&outputs[i]); + } + + for (i = 0; i < num_modes; i++) { + RRModePtr mode = modes[i]; + + modeinfos[i] = mode->mode; + if (client->swapped) { + 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); + names += mode->mode.nameLength; + } free(modes); - assert (bytes_to_int32((char *) names - (char *) extra) == rep.length); + assert(bytes_to_int32((char *) names - (char *) extra) == rep.length); } - + if (client->swapped) { - 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) - { - WriteToClient (client, extraLen, (char *) extra); - free(extra); + 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) { + WriteToClient(client, extraLen, (char *) extra); + free(extra); } return Success; } int -ProcRRGetScreenResources (ClientPtr client) +ProcRRGetScreenResources(ClientPtr client) { return rrGetScreenResources(client, TRUE); } - + int -ProcRRGetScreenResourcesCurrent (ClientPtr client) +ProcRRGetScreenResourcesCurrent(ClientPtr client) { return rrGetScreenResources(client, FALSE); } typedef struct _RR10Data { RRScreenSizePtr sizes; - int nsize; - int nrefresh; - int size; - CARD16 refresh; + int nsize; + int nrefresh; + int size; + CARD16 refresh; } RR10DataRec, *RR10DataPtr; /* * Convert 1.2 monitor data into 1.0 screen data */ static RR10DataPtr -RR10GetData (ScreenPtr pScreen, RROutputPtr output) +RR10GetData(ScreenPtr pScreen, RROutputPtr output) { - RR10DataPtr data; + RR10DataPtr data; RRScreenSizePtr size; - int nmode = output->numModes + output->numUserModes; - int o, os, l, r; + int nmode = output->numModes + output->numUserModes; + int o, os, l, r; RRScreenRatePtr refresh; - CARD16 vRefresh; - RRModePtr mode; - Bool *used; + CARD16 vRefresh; + RRModePtr mode; + Bool *used; /* Make sure there is plenty of space for any combination */ - data = malloc (sizeof (RR10DataRec) + - sizeof (RRScreenSize) * nmode + - sizeof (RRScreenRate) * nmode + - sizeof (Bool) * nmode); + data = malloc(sizeof(RR10DataRec) + + sizeof(RRScreenSize) * nmode + + sizeof(RRScreenRate) * nmode + sizeof(Bool) * nmode); if (!data) - return NULL; + return NULL; size = (RRScreenSizePtr) (data + 1); refresh = (RRScreenRatePtr) (size + nmode); used = (Bool *) (refresh + nmode); - memset (used, '\0', sizeof (Bool) * nmode); + memset(used, '\0', sizeof(Bool) * nmode); data->sizes = size; data->nsize = 0; data->nrefresh = 0; data->size = 0; data->refresh = 0; - + /* * find modes not yet listed */ - for (o = 0; o < output->numModes + output->numUserModes; o++) - { - if (used[o]) continue; - - if (o < output->numModes) - mode = output->modes[o]; - else - mode = output->userModes[o - output->numModes]; - - l = data->nsize; - size[l].id = data->nsize; - size[l].width = mode->mode.width; - size[l].height = mode->mode.height; - if (output->mmWidth && output->mmHeight) { - size[l].mmWidth = output->mmWidth; - size[l].mmHeight = output->mmHeight; - } else { - size[l].mmWidth = pScreen->mmWidth; - size[l].mmHeight = pScreen->mmHeight; - } - size[l].nRates = 0; - size[l].pRates = &refresh[data->nrefresh]; - data->nsize++; - - /* - * Find all modes with matching size - */ - for (os = o; os < output->numModes + output->numUserModes; os++) - { - if (os < output->numModes) - mode = output->modes[os]; - else - mode = output->userModes[os - output->numModes]; - if (mode->mode.width == size[l].width && - mode->mode.height == size[l].height) - { - vRefresh = RRVerticalRefresh (&mode->mode); - used[os] = TRUE; - - for (r = 0; r < size[l].nRates; r++) - if (vRefresh == size[l].pRates[r].rate) - break; - if (r == size[l].nRates) - { - size[l].pRates[r].rate = vRefresh; - size[l].pRates[r].mode = mode; - size[l].nRates++; - data->nrefresh++; - } - if (mode == output->crtc->mode) - { - data->size = l; - data->refresh = vRefresh; - } - } - } + for (o = 0; o < output->numModes + output->numUserModes; o++) { + if (used[o]) + continue; + + if (o < output->numModes) + mode = output->modes[o]; + else + mode = output->userModes[o - output->numModes]; + + l = data->nsize; + size[l].id = data->nsize; + size[l].width = mode->mode.width; + size[l].height = mode->mode.height; + if (output->mmWidth && output->mmHeight) { + size[l].mmWidth = output->mmWidth; + size[l].mmHeight = output->mmHeight; + } + else { + size[l].mmWidth = pScreen->mmWidth; + size[l].mmHeight = pScreen->mmHeight; + } + size[l].nRates = 0; + size[l].pRates = &refresh[data->nrefresh]; + data->nsize++; + + /* + * Find all modes with matching size + */ + for (os = o; os < output->numModes + output->numUserModes; os++) { + if (os < output->numModes) + mode = output->modes[os]; + else + mode = output->userModes[os - output->numModes]; + if (mode->mode.width == size[l].width && + mode->mode.height == size[l].height) { + vRefresh = RRVerticalRefresh(&mode->mode); + used[os] = TRUE; + + for (r = 0; r < size[l].nRates; r++) + if (vRefresh == size[l].pRates[r].rate) + break; + if (r == size[l].nRates) { + size[l].pRates[r].rate = vRefresh; + size[l].pRates[r].mode = mode; + size[l].nRates++; + data->nrefresh++; + } + if (mode == output->crtc->mode) { + data->size = l; + data->refresh = vRefresh; + } + } + } } return data; } int -ProcRRGetScreenInfo (ClientPtr client) +ProcRRGetScreenInfo(ClientPtr client) { REQUEST(xRRGetScreenInfoReq); - xRRGetScreenInfoReply rep; - WindowPtr pWin; - int rc; - ScreenPtr pScreen; - rrScrPrivPtr pScrPriv; - CARD8 *extra; - unsigned long extraLen; - RROutputPtr output; + xRRGetScreenInfoReply rep; + WindowPtr pWin; + int rc; + ScreenPtr pScreen; + rrScrPrivPtr pScrPriv; + CARD8 *extra; + unsigned long extraLen; + RROutputPtr output; REQUEST_SIZE_MATCH(xRRGetScreenInfoReq); rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); if (rc != Success) - return rc; + return rc; pScreen = pWin->drawable.pScreen; pScrPriv = rrGetScrPriv(pScreen); rep.pad = 0; - + if (pScrPriv) - if (!RRGetInfo (pScreen, TRUE)) - return BadAlloc; - - output = RRFirstOutput (pScreen); - - if (!pScrPriv || !output) - { - rep.type = X_Reply; - rep.setOfRotations = RR_Rotate_0; - rep.sequenceNumber = client->sequence; - rep.length = 0; - rep.root = pWin->drawable.pScreen->root->drawable.id; - rep.timestamp = currentTime.milliseconds; - rep.configTimestamp = currentTime.milliseconds; - rep.nSizes = 0; - rep.sizeID = 0; - rep.rotation = RR_Rotate_0; - rep.rate = 0; - rep.nrateEnts = 0; - extra = 0; - extraLen = 0; + if (!RRGetInfo(pScreen, TRUE)) + return BadAlloc; + + output = RRFirstOutput(pScreen); + + if (!pScrPriv || !output) { + rep.type = X_Reply; + rep.setOfRotations = RR_Rotate_0; + rep.sequenceNumber = client->sequence; + rep.length = 0; + rep.root = pWin->drawable.pScreen->root->drawable.id; + rep.timestamp = currentTime.milliseconds; + rep.configTimestamp = currentTime.milliseconds; + rep.nSizes = 0; + rep.sizeID = 0; + rep.rotation = RR_Rotate_0; + rep.rate = 0; + rep.nrateEnts = 0; + extra = 0; + extraLen = 0; } - else - { - int i, j; - xScreenSizes *size; - CARD16 *rates; - CARD8 *data8; - Bool has_rate = RRClientKnowsRates (client); - RR10DataPtr pData; - RRScreenSizePtr pSize; - - pData = RR10GetData (pScreen, output); - if (!pData) - return BadAlloc; - - rep.type = X_Reply; - rep.setOfRotations = output->crtc->rotations; - rep.sequenceNumber = client->sequence; - rep.length = 0; - rep.root = pWin->drawable.pScreen->root->drawable.id; - rep.timestamp = pScrPriv->lastSetTime.milliseconds; - rep.configTimestamp = pScrPriv->lastConfigTime.milliseconds; - rep.rotation = output->crtc->rotation; - rep.nSizes = pData->nsize; + else { + int i, j; + xScreenSizes *size; + CARD16 *rates; + CARD8 *data8; + Bool has_rate = RRClientKnowsRates(client); + RR10DataPtr pData; + RRScreenSizePtr pSize; + + pData = RR10GetData(pScreen, output); + if (!pData) + return BadAlloc; + + rep.type = X_Reply; + rep.setOfRotations = output->crtc->rotations; + rep.sequenceNumber = client->sequence; + rep.length = 0; + rep.root = pWin->drawable.pScreen->root->drawable.id; + rep.timestamp = pScrPriv->lastSetTime.milliseconds; + rep.configTimestamp = pScrPriv->lastConfigTime.milliseconds; + rep.rotation = output->crtc->rotation; + rep.nSizes = pData->nsize; rep.nrateEnts = pData->nrefresh + pData->nsize; - rep.sizeID = pData->size; - rep.rate = pData->refresh; - - extraLen = rep.nSizes * sizeof (xScreenSizes); - if (has_rate) - extraLen += rep.nrateEnts * sizeof (CARD16); - - if (extraLen) - { - extra = (CARD8 *) malloc(extraLen); - if (!extra) - { - free(pData); - return BadAlloc; - } - } - else - extra = NULL; - - /* - * First comes the size information - */ - size = (xScreenSizes *) extra; - rates = (CARD16 *) (size + rep.nSizes); - for (i = 0; i < pData->nsize; i++) - { - pSize = &pData->sizes[i]; - size->widthInPixels = pSize->width; - size->heightInPixels = pSize->height; - size->widthInMillimeters = pSize->mmWidth; - size->heightInMillimeters = pSize->mmHeight; - if (client->swapped) - { - swaps(&size->widthInPixels); - swaps(&size->heightInPixels); - swaps(&size->widthInMillimeters); - swaps(&size->heightInMillimeters); - } - size++; - if (has_rate) - { - *rates = pSize->nRates; - if (client->swapped) - { - swaps(rates); - } - rates++; - for (j = 0; j < pSize->nRates; j++) - { - *rates = pSize->pRates[j].rate; - if (client->swapped) - { - swaps(rates); - } - rates++; - } - } - } + rep.sizeID = pData->size; + rep.rate = pData->refresh; + + extraLen = rep.nSizes * sizeof(xScreenSizes); + if (has_rate) + extraLen += rep.nrateEnts * sizeof(CARD16); + + if (extraLen) { + extra = (CARD8 *) malloc(extraLen); + if (!extra) { + free(pData); + return BadAlloc; + } + } + else + extra = NULL; + + /* + * First comes the size information + */ + size = (xScreenSizes *) extra; + rates = (CARD16 *) (size + rep.nSizes); + for (i = 0; i < pData->nsize; i++) { + pSize = &pData->sizes[i]; + size->widthInPixels = pSize->width; + size->heightInPixels = pSize->height; + size->widthInMillimeters = pSize->mmWidth; + size->heightInMillimeters = pSize->mmHeight; + if (client->swapped) { + swaps(&size->widthInPixels); + swaps(&size->heightInPixels); + swaps(&size->widthInMillimeters); + swaps(&size->heightInMillimeters); + } + size++; + if (has_rate) { + *rates = pSize->nRates; + if (client->swapped) { + swaps(rates); + } + rates++; + for (j = 0; j < pSize->nRates; j++) { + *rates = pSize->pRates[j].rate; + if (client->swapped) { + swaps(rates); + } + rates++; + } + } + } free(pData); - - data8 = (CARD8 *) rates; - if (data8 - (CARD8 *) extra != extraLen) - FatalError ("RRGetScreenInfo bad extra len %ld != %ld\n", - (unsigned long)(data8 - (CARD8 *) extra), extraLen); - rep.length = bytes_to_int32(extraLen); + data8 = (CARD8 *) rates; + + if (data8 - (CARD8 *) extra != extraLen) + FatalError("RRGetScreenInfo bad extra len %ld != %ld\n", + (unsigned long) (data8 - (CARD8 *) extra), extraLen); + rep.length = bytes_to_int32(extraLen); } if (client->swapped) { - 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) - { - WriteToClient (client, extraLen, (char *) extra); - free(extra); + 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) { + WriteToClient(client, extraLen, (char *) extra); + free(extra); } return Success; } int -ProcRRSetScreenConfig (ClientPtr client) +ProcRRSetScreenConfig(ClientPtr client) { REQUEST(xRRSetScreenConfigReq); xRRSetScreenConfigReply rep; - DrawablePtr pDraw; - int rc; - ScreenPtr pScreen; - rrScrPrivPtr pScrPriv; - TimeStamp time; - int i; - Rotation rotation; - int rate; - Bool has_rate; - RROutputPtr output; - RRCrtcPtr crtc; - RRModePtr mode; - RR10DataPtr pData = NULL; - RRScreenSizePtr pSize; - int width, height; - - UpdateCurrentTime (); - - if (RRClientKnowsRates (client)) - { - REQUEST_SIZE_MATCH (xRRSetScreenConfigReq); - has_rate = TRUE; + DrawablePtr pDraw; + int rc; + ScreenPtr pScreen; + rrScrPrivPtr pScrPriv; + TimeStamp time; + int i; + Rotation rotation; + int rate; + Bool has_rate; + RROutputPtr output; + RRCrtcPtr crtc; + RRModePtr mode; + RR10DataPtr pData = NULL; + RRScreenSizePtr pSize; + int width, height; + + UpdateCurrentTime(); + + if (RRClientKnowsRates(client)) { + REQUEST_SIZE_MATCH(xRRSetScreenConfigReq); + has_rate = TRUE; } - else - { - REQUEST_SIZE_MATCH (xRR1_0SetScreenConfigReq); - has_rate = FALSE; + else { + REQUEST_SIZE_MATCH(xRR1_0SetScreenConfigReq); + has_rate = FALSE; } - + rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, DixWriteAccess); if (rc != Success) - return rc; + return rc; pScreen = pDraw->pScreen; pScrPriv = rrGetScrPriv(pScreen); - + time = ClientTimeToServerTime(stuff->timestamp); - - if (!pScrPriv) - { - time = currentTime; - rep.status = RRSetConfigFailed; - goto sendReply; - } - if (!RRGetInfo (pScreen, FALSE)) - return BadAlloc; - - output = RRFirstOutput (pScreen); - if (!output) - { - time = currentTime; - rep.status = RRSetConfigFailed; - goto sendReply; + + if (!pScrPriv) { + time = currentTime; + rep.status = RRSetConfigFailed; + goto sendReply; + } + if (!RRGetInfo(pScreen, FALSE)) + return BadAlloc; + + output = RRFirstOutput(pScreen); + if (!output) { + time = currentTime; + rep.status = RRSetConfigFailed; + goto sendReply; } crtc = output->crtc; @@ -811,27 +764,25 @@ ProcRRSetScreenConfig (ClientPtr client) * timestamp, so using CompareTimeStamps here would cause randr to suddenly * stop working after several hours have passed (freedesktop bug #6502). */ - if (stuff->configTimestamp != pScrPriv->lastConfigTime.milliseconds) - { - rep.status = RRSetConfigInvalidConfigTime; - goto sendReply; + if (stuff->configTimestamp != pScrPriv->lastConfigTime.milliseconds) { + rep.status = RRSetConfigInvalidConfigTime; + goto sendReply; } - - pData = RR10GetData (pScreen, output); + + pData = RR10GetData(pScreen, output); if (!pData) - return BadAlloc; - - if (stuff->sizeID >= pData->nsize) - { - /* - * Invalid size ID - */ - client->errorValue = stuff->sizeID; - free(pData); - return BadValue; + return BadAlloc; + + if (stuff->sizeID >= pData->nsize) { + /* + * Invalid size ID + */ + client->errorValue = stuff->sizeID; + free(pData); + return BadValue; } pSize = &pData->sizes[stuff->sizeID]; - + /* * Validate requested rotation */ @@ -843,63 +794,58 @@ ProcRRSetScreenConfig (ClientPtr client) case RR_Rotate_90: case RR_Rotate_180: case RR_Rotate_270: - break; + break; default: - /* - * Invalid rotation - */ - client->errorValue = stuff->rotation; - free(pData); - return BadValue; + /* + * Invalid rotation + */ + client->errorValue = stuff->rotation; + free(pData); + return BadValue; } - if ((~crtc->rotations) & rotation) - { - /* - * requested rotation or reflection not supported by screen - */ - client->errorValue = stuff->rotation; - free(pData); - return BadMatch; + if ((~crtc->rotations) & rotation) { + /* + * requested rotation or reflection not supported by screen + */ + client->errorValue = stuff->rotation; + free(pData); + return BadMatch; } /* * Validate requested refresh */ if (has_rate) - rate = (int) stuff->rate; + rate = (int) stuff->rate; else - rate = 0; - - if (rate) - { - for (i = 0; i < pSize->nRates; i++) - { - if (pSize->pRates[i].rate == rate) - break; - } - if (i == pSize->nRates) - { - /* - * Invalid rate - */ - client->errorValue = rate; - free(pData); - return BadValue; - } - mode = pSize->pRates[i].mode; + rate = 0; + + if (rate) { + for (i = 0; i < pSize->nRates; i++) { + if (pSize->pRates[i].rate == rate) + break; + } + if (i == pSize->nRates) { + /* + * Invalid rate + */ + client->errorValue = rate; + free(pData); + return BadValue; + } + mode = pSize->pRates[i].mode; } else - mode = pSize->pRates[0].mode; - + mode = pSize->pRates[0].mode; + /* * Make sure the requested set-time is not older than * the last set-time */ - if (CompareTimeStamps (time, pScrPriv->lastSetTime) < 0) - { - rep.status = RRSetConfigInvalidTime; - goto sendReply; + if (CompareTimeStamps(time, pScrPriv->lastSetTime) < 0) { + rep.status = RRSetConfigInvalidTime; + goto sendReply; } /* @@ -909,58 +855,53 @@ ProcRRSetScreenConfig (ClientPtr client) width = mode->mode.width; height = mode->mode.height; if (width < pScrPriv->minWidth || pScrPriv->maxWidth < width) { - client->errorValue = width; - free(pData); - return BadValue; + client->errorValue = width; + free(pData); + return BadValue; } if (height < pScrPriv->minHeight || pScrPriv->maxHeight < height) { - client->errorValue = height; - free(pData); - return BadValue; - } - - if (rotation & (RR_Rotate_90|RR_Rotate_270)) - { - width = mode->mode.height; - height = mode->mode.width; - } - - if (width != pScreen->width || height != pScreen->height) - { - int c; - - for (c = 0; c < pScrPriv->numCrtcs; c++) - { - if (!RRCrtcSet (pScrPriv->crtcs[c], NULL, 0, 0, RR_Rotate_0, - 0, NULL)) - { - rep.status = RRSetConfigFailed; - /* XXX recover from failure */ - goto sendReply; - } - } - if (!RRScreenSizeSet (pScreen, width, height, - pScreen->mmWidth, pScreen->mmHeight)) - { - rep.status = RRSetConfigFailed; - /* XXX recover from failure */ - goto sendReply; - } - } - - if (!RRCrtcSet (crtc, mode, 0, 0, stuff->rotation, 1, &output)) - rep.status = RRSetConfigFailed; + client->errorValue = height; + free(pData); + return BadValue; + } + + if (rotation & (RR_Rotate_90 | RR_Rotate_270)) { + width = mode->mode.height; + height = mode->mode.width; + } + + if (width != pScreen->width || height != pScreen->height) { + int c; + + for (c = 0; c < pScrPriv->numCrtcs; c++) { + if (!RRCrtcSet(pScrPriv->crtcs[c], NULL, 0, 0, RR_Rotate_0, + 0, NULL)) { + rep.status = RRSetConfigFailed; + /* XXX recover from failure */ + goto sendReply; + } + } + if (!RRScreenSizeSet(pScreen, width, height, + pScreen->mmWidth, pScreen->mmHeight)) { + rep.status = RRSetConfigFailed; + /* XXX recover from failure */ + goto sendReply; + } + } + + if (!RRCrtcSet(crtc, mode, 0, 0, stuff->rotation, 1, &output)) + rep.status = RRSetConfigFailed; else { - pScrPriv->lastSetTime = time; - rep.status = RRSetConfigSuccess; + pScrPriv->lastSetTime = time; + rep.status = RRSetConfigSuccess; } /* * XXX Configure other crtcs to mirror as much as possible */ - -sendReply: - + + sendReply: + free(pData); rep.type = X_Reply; @@ -972,40 +913,38 @@ sendReply: rep.newConfigTimestamp = pScrPriv->lastConfigTime.milliseconds; rep.root = pDraw->pScreen->root->drawable.id; - if (client->swapped) - { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - swapl(&rep.newTimestamp); - swapl(&rep.newConfigTimestamp); - swapl(&rep.root); + if (client->swapped) { + swaps(&rep.sequenceNumber); + swapl(&rep.length); + swapl(&rep.newTimestamp); + swapl(&rep.newConfigTimestamp); + swapl(&rep.root); } - WriteToClient(client, sizeof(xRRSetScreenConfigReply), (char *)&rep); + WriteToClient(client, sizeof(xRRSetScreenConfigReply), (char *) &rep); return Success; } static CARD16 -RR10CurrentSizeID (ScreenPtr pScreen) +RR10CurrentSizeID(ScreenPtr pScreen) { - CARD16 sizeID = 0xffff; - RROutputPtr output = RRFirstOutput (pScreen); - - if (output) - { - RR10DataPtr data = RR10GetData (pScreen, output); - if (data) - { - int i; - for (i = 0; i < data->nsize; i++) - if (data->sizes[i].width == pScreen->width && - data->sizes[i].height == pScreen->height) - { - sizeID = (CARD16) i; - break; - } - free(data); - } + CARD16 sizeID = 0xffff; + RROutputPtr output = RRFirstOutput(pScreen); + + if (output) { + RR10DataPtr data = RR10GetData(pScreen, output); + + if (data) { + int i; + + for (i = 0; i < data->nsize; i++) + if (data->sizes[i].width == pScreen->width && + data->sizes[i].height == pScreen->height) { + sizeID = (CARD16) i; + break; + } + free(data); + } } return sizeID; } diff --git a/xorg-server/randr/rrsdispatch.c b/xorg-server/randr/rrsdispatch.c index 543fc9022..9968c7f81 100644 --- a/xorg-server/randr/rrsdispatch.c +++ b/xorg-server/randr/rrsdispatch.c @@ -23,7 +23,7 @@ #include "randrstr.h" static int -SProcRRQueryVersion (ClientPtr client) +SProcRRQueryVersion(ClientPtr client) { REQUEST(xRRQueryVersionReq); @@ -34,7 +34,7 @@ SProcRRQueryVersion (ClientPtr client) } static int -SProcRRGetScreenInfo (ClientPtr client) +SProcRRGetScreenInfo(ClientPtr client) { REQUEST(xRRGetScreenInfoReq); @@ -44,20 +44,18 @@ SProcRRGetScreenInfo (ClientPtr client) } static int -SProcRRSetScreenConfig (ClientPtr client) +SProcRRSetScreenConfig(ClientPtr client) { REQUEST(xRRSetScreenConfigReq); - if (RRClientKnowsRates (client)) - { - REQUEST_SIZE_MATCH (xRRSetScreenConfigReq); - swaps(&stuff->rate); + if (RRClientKnowsRates(client)) { + REQUEST_SIZE_MATCH(xRRSetScreenConfigReq); + swaps(&stuff->rate); } - else - { - REQUEST_SIZE_MATCH (xRR1_0SetScreenConfigReq); + else { + REQUEST_SIZE_MATCH(xRR1_0SetScreenConfigReq); } - + swaps(&stuff->length); swapl(&stuff->drawable); swapl(&stuff->timestamp); @@ -67,7 +65,7 @@ SProcRRSetScreenConfig (ClientPtr client) } static int -SProcRRSelectInput (ClientPtr client) +SProcRRSelectInput(ClientPtr client) { REQUEST(xRRSelectInputReq); @@ -78,7 +76,7 @@ SProcRRSelectInput (ClientPtr client) } static int -SProcRRGetScreenSizeRange (ClientPtr client) +SProcRRGetScreenSizeRange(ClientPtr client) { REQUEST(xRRGetScreenSizeRangeReq); @@ -89,7 +87,7 @@ SProcRRGetScreenSizeRange (ClientPtr client) } static int -SProcRRSetScreenSize (ClientPtr client) +SProcRRSetScreenSize(ClientPtr client) { REQUEST(xRRSetScreenSizeReq); @@ -104,7 +102,7 @@ SProcRRSetScreenSize (ClientPtr client) } static int -SProcRRGetScreenResources (ClientPtr client) +SProcRRGetScreenResources(ClientPtr client) { REQUEST(xRRGetScreenResourcesReq); @@ -115,7 +113,7 @@ SProcRRGetScreenResources (ClientPtr client) } static int -SProcRRGetOutputInfo (ClientPtr client) +SProcRRGetOutputInfo(ClientPtr client) { REQUEST(xRRGetOutputInfoReq); @@ -127,7 +125,7 @@ SProcRRGetOutputInfo (ClientPtr client) } static int -SProcRRListOutputProperties (ClientPtr client) +SProcRRListOutputProperties(ClientPtr client) { REQUEST(xRRListOutputPropertiesReq); @@ -138,7 +136,7 @@ SProcRRListOutputProperties (ClientPtr client) } static int -SProcRRQueryOutputProperty (ClientPtr client) +SProcRRQueryOutputProperty(ClientPtr client) { REQUEST(xRRQueryOutputPropertyReq); @@ -150,7 +148,7 @@ SProcRRQueryOutputProperty (ClientPtr client) } static int -SProcRRConfigureOutputProperty (ClientPtr client) +SProcRRConfigureOutputProperty(ClientPtr client) { REQUEST(xRRConfigureOutputPropertyReq); @@ -162,37 +160,37 @@ SProcRRConfigureOutputProperty (ClientPtr client) } static int -SProcRRChangeOutputProperty (ClientPtr client) +SProcRRChangeOutputProperty(ClientPtr client) { REQUEST(xRRChangeOutputPropertyReq); - REQUEST_AT_LEAST_SIZE (xRRChangeOutputPropertyReq); + REQUEST_AT_LEAST_SIZE(xRRChangeOutputPropertyReq); swaps(&stuff->length); swapl(&stuff->output); swapl(&stuff->property); swapl(&stuff->type); swapl(&stuff->nUnits); - switch(stuff->format) { - case 8: - break; - case 16: - SwapRestS(stuff); - break; - case 32: - SwapRestL(stuff); - break; - default: - client->errorValue = stuff->format; - return BadValue; + switch (stuff->format) { + case 8: + break; + case 16: + SwapRestS(stuff); + break; + case 32: + SwapRestL(stuff); + break; + default: + client->errorValue = stuff->format; + return BadValue; } return (*ProcRandrVector[stuff->randrReqType]) (client); } static int -SProcRRDeleteOutputProperty (ClientPtr client) +SProcRRDeleteOutputProperty(ClientPtr client) { REQUEST(xRRDeleteOutputPropertyReq); - + REQUEST_SIZE_MATCH(xRRDeleteOutputPropertyReq); swaps(&stuff->length); swapl(&stuff->output); @@ -201,7 +199,7 @@ SProcRRDeleteOutputProperty (ClientPtr client) } static int -SProcRRGetOutputProperty (ClientPtr client) +SProcRRGetOutputProperty(ClientPtr client) { REQUEST(xRRGetOutputPropertyReq); @@ -216,9 +214,10 @@ SProcRRGetOutputProperty (ClientPtr client) } static int -SProcRRCreateMode (ClientPtr client) +SProcRRCreateMode(ClientPtr client) { xRRModeInfo *modeinfo; + REQUEST(xRRCreateModeReq); REQUEST_AT_LEAST_SIZE(xRRCreateModeReq); @@ -242,7 +241,7 @@ SProcRRCreateMode (ClientPtr client) } static int -SProcRRDestroyMode (ClientPtr client) +SProcRRDestroyMode(ClientPtr client) { REQUEST(xRRDestroyModeReq); @@ -253,7 +252,7 @@ SProcRRDestroyMode (ClientPtr client) } static int -SProcRRAddOutputMode (ClientPtr client) +SProcRRAddOutputMode(ClientPtr client) { REQUEST(xRRAddOutputModeReq); @@ -265,7 +264,7 @@ SProcRRAddOutputMode (ClientPtr client) } static int -SProcRRDeleteOutputMode (ClientPtr client) +SProcRRDeleteOutputMode(ClientPtr client) { REQUEST(xRRDeleteOutputModeReq); @@ -277,7 +276,7 @@ SProcRRDeleteOutputMode (ClientPtr client) } static int -SProcRRGetCrtcInfo (ClientPtr client) +SProcRRGetCrtcInfo(ClientPtr client) { REQUEST(xRRGetCrtcInfoReq); @@ -289,7 +288,7 @@ SProcRRGetCrtcInfo (ClientPtr client) } static int -SProcRRSetCrtcConfig (ClientPtr client) +SProcRRSetCrtcConfig(ClientPtr client) { REQUEST(xRRSetCrtcConfigReq); @@ -307,7 +306,7 @@ SProcRRSetCrtcConfig (ClientPtr client) } static int -SProcRRGetCrtcGammaSize (ClientPtr client) +SProcRRGetCrtcGammaSize(ClientPtr client) { REQUEST(xRRGetCrtcGammaSizeReq); @@ -318,7 +317,7 @@ SProcRRGetCrtcGammaSize (ClientPtr client) } static int -SProcRRGetCrtcGamma (ClientPtr client) +SProcRRGetCrtcGamma(ClientPtr client) { REQUEST(xRRGetCrtcGammaReq); @@ -329,7 +328,7 @@ SProcRRGetCrtcGamma (ClientPtr client) } static int -SProcRRSetCrtcGamma (ClientPtr client) +SProcRRSetCrtcGamma(ClientPtr client) { REQUEST(xRRSetCrtcGammaReq); @@ -342,30 +341,32 @@ SProcRRSetCrtcGamma (ClientPtr client) } static int -SProcRRSetCrtcTransform (ClientPtr client) +SProcRRSetCrtcTransform(ClientPtr client) { int nparams; char *filter; CARD32 *params; + REQUEST(xRRSetCrtcTransformReq); REQUEST_AT_LEAST_SIZE(xRRSetCrtcTransformReq); swaps(&stuff->length); swapl(&stuff->crtc); - SwapLongs((CARD32 *)&stuff->transform, bytes_to_int32(sizeof(xRenderTransform))); + SwapLongs((CARD32 *) &stuff->transform, + bytes_to_int32(sizeof(xRenderTransform))); swaps(&stuff->nbytesFilter); - filter = (char *)(stuff + 1); + filter = (char *) (stuff + 1); params = (CARD32 *) (filter + pad_to_int32(stuff->nbytesFilter)); nparams = ((CARD32 *) stuff + client->req_len) - params; if (nparams < 0) - return BadLength; + return BadLength; SwapLongs(params, nparams); return (*ProcRandrVector[stuff->randrReqType]) (client); } static int -SProcRRGetCrtcTransform (ClientPtr client) +SProcRRGetCrtcTransform(ClientPtr client) { REQUEST(xRRGetCrtcTransformReq); @@ -376,10 +377,10 @@ SProcRRGetCrtcTransform (ClientPtr client) } static int -SProcRRGetPanning (ClientPtr client) +SProcRRGetPanning(ClientPtr client) { REQUEST(xRRGetPanningReq); - + REQUEST_SIZE_MATCH(xRRGetPanningReq); swaps(&stuff->length); swapl(&stuff->crtc); @@ -387,10 +388,10 @@ SProcRRGetPanning (ClientPtr client) } static int -SProcRRSetPanning (ClientPtr client) +SProcRRSetPanning(ClientPtr client) { REQUEST(xRRSetPanningReq); - + REQUEST_SIZE_MATCH(xRRSetPanningReq); swaps(&stuff->length); swapl(&stuff->crtc); @@ -411,7 +412,7 @@ SProcRRSetPanning (ClientPtr client) } static int -SProcRRSetOutputPrimary (ClientPtr client) +SProcRRSetOutputPrimary(ClientPtr client) { REQUEST(xRRSetOutputPrimaryReq); @@ -419,57 +420,56 @@ SProcRRSetOutputPrimary (ClientPtr client) swaps(&stuff->length); swapl(&stuff->window); swapl(&stuff->output); - return ProcRandrVector[stuff->randrReqType](client); + return ProcRandrVector[stuff->randrReqType] (client); } static int -SProcRRGetOutputPrimary (ClientPtr client) +SProcRRGetOutputPrimary(ClientPtr client) { REQUEST(xRRGetOutputPrimaryReq); REQUEST_SIZE_MATCH(xRRGetOutputPrimaryReq); swaps(&stuff->length); swapl(&stuff->window); - return ProcRandrVector[stuff->randrReqType](client); + return ProcRandrVector[stuff->randrReqType] (client); } -int (*SProcRandrVector[RRNumberRequests])(ClientPtr) = { - SProcRRQueryVersion, /* 0 */ +int (*SProcRandrVector[RRNumberRequests]) (ClientPtr) = { + SProcRRQueryVersion, /* 0 */ /* we skip 1 to make old clients fail pretty immediately */ - NULL, /* 1 SProcRandrOldGetScreenInfo */ + NULL, /* 1 SProcRandrOldGetScreenInfo */ /* V1.0 apps share the same set screen config request id */ - SProcRRSetScreenConfig, /* 2 */ - NULL, /* 3 SProcRandrOldScreenChangeSelectInput */ + SProcRRSetScreenConfig, /* 2 */ + NULL, /* 3 SProcRandrOldScreenChangeSelectInput */ /* 3 used to be ScreenChangeSelectInput; deprecated */ - SProcRRSelectInput, /* 4 */ - SProcRRGetScreenInfo, /* 5 */ + SProcRRSelectInput, /* 4 */ + SProcRRGetScreenInfo, /* 5 */ /* V1.2 additions */ - SProcRRGetScreenSizeRange, /* 6 */ - SProcRRSetScreenSize, /* 7 */ - SProcRRGetScreenResources, /* 8 */ - SProcRRGetOutputInfo, /* 9 */ - SProcRRListOutputProperties,/* 10 */ - SProcRRQueryOutputProperty, /* 11 */ - SProcRRConfigureOutputProperty, /* 12 */ - SProcRRChangeOutputProperty,/* 13 */ - SProcRRDeleteOutputProperty,/* 14 */ - SProcRRGetOutputProperty, /* 15 */ - SProcRRCreateMode, /* 16 */ - SProcRRDestroyMode, /* 17 */ - SProcRRAddOutputMode, /* 18 */ - SProcRRDeleteOutputMode, /* 19 */ - SProcRRGetCrtcInfo, /* 20 */ - SProcRRSetCrtcConfig, /* 21 */ - SProcRRGetCrtcGammaSize, /* 22 */ - SProcRRGetCrtcGamma, /* 23 */ - SProcRRSetCrtcGamma, /* 24 */ + SProcRRGetScreenSizeRange, /* 6 */ + SProcRRSetScreenSize, /* 7 */ + SProcRRGetScreenResources, /* 8 */ + SProcRRGetOutputInfo, /* 9 */ + SProcRRListOutputProperties, /* 10 */ + SProcRRQueryOutputProperty, /* 11 */ + SProcRRConfigureOutputProperty, /* 12 */ + SProcRRChangeOutputProperty, /* 13 */ + SProcRRDeleteOutputProperty, /* 14 */ + SProcRRGetOutputProperty, /* 15 */ + SProcRRCreateMode, /* 16 */ + SProcRRDestroyMode, /* 17 */ + SProcRRAddOutputMode, /* 18 */ + SProcRRDeleteOutputMode, /* 19 */ + SProcRRGetCrtcInfo, /* 20 */ + SProcRRSetCrtcConfig, /* 21 */ + SProcRRGetCrtcGammaSize, /* 22 */ + SProcRRGetCrtcGamma, /* 23 */ + SProcRRSetCrtcGamma, /* 24 */ /* V1.3 additions */ - SProcRRGetScreenResources, /* 25 GetScreenResourcesCurrent */ - SProcRRSetCrtcTransform, /* 26 */ - SProcRRGetCrtcTransform, /* 27 */ - SProcRRGetPanning, /* 28 */ - SProcRRSetPanning, /* 29 */ - SProcRRSetOutputPrimary, /* 30 */ - SProcRRGetOutputPrimary, /* 31 */ + SProcRRGetScreenResources, /* 25 GetScreenResourcesCurrent */ + SProcRRSetCrtcTransform, /* 26 */ + SProcRRGetCrtcTransform, /* 27 */ + SProcRRGetPanning, /* 28 */ + SProcRRSetPanning, /* 29 */ + SProcRRSetOutputPrimary, /* 30 */ + SProcRRGetOutputPrimary, /* 31 */ }; - diff --git a/xorg-server/randr/rrtransform.c b/xorg-server/randr/rrtransform.c index e1620498b..f93181d2e 100644 --- a/xorg-server/randr/rrtransform.c +++ b/xorg-server/randr/rrtransform.c @@ -24,63 +24,59 @@ #include "rrtransform.h" void -RRTransformInit (RRTransformPtr transform) +RRTransformInit(RRTransformPtr transform) { - pixman_transform_init_identity (&transform->transform); - pixman_f_transform_init_identity (&transform->f_transform); - pixman_f_transform_init_identity (&transform->f_inverse); + pixman_transform_init_identity(&transform->transform); + pixman_f_transform_init_identity(&transform->f_transform); + pixman_f_transform_init_identity(&transform->f_inverse); transform->filter = NULL; transform->params = NULL; transform->nparams = 0; } void -RRTransformFini (RRTransformPtr transform) +RRTransformFini(RRTransformPtr transform) { free(transform->params); } Bool -RRTransformEqual (RRTransformPtr a, RRTransformPtr b) +RRTransformEqual(RRTransformPtr a, RRTransformPtr b) { - if (a && pixman_transform_is_identity (&a->transform)) - a = NULL; - if (b && pixman_transform_is_identity (&b->transform)) - b = NULL; + if (a && pixman_transform_is_identity(&a->transform)) + a = NULL; + if (b && pixman_transform_is_identity(&b->transform)) + b = NULL; if (a == NULL && b == NULL) - return TRUE; + return TRUE; if (a == NULL || b == NULL) - return FALSE; - if (memcmp (&a->transform, &b->transform, sizeof (a->transform)) != 0) - return FALSE; + return FALSE; + if (memcmp(&a->transform, &b->transform, sizeof(a->transform)) != 0) + return FALSE; if (a->filter != b->filter) - return FALSE; + return FALSE; if (a->nparams != b->nparams) - return FALSE; - if (memcmp (a->params, b->params, a->nparams * sizeof (xFixed)) != 0) - return FALSE; + return FALSE; + if (memcmp(a->params, b->params, a->nparams * sizeof(xFixed)) != 0) + return FALSE; return TRUE; } Bool -RRTransformSetFilter (RRTransformPtr dst, - PictFilterPtr filter, - xFixed *params, - int nparams, - int width, - int height) +RRTransformSetFilter(RRTransformPtr dst, + PictFilterPtr filter, + xFixed * params, int nparams, int width, int height) { - xFixed *new_params; + xFixed *new_params; - if (nparams) - { - new_params = malloc(nparams * sizeof (xFixed)); - if (!new_params) - return FALSE; - memcpy (new_params, params, nparams * sizeof (xFixed)); + if (nparams) { + new_params = malloc(nparams * sizeof(xFixed)); + if (!new_params) + return FALSE; + memcpy(new_params, params, nparams * sizeof(xFixed)); } else - new_params = NULL; + new_params = NULL; free(dst->params); dst->filter = filter; dst->params = new_params; @@ -91,27 +87,26 @@ RRTransformSetFilter (RRTransformPtr dst, } Bool -RRTransformCopy (RRTransformPtr dst, RRTransformPtr src) +RRTransformCopy(RRTransformPtr dst, RRTransformPtr src) { - if (src && pixman_transform_is_identity (&src->transform)) - src = NULL; + if (src && pixman_transform_is_identity(&src->transform)) + src = NULL; - if (src) - { - if (!RRTransformSetFilter (dst, src->filter, - src->params, src->nparams, src->width, src->height)) - return FALSE; - dst->transform = src->transform; - dst->f_transform = src->f_transform; - dst->f_inverse = src->f_inverse; + if (src) { + if (!RRTransformSetFilter(dst, src->filter, + src->params, src->nparams, src->width, + src->height)) + return FALSE; + dst->transform = src->transform; + dst->f_transform = src->f_transform; + dst->f_inverse = src->f_inverse; } - else - { - if (!RRTransformSetFilter (dst, NULL, NULL, 0, 0, 0)) - return FALSE; - pixman_transform_init_identity (&dst->transform); - pixman_f_transform_init_identity (&dst->f_transform); - pixman_f_transform_init_identity (&dst->f_inverse); + else { + if (!RRTransformSetFilter(dst, NULL, NULL, 0, 0, 0)) + return FALSE; + pixman_transform_init_identity(&dst->transform); + pixman_f_transform_init_identity(&dst->f_transform); + pixman_f_transform_init_identity(&dst->f_inverse); } return TRUE; } @@ -125,13 +120,13 @@ RRTransformRescale(struct pixman_f_transform *f_transform, double limit) int i, j; for (j = 0; j < 3; j++) - for (i = 0; i < 3; i++) - if ((v = abs (f_transform->m[j][i])) > max) - max = v; + for (i = 0; i < 3; i++) + if ((v = abs(f_transform->m[j][i])) > max) + max = v; scale = limit / max; for (j = 0; j < 3; j++) - for (i = 0; i < 3; i++) - f_transform->m[j][i] *= scale; + for (i = 0; i < 3; i++) + f_transform->m[j][i] *= scale; } /* @@ -142,142 +137,161 @@ RRTransformRescale(struct pixman_f_transform *f_transform, double limit) * Return TRUE if the resulting transform is not a simple translation. */ Bool -RRTransformCompute (int x, - int y, - int width, - int height, - Rotation rotation, - RRTransformPtr rr_transform, - - PictTransformPtr transform, - struct pixman_f_transform *f_transform, - struct pixman_f_transform *f_inverse) +RRTransformCompute(int x, + int y, + int width, + int height, + Rotation rotation, + RRTransformPtr rr_transform, + PictTransformPtr transform, + struct pixman_f_transform *f_transform, + struct pixman_f_transform *f_inverse) { - PictTransform t_transform, inverse; + PictTransform t_transform, inverse; struct pixman_f_transform tf_transform, tf_inverse; - Bool overflow = FALSE; + Bool overflow = FALSE; + + if (!transform) + transform = &t_transform; + if (!f_transform) + f_transform = &tf_transform; + if (!f_inverse) + f_inverse = &tf_inverse; + + pixman_transform_init_identity(transform); + pixman_transform_init_identity(&inverse); + pixman_f_transform_init_identity(f_transform); + pixman_f_transform_init_identity(f_inverse); + if (rotation != RR_Rotate_0) { + double f_rot_cos, f_rot_sin, f_rot_dx, f_rot_dy; + double f_scale_x, f_scale_y, f_scale_dx, f_scale_dy; + xFixed rot_cos, rot_sin, rot_dx, rot_dy; + xFixed scale_x, scale_y, scale_dx, scale_dy; - if (!transform) transform = &t_transform; - if (!f_transform) f_transform = &tf_transform; - if (!f_inverse) f_inverse = &tf_inverse; + /* rotation */ + switch (rotation & 0xf) { + default: + case RR_Rotate_0: + f_rot_cos = 1; + f_rot_sin = 0; + f_rot_dx = 0; + f_rot_dy = 0; + rot_cos = F(1); + rot_sin = F(0); + rot_dx = F(0); + rot_dy = F(0); + break; + case RR_Rotate_90: + f_rot_cos = 0; + f_rot_sin = 1; + f_rot_dx = height; + f_rot_dy = 0; + rot_cos = F(0); + rot_sin = F(1); + rot_dx = F(height); + rot_dy = F(0); + break; + case RR_Rotate_180: + f_rot_cos = -1; + f_rot_sin = 0; + f_rot_dx = width; + f_rot_dy = height; + rot_cos = F(-1); + rot_sin = F(0); + rot_dx = F(width); + rot_dy = F(height); + break; + case RR_Rotate_270: + f_rot_cos = 0; + f_rot_sin = -1; + f_rot_dx = 0; + f_rot_dy = width; + rot_cos = F(0); + rot_sin = F(-1); + rot_dx = F(0); + rot_dy = F(width); + break; + } - pixman_transform_init_identity (transform); - pixman_transform_init_identity (&inverse); - pixman_f_transform_init_identity (f_transform); - pixman_f_transform_init_identity (f_inverse); - if (rotation != RR_Rotate_0) - { - double f_rot_cos, f_rot_sin, f_rot_dx, f_rot_dy; - double f_scale_x, f_scale_y, f_scale_dx, f_scale_dy; - xFixed rot_cos, rot_sin, rot_dx, rot_dy; - xFixed scale_x, scale_y, scale_dx, scale_dy; + pixman_transform_rotate(transform, &inverse, rot_cos, rot_sin); + pixman_transform_translate(transform, &inverse, rot_dx, rot_dy); + pixman_f_transform_rotate(f_transform, f_inverse, f_rot_cos, f_rot_sin); + pixman_f_transform_translate(f_transform, f_inverse, f_rot_dx, + f_rot_dy); - /* rotation */ - switch (rotation & 0xf) { - default: - case RR_Rotate_0: - f_rot_cos = 1; f_rot_sin = 0; - f_rot_dx = 0; f_rot_dy = 0; - rot_cos = F ( 1); rot_sin = F ( 0); - rot_dx = F ( 0); rot_dy = F ( 0); - break; - case RR_Rotate_90: - f_rot_cos = 0; f_rot_sin = 1; - f_rot_dx = height; f_rot_dy = 0; - rot_cos = F ( 0); rot_sin = F ( 1); - rot_dx = F ( height); rot_dy = F (0); - break; - case RR_Rotate_180: - f_rot_cos = -1; f_rot_sin = 0; - f_rot_dx = width; f_rot_dy = height; - rot_cos = F (-1); rot_sin = F ( 0); - rot_dx = F (width); rot_dy = F ( height); - break; - case RR_Rotate_270: - f_rot_cos = 0; f_rot_sin = -1; - f_rot_dx = 0; f_rot_dy = width; - rot_cos = F ( 0); rot_sin = F (-1); - rot_dx = F ( 0); rot_dy = F ( width); - break; - } - - pixman_transform_rotate (transform, &inverse, rot_cos, rot_sin); - pixman_transform_translate (transform, &inverse, rot_dx, rot_dy); - pixman_f_transform_rotate (f_transform, f_inverse, f_rot_cos, f_rot_sin); - pixman_f_transform_translate (f_transform, f_inverse, f_rot_dx, f_rot_dy); + /* reflection */ + f_scale_x = 1; + f_scale_dx = 0; + f_scale_y = 1; + f_scale_dy = 0; + scale_x = F(1); + scale_dx = 0; + scale_y = F(1); + scale_dy = 0; + if (rotation & RR_Reflect_X) { + f_scale_x = -1; + scale_x = F(-1); + if (rotation & (RR_Rotate_0 | RR_Rotate_180)) { + f_scale_dx = width; + scale_dx = F(width); + } + else { + f_scale_dx = height; + scale_dx = F(height); + } + } + if (rotation & RR_Reflect_Y) { + f_scale_y = -1; + scale_y = F(-1); + if (rotation & (RR_Rotate_0 | RR_Rotate_180)) { + f_scale_dy = height; + scale_dy = F(height); + } + else { + f_scale_dy = width; + scale_dy = F(width); + } + } - /* reflection */ - f_scale_x = 1; - f_scale_dx = 0; - f_scale_y = 1; - f_scale_dy = 0; - scale_x = F (1); - scale_dx = 0; - scale_y = F (1); - scale_dy = 0; - if (rotation & RR_Reflect_X) - { - f_scale_x = -1; - scale_x = F(-1); - if (rotation & (RR_Rotate_0|RR_Rotate_180)) { - f_scale_dx = width; - scale_dx = F(width); - } else { - f_scale_dx = height; - scale_dx = F(height); - } - } - if (rotation & RR_Reflect_Y) - { - f_scale_y = -1; - scale_y = F(-1); - if (rotation & (RR_Rotate_0|RR_Rotate_180)) { - f_scale_dy = height; - scale_dy = F(height); - } else { - f_scale_dy = width; - scale_dy = F(width); - } - } - - pixman_transform_scale (transform, &inverse, scale_x, scale_y); - pixman_f_transform_scale (f_transform, f_inverse, f_scale_x, f_scale_y); - pixman_transform_translate (transform, &inverse, scale_dx, scale_dy); - pixman_f_transform_translate (f_transform, f_inverse, f_scale_dx, f_scale_dy); + pixman_transform_scale(transform, &inverse, scale_x, scale_y); + pixman_f_transform_scale(f_transform, f_inverse, f_scale_x, f_scale_y); + pixman_transform_translate(transform, &inverse, scale_dx, scale_dy); + pixman_f_transform_translate(f_transform, f_inverse, f_scale_dx, + f_scale_dy); } - + #ifdef RANDR_12_INTERFACE - if (rr_transform) - { - if (!pixman_transform_multiply (transform, &rr_transform->transform, transform)) - overflow = TRUE; - pixman_f_transform_multiply (f_transform, &rr_transform->f_transform, f_transform); - pixman_f_transform_multiply (f_inverse, f_inverse, &rr_transform->f_inverse); + if (rr_transform) { + if (!pixman_transform_multiply + (transform, &rr_transform->transform, transform)) + overflow = TRUE; + pixman_f_transform_multiply(f_transform, &rr_transform->f_transform, + f_transform); + pixman_f_transform_multiply(f_inverse, f_inverse, + &rr_transform->f_inverse); } #endif /* * Compute the class of the resulting transform */ - if (!overflow && pixman_transform_is_identity (transform)) - { - pixman_transform_init_translate (transform, F ( x), F ( y)); + if (!overflow && pixman_transform_is_identity(transform)) { + pixman_transform_init_translate(transform, F(x), F(y)); - pixman_f_transform_init_translate (f_transform, x, y); - pixman_f_transform_init_translate (f_inverse, -x, -y); - return FALSE; + pixman_f_transform_init_translate(f_transform, x, y); + pixman_f_transform_init_translate(f_inverse, -x, -y); + return FALSE; } - else - { - pixman_f_transform_translate (f_transform, f_inverse, x, y); - if (!pixman_transform_translate (transform, &inverse, F(x), F(y))) - overflow = TRUE; - if (overflow) - { - struct pixman_f_transform f_scaled; - f_scaled = *f_transform; - RRTransformRescale(&f_scaled, 16384.0); - pixman_transform_from_pixman_f_transform(transform, &f_scaled); - } - return TRUE; + else { + pixman_f_transform_translate(f_transform, f_inverse, x, y); + if (!pixman_transform_translate(transform, &inverse, F(x), F(y))) + overflow = TRUE; + if (overflow) { + struct pixman_f_transform f_scaled; + + f_scaled = *f_transform; + RRTransformRescale(&f_scaled, 16384.0); + pixman_transform_from_pixman_f_transform(transform, &f_scaled); + } + return TRUE; } } diff --git a/xorg-server/randr/rrtransform.h b/xorg-server/randr/rrtransform.h index 561762dfe..efce7e0d7 100644 --- a/xorg-server/randr/rrtransform.h +++ b/xorg-server/randr/rrtransform.h @@ -26,50 +26,47 @@ #include <X11/extensions/randr.h> #include "picturestr.h" -typedef struct _rrTransform RRTransformRec, *RRTransformPtr; +typedef struct _rrTransform RRTransformRec, *RRTransformPtr; struct _rrTransform { - PictTransform transform; + PictTransform transform; struct pict_f_transform f_transform; struct pict_f_transform f_inverse; - PictFilterPtr filter; - xFixed *params; - int nparams; - int width; - int height; + PictFilterPtr filter; + xFixed *params; + int nparams; + int width; + int height; }; extern _X_EXPORT void -RRTransformInit (RRTransformPtr transform); + RRTransformInit(RRTransformPtr transform); extern _X_EXPORT void -RRTransformFini (RRTransformPtr transform); + RRTransformFini(RRTransformPtr transform); extern _X_EXPORT Bool -RRTransformEqual (RRTransformPtr a, RRTransformPtr b); + RRTransformEqual(RRTransformPtr a, RRTransformPtr b); extern _X_EXPORT Bool -RRTransformSetFilter (RRTransformPtr dst, - PictFilterPtr filter, - xFixed *params, - int nparams, - int width, - int height); -extern _X_EXPORT Bool -RRTransformCopy (RRTransformPtr dst, RRTransformPtr src); +RRTransformSetFilter(RRTransformPtr dst, + PictFilterPtr filter, + xFixed * params, int nparams, int width, int height); extern _X_EXPORT Bool -RRTransformCompute (int x, - int y, - int width, - int height, - Rotation rotation, - RRTransformPtr rr_transform, + RRTransformCopy(RRTransformPtr dst, RRTransformPtr src); - PictTransformPtr transform, - struct pict_f_transform *f_transform, - struct pict_f_transform *f_inverse); +extern _X_EXPORT Bool +RRTransformCompute(int x, + int y, + int width, + int height, + Rotation rotation, + RRTransformPtr rr_transform, + PictTransformPtr transform, + struct pict_f_transform *f_transform, + struct pict_f_transform *f_inverse); -#endif /* _RRTRANSFORM_H_ */ +#endif /* _RRTRANSFORM_H_ */ diff --git a/xorg-server/randr/rrxinerama.c b/xorg-server/randr/rrxinerama.c index 6d4519043..aa8a61eee 100644 --- a/xorg-server/randr/rrxinerama.c +++ b/xorg-server/randr/rrxinerama.c @@ -89,7 +89,7 @@ static int SProcRRXineramaDispatch(ClientPtr client); int ProcRRXineramaQueryVersion(ClientPtr client) { - xPanoramiXQueryVersionReply rep; + xPanoramiXQueryVersionReply rep; REQUEST_SIZE_MATCH(xPanoramiXQueryVersionReq); rep.type = X_Reply; @@ -97,13 +97,13 @@ ProcRRXineramaQueryVersion(ClientPtr client) rep.sequenceNumber = client->sequence; rep.majorVersion = SERVER_RRXINERAMA_MAJOR_VERSION; rep.minorVersion = SERVER_RRXINERAMA_MINOR_VERSION; - if(client->swapped) { + if (client->swapped) { swaps(&rep.sequenceNumber); swapl(&rep.length); swaps(&rep.majorVersion); swaps(&rep.minorVersion); } - WriteToClient(client, sizeof(xPanoramiXQueryVersionReply), (char *)&rep); + WriteToClient(client, sizeof(xPanoramiXQueryVersionReply), (char *) &rep); return Success; } @@ -111,24 +111,23 @@ int ProcRRXineramaGetState(ClientPtr client) { REQUEST(xPanoramiXGetStateReq); - WindowPtr pWin; - xPanoramiXGetStateReply rep; - register int rc; - ScreenPtr pScreen; - rrScrPrivPtr pScrPriv; - Bool active = FALSE; + 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; + if (rc != Success) + return rc; pScreen = pWin->drawable.pScreen; pScrPriv = rrGetScrPriv(pScreen); - if (pScrPriv) - { - /* XXX do we need more than this? */ - active = TRUE; + if (pScrPriv) { + /* XXX do we need more than this? */ + active = TRUE; } rep.type = X_Reply; @@ -136,67 +135,66 @@ ProcRRXineramaGetState(ClientPtr client) rep.sequenceNumber = client->sequence; rep.state = active; rep.window = stuff->window; - if(client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - swapl(&rep.window); + if (client->swapped) { + swaps(&rep.sequenceNumber); + swapl(&rep.length); + swapl(&rep.window); } - WriteToClient(client, sizeof(xPanoramiXGetStateReply), (char *)&rep); + WriteToClient(client, sizeof(xPanoramiXGetStateReply), (char *) &rep); return Success; } static Bool -RRXineramaCrtcActive (RRCrtcPtr crtc) +RRXineramaCrtcActive(RRCrtcPtr crtc) { return crtc->mode != NULL && crtc->numOutputs > 0; } static int -RRXineramaScreenCount (ScreenPtr pScreen) +RRXineramaScreenCount(ScreenPtr pScreen) { - int i, n; - + int i, n; + n = 0; - if (rrGetScrPriv (pScreen)) - { - rrScrPriv(pScreen); - for (i = 0; i < pScrPriv->numCrtcs; i++) - if (RRXineramaCrtcActive (pScrPriv->crtcs[i])) - n++; + 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) +RRXineramaScreenActive(ScreenPtr pScreen) { - return RRXineramaScreenCount (pScreen) > 0; + return RRXineramaScreenCount(pScreen) > 0; } int ProcRRXineramaGetScreenCount(ClientPtr client) { REQUEST(xPanoramiXGetScreenCountReq); - WindowPtr pWin; - xPanoramiXGetScreenCountReply rep; - register int rc; + WindowPtr pWin; + xPanoramiXGetScreenCountReply rep; + register int rc; REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq); rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); if (rc != Success) - return rc; - + return rc; + rep.type = X_Reply; rep.length = 0; rep.sequenceNumber = client->sequence; - rep.ScreenCount = RRXineramaScreenCount (pWin->drawable.pScreen); + rep.ScreenCount = RRXineramaScreenCount(pWin->drawable.pScreen); rep.window = stuff->window; - if(client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - swapl(&rep.window); + if (client->swapped) { + swaps(&rep.sequenceNumber); + swapl(&rep.length); + swapl(&rep.window); } - WriteToClient(client, sizeof(xPanoramiXGetScreenCountReply), (char *)&rep); + WriteToClient(client, sizeof(xPanoramiXGetScreenCountReply), (char *) &rep); return Success; } @@ -204,42 +202,42 @@ int ProcRRXineramaGetScreenSize(ClientPtr client) { REQUEST(xPanoramiXGetScreenSizeReq); - WindowPtr pWin, pRoot; - ScreenPtr pScreen; - xPanoramiXGetScreenSizeReply rep; - register int rc; + 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; + 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.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); + 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); + WriteToClient(client, sizeof(xPanoramiXGetScreenSizeReply), (char *) &rep); return Success; } int ProcRRXineramaIsActive(ClientPtr client) { - xXineramaIsActiveReply rep; + xXineramaIsActiveReply rep; REQUEST_SIZE_MATCH(xXineramaIsActiveReq); @@ -247,11 +245,11 @@ ProcRRXineramaIsActive(ClientPtr client) 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); + 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; @@ -262,79 +260,80 @@ 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); + 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]; + xXineramaQueryScreensReply rep; + ScreenPtr pScreen = screenInfo.screens[RR_XINERAMA_SCREEN]; REQUEST_SIZE_MATCH(xXineramaQueryScreensReq); - if (RRXineramaScreenActive (pScreen)) - RRGetInfo (pScreen, FALSE); + if (RRXineramaScreenActive(pScreen)) + RRGetInfo(pScreen, FALSE); rep.type = X_Reply; rep.sequenceNumber = client->sequence; - rep.number = RRXineramaScreenCount (pScreen); + 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); + 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]); - } + 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; @@ -345,18 +344,18 @@ 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); + 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; } @@ -364,11 +363,11 @@ ProcRRXineramaDispatch(ClientPtr client) /* SProc */ static int -SProcRRXineramaQueryVersion (ClientPtr client) +SProcRRXineramaQueryVersion(ClientPtr client) { REQUEST(xPanoramiXQueryVersionReq); swaps(&stuff->length); - REQUEST_SIZE_MATCH (xPanoramiXQueryVersionReq); + REQUEST_SIZE_MATCH(xPanoramiXQueryVersionReq); return ProcRRXineramaQueryVersion(client); } @@ -426,18 +425,18 @@ 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); + 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; } @@ -446,8 +445,8 @@ void RRXineramaExtensionInit(void) { #ifdef PANORAMIX - if(!noPanoramiXExtension) - return; + if (!noPanoramiXExtension) + return; #endif /* @@ -456,11 +455,9 @@ RRXineramaExtensionInit(void) * screen, just don't even try. */ if (screenInfo.numScreens > 1) - return; + return; - (void) AddExtension(PANORAMIX_PROTOCOL_NAME, 0,0, - ProcRRXineramaDispatch, - SProcRRXineramaDispatch, - NULL, - StandardMinorOpcode); + (void) AddExtension(PANORAMIX_PROTOCOL_NAME, 0, 0, + ProcRRXineramaDispatch, + SProcRRXineramaDispatch, NULL, StandardMinorOpcode); } |