Commit e440ea76 authored by Mike Gabriel's avatar Mike Gabriel

randr extension: Convert to Xorg coding style.

The reformatting has been achieved by applying x-indent.sh to all .c and .h files in Xserver/randr/.
parent 7f7c96c7
......@@ -67,13 +67,13 @@ typedef struct {
#define sz_xPanoramiXQueryVersionReply 32
typedef struct _PanoramiXGetState {
CARD8 reqType; /* always PanoramiXReqCode */
CARD8 panoramiXReqType; /* always X_PanoramiXGetState */
CARD16 length B16;
CARD32 window B32;
} xPanoramiXGetStateReq;
#define sz_xPanoramiXGetStateReq 8
typedef struct {
......@@ -97,6 +97,7 @@ typedef struct _PanoramiXGetScreenCount {
CARD16 length B16;
CARD32 window B32;
} xPanoramiXGetScreenCountReq;
#define sz_xPanoramiXGetScreenCountReq 8
typedef struct {
......@@ -111,6 +112,7 @@ typedef struct {
CARD32 pad4 B32; /* unused */
CARD32 pad5 B32; /* unused */
} xPanoramiXGetScreenCountReply;
#define sz_panoramiXGetScreenCountReply 32
typedef struct _PanoramiXGetScreenSize {
......@@ -120,6 +122,7 @@ typedef struct _PanoramiXGetScreenSize {
CARD32 window B32;
CARD32 screen B32;
} xPanoramiXGetScreenSizeReq;
#define sz_xPanoramiXGetScreenSizeReq 12
typedef struct {
......@@ -134,6 +137,7 @@ typedef struct {
CARD32 pad2 B32; /* unused */
CARD32 pad3 B32; /* unused */
} xPanoramiXGetScreenSizeReply;
#define sz_panoramiXGetScreenSizeReply 32
/************ Alternate protocol ******************/
......@@ -143,6 +147,7 @@ typedef struct {
CARD8 panoramiXReqType;
CARD16 length B16;
} xXineramaIsActiveReq;
#define sz_xXineramaIsActiveReq 4
typedef struct {
......@@ -157,14 +162,15 @@ typedef struct {
CARD32 pad5 B32;
CARD32 pad6 B32;
} xXineramaIsActiveReply;
#define sz_XineramaIsActiveReply 32
#define sz_XineramaIsActiveReply 32
typedef struct {
CARD8 reqType;
CARD8 panoramiXReqType;
CARD16 length B16;
} xXineramaQueryScreensReq;
#define sz_xXineramaQueryScreensReq 4
typedef struct {
......@@ -179,6 +185,7 @@ typedef struct {
CARD32 pad5 B32;
CARD32 pad6 B32;
} xXineramaQueryScreensReply;
#define sz_XineramaQueryScreensReply 32
typedef struct {
......@@ -187,6 +194,7 @@ typedef struct {
CARD16 width B16;
CARD16 height B16;
} xXineramaScreenInfo;
#define sz_XineramaScreenInfo 8
#endif
......@@ -67,8 +67,8 @@ static int RRNScreens;
real->mem = priv->mem; \
}
static int ProcRRDispatch (ClientPtr pClient);
static int SProcRRDispatch (ClientPtr pClient);
static int ProcRRDispatch(ClientPtr pClient);
static int SProcRRDispatch(ClientPtr pClient);
int RREventBase;
int RRErrorBase;
......@@ -83,25 +83,23 @@ int rrPrivIndex = -1;
#endif
static void
RRClientCallback (CallbackListPtr *list,
void * closure,
void * data)
RRClientCallback(CallbackListPtr *list, void *closure, void *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++)
{
for (i = 0; i < screenInfo.numScreens; i++) {
ScreenPtr pScreen = screenInfo.screens[i];
rrScrPriv(pScreen);
if (pScrPriv)
{
if (pScrPriv) {
pTimes[i].setTime = pScrPriv->lastSetTime;
pTimes[i].configTime = pScrPriv->lastConfigTime;
}
......@@ -109,32 +107,32 @@ RRClientCallback (CallbackListPtr *list,
}
static void
RRResetProc (ExtensionEntry *extEntry)
RRResetProc(ExtensionEntry * extEntry)
{
}
static Bool
RRCloseScreen (int i, ScreenPtr pScreen)
RRCloseScreen(int i, ScreenPtr pScreen)
{
rrScrPriv(pScreen);
int j;
unwrap (pScrPriv, pScreen, CloseScreen);
unwrap(pScrPriv, pScreen, CloseScreen);
for (j = pScrPriv->numCrtcs - 1; j >= 0; j--)
RRCrtcDestroy (pScrPriv->crtcs[j]);
RRCrtcDestroy(pScrPriv->crtcs[j]);
for (j = pScrPriv->numOutputs - 1; j >= 0; j--)
RROutputDestroy (pScrPriv->outputs[j]);
RROutputDestroy(pScrPriv->outputs[j]);
xfree (pScrPriv->crtcs);
xfree (pScrPriv->outputs);
xfree (pScrPriv);
xfree(pScrPriv->crtcs);
xfree(pScrPriv->outputs);
xfree(pScrPriv);
RRNScreens -= 1; /* ok, one fewer screen with RandR running */
return (*pScreen->CloseScreen) (i, pScreen);
}
static void
SRRScreenChangeNotifyEvent(xRRScreenChangeNotifyEvent *from,
xRRScreenChangeNotifyEvent *to)
SRRScreenChangeNotifyEvent(xRRScreenChangeNotifyEvent * from,
xRRScreenChangeNotifyEvent * to)
{
to->type = from->type;
to->rotation = from->rotation;
......@@ -152,8 +150,8 @@ SRRScreenChangeNotifyEvent(xRRScreenChangeNotifyEvent *from,
}
static void
SRRCrtcChangeNotifyEvent(xRRCrtcChangeNotifyEvent *from,
xRRCrtcChangeNotifyEvent *to)
SRRCrtcChangeNotifyEvent(xRRCrtcChangeNotifyEvent * from,
xRRCrtcChangeNotifyEvent * to)
{
to->type = from->type;
to->subCode = from->subCode;
......@@ -171,8 +169,8 @@ SRRCrtcChangeNotifyEvent(xRRCrtcChangeNotifyEvent *from,
}
static void
SRROutputChangeNotifyEvent(xRROutputChangeNotifyEvent *from,
xRROutputChangeNotifyEvent *to)
SRROutputChangeNotifyEvent(xRROutputChangeNotifyEvent * from,
xRROutputChangeNotifyEvent * to)
{
to->type = from->type;
to->subCode = from->subCode;
......@@ -187,8 +185,8 @@ SRROutputChangeNotifyEvent(xRROutputChangeNotifyEvent *from,
}
static void
SRROutputPropertyNotifyEvent(xRROutputPropertyNotifyEvent *from,
xRROutputPropertyNotifyEvent *to)
SRROutputPropertyNotifyEvent(xRROutputPropertyNotifyEvent * from,
xRROutputPropertyNotifyEvent * to)
{
to->type = from->type;
to->subCode = from->subCode;
......@@ -200,20 +198,19 @@ SRROutputPropertyNotifyEvent(xRROutputPropertyNotifyEvent *from,
}
static void
SRRNotifyEvent (xEvent *from,
xEvent *to)
SRRNotifyEvent(xEvent *from, xEvent *to)
{
switch (from->u.u.detail) {
case RRNotify_CrtcChange:
SRRCrtcChangeNotifyEvent ((xRRCrtcChangeNotifyEvent *) from,
SRRCrtcChangeNotifyEvent((xRRCrtcChangeNotifyEvent *) from,
(xRRCrtcChangeNotifyEvent *) to);
break;
case RRNotify_OutputChange:
SRROutputChangeNotifyEvent ((xRROutputChangeNotifyEvent *) from,
SRROutputChangeNotifyEvent((xRROutputChangeNotifyEvent *) from,
(xRROutputChangeNotifyEvent *) to);
break;
case RRNotify_OutputProperty:
SRROutputPropertyNotifyEvent ((xRROutputPropertyNotifyEvent *) from,
SRROutputPropertyNotifyEvent((xRROutputPropertyNotifyEvent *) from,
(xRROutputPropertyNotifyEvent *) to);
break;
default:
......@@ -223,33 +220,34 @@ SRRNotifyEvent (xEvent *from,
static int RRGeneration;
Bool RRInit (void)
Bool
RRInit(void)
{
if (RRGeneration != serverGeneration)
{
#ifdef NXAGENT_SERVER
if (RRGeneration != serverGeneration) {
#ifdef NXAGENT_SERVER
if ((rrPrivIndex = AllocateScreenPrivateIndex()) < 0)
return FALSE;
#endif
if (!RRModeInit ())
#endif
if (!RRModeInit())
return FALSE;
if (!RRCrtcInit ())
if (!RRCrtcInit())
return FALSE;
if (!RROutputInit ())
if (!RROutputInit())
return FALSE;
RRGeneration = serverGeneration;
}
return TRUE;
}
Bool RRScreenInit(ScreenPtr pScreen)
Bool
RRScreenInit(ScreenPtr pScreen)
{
rrScrPrivPtr pScrPriv;
if (!RRInit ())
if (!RRInit())
return FALSE;
pScrPriv = (rrScrPrivPtr) xcalloc (1, sizeof (rrScrPrivRec));
pScrPriv = (rrScrPrivPtr) xcalloc(1, sizeof(rrScrPrivRec));
if (!pScrPriv)
return FALSE;
......@@ -291,7 +289,7 @@ Bool RRScreenInit(ScreenPtr pScreen)
pScrPriv->lastSetTime = currentTime;
pScrPriv->lastConfigTime = currentTime;
wrap (pScrPriv, pScreen, CloseScreen, RRCloseScreen);
wrap(pScrPriv, pScreen, CloseScreen, RRCloseScreen);
pScrPriv->numOutputs = 0;
pScrPriv->outputs = NULL;
......@@ -302,9 +300,8 @@ Bool RRScreenInit(ScreenPtr pScreen)
return TRUE;
}
/*ARGSUSED*/
static int
RRFreeClient (void * data, XID id)
/*ARGSUSED*/ static int
RRFreeClient(void *data, XID id)
{
RREventPtr pRREvent;
WindowPtr pWin;
......@@ -315,56 +312,55 @@ RRFreeClient (void * data, XID id)
pHead = (RREventPtr *) LookupIDByType(pWin->drawable.id, RREventType);
if (pHead) {
pPrev = 0;
for (pCur = *pHead; pCur && pCur != pRREvent; pCur=pCur->next)
for (pCur = *pHead; pCur && pCur != pRREvent; pCur = pCur->next)
pPrev = pCur;
if (pCur)
{
if (pCur) {
if (pPrev)
pPrev->next = pRREvent->next;
else
*pHead = pRREvent->next;
}
}
xfree ((void *) pRREvent);
xfree((void *) pRREvent);
return 1;
}
/*ARGSUSED*/
static int
RRFreeEvents (void * data, XID id)
/*ARGSUSED*/ static int
RRFreeEvents(void *data, XID id)
{
RREventPtr *pHead, pCur, pNext;
pHead = (RREventPtr *) data;
for (pCur = *pHead; pCur; pCur = pNext) {
pNext = pCur->next;
FreeResource (pCur->clientResource, RRClientType);
xfree ((void *) pCur);
FreeResource(pCur->clientResource, RRClientType);
xfree((void *) pCur);
}
xfree ((void *) pHead);
xfree((void *) pHead);
return 1;
}
void
RRExtensionInit (void)
RRExtensionInit(void)
{
ExtensionEntry *extEntry;
if (RRNScreens == 0) return;
if (RRNScreens == 0)
return;
#ifndef NXAGENT_SERVER
#ifndef NXAGENT_SERVER
if (!dixRequestPrivate(RRClientPrivateKey,
sizeof (RRClientRec) +
screenInfo.numScreens * sizeof (RRTimesRec)))
sizeof(RRClientRec) +
screenInfo.numScreens * sizeof(RRTimesRec)))
return;
#else
RRClientPrivateIndex = AllocateClientPrivateIndex ();
if (!AllocateClientPrivate (RRClientPrivateIndex,
sizeof (RRClientRec) +
screenInfo.numScreens * sizeof (RRTimesRec)))
#else
RRClientPrivateIndex = AllocateClientPrivateIndex();
if (!AllocateClientPrivate(RRClientPrivateIndex,
sizeof(RRClientRec) +
screenInfo.numScreens * sizeof(RRTimesRec)))
return;
#endif
if (!AddCallback (&ClientStateCallback, RRClientCallback, 0))
#endif
if (!AddCallback(&ClientStateCallback, RRClientCallback, 0))
return;
RRClientType = CreateNewResourceType(RRFreeClient);
......@@ -373,7 +369,7 @@ RRExtensionInit (void)
RREventType = CreateNewResourceType(RRFreeEvents);
if (!RREventType)
return;
extEntry = AddExtension (RANDR_NAME, RRNumberEvents, RRNumberErrors,
extEntry = AddExtension(RANDR_NAME, RRNumberEvents, RRNumberErrors,
ProcRRDispatch, SProcRRDispatch,
RRResetProc, StandardMinorOpcode);
if (!extEntry)
......@@ -390,44 +386,42 @@ RRExtensionInit (void)
}
static int
TellChanged (WindowPtr pWin, void * value)
TellChanged(WindowPtr pWin, void *value)
{
RREventPtr *pHead, pRREvent;
ClientPtr client;
ScreenPtr pScreen = pWin->drawable.pScreen;
rrScrPriv(pScreen);
int i;
pHead = (RREventPtr *) LookupIDByType (pWin->drawable.id, RREventType);
pHead = (RREventPtr *) LookupIDByType(pWin->drawable.id, RREventType);
if (!pHead)
return WT_WALKCHILDREN;
for (pRREvent = *pHead; pRREvent; pRREvent = pRREvent->next)
{
for (pRREvent = *pHead; pRREvent; pRREvent = pRREvent->next) {
client = pRREvent->client;
if (client == serverClient || client->clientGone)
continue;
if (pRREvent->mask & RRScreenChangeNotifyMask)
RRDeliverScreenEvent (client, pWin, pScreen);
RRDeliverScreenEvent(client, pWin, pScreen);
if (pRREvent->mask & RRCrtcChangeNotifyMask)
{
for (i = 0; i < pScrPriv->numCrtcs; i++)
{
if (pRREvent->mask & RRCrtcChangeNotifyMask) {
for (i = 0; i < pScrPriv->numCrtcs; i++) {
RRCrtcPtr crtc = pScrPriv->crtcs[i];
if (crtc->changed)
RRDeliverCrtcEvent (client, pWin, crtc);
RRDeliverCrtcEvent(client, pWin, crtc);
}
}
if (pRREvent->mask & RROutputChangeNotifyMask)
{
for (i = 0; i < pScrPriv->numOutputs; i++)
{
if (pRREvent->mask & RROutputChangeNotifyMask) {
for (i = 0; i < pScrPriv->numOutputs; i++) {
RROutputPtr output = pScrPriv->outputs[i];
if (output->changed)
RRDeliverOutputEvent (client, pWin, output);
RRDeliverOutputEvent(client, pWin, output);
}
}
}
......@@ -438,30 +432,27 @@ TellChanged (WindowPtr pWin, void * value)
* Something changed; send events and adjust pointer position
*/
void
RRTellChanged (ScreenPtr pScreen)
RRTellChanged(ScreenPtr pScreen)
{
rrScrPriv (pScreen);
rrScrPriv(pScreen);
int i;
if (pScrPriv->changed)
{
UpdateCurrentTime ();
if (pScrPriv->configChanged)
{
if (pScrPriv->changed) {
UpdateCurrentTime();
if (pScrPriv->configChanged) {
pScrPriv->lastConfigTime = currentTime;
pScrPriv->configChanged = FALSE;
}
pScrPriv->changed = FALSE;
WalkTree (pScreen, TellChanged, (void *) pScreen);
WalkTree(pScreen, TellChanged, (void *) 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)
{
if (pScrPriv->layoutChanged) {
pScrPriv->layoutChanged = FALSE;
RRPointerScreenConfigured (pScreen);
RRSendConfigNotify (pScreen);
RRPointerScreenConfigured(pScreen);
RRSendConfigNotify(pScreen);
}
}
}
......@@ -471,17 +462,16 @@ RRTellChanged (ScreenPtr pScreen)
* Used in emulating 1.0 behaviour
*/
RROutputPtr
RRFirstOutput (ScreenPtr pScreen)
RRFirstOutput(ScreenPtr pScreen)
{
rrScrPriv(pScreen);
RROutputPtr output;
int i, j;
for (i = 0; i < pScrPriv->numCrtcs; i++)
{
for (i = 0; i < pScrPriv->numCrtcs; i++) {
RRCrtcPtr crtc = pScrPriv->crtcs[i];
for (j = 0; j < pScrPriv->numOutputs; j++)
{
for (j = 0; j < pScrPriv->numOutputs; j++) {
output = pScrPriv->outputs[j];
if (output->crtc == crtc)
return output;
......@@ -491,20 +481,21 @@ RRFirstOutput (ScreenPtr pScreen)
}
CARD16
RRVerticalRefresh (xRRModeInfo *mode)
RRVerticalRefresh(xRRModeInfo * mode)
{
CARD32 refresh;
CARD32 dots = mode->hTotal * mode->vTotal;
if (!dots)
return 0;
refresh = (mode->dotClock + dots/2) / dots;
refresh = (mode->dotClock + dots / 2) / dots;
if (refresh > 0xffff)
refresh = 0xffff;
return (CARD16) refresh;
}
static int
ProcRRDispatch (ClientPtr client)
ProcRRDispatch(ClientPtr client)
{
REQUEST(xReq);
if (stuff->data >= RRNumberRequests || !ProcRandrVector[stuff->data])
......@@ -513,11 +504,10 @@ ProcRRDispatch (ClientPtr client)
}
static int
SProcRRDispatch (ClientPtr client)
SProcRRDispatch(ClientPtr client)
{
REQUEST(xReq);
if (stuff->data >= RRNumberRequests || !ProcRandrVector[stuff->data])
return BadRequest;
return (*SProcRandrVector[stuff->data]) (client);
}
......@@ -63,6 +63,7 @@ typedef struct {
CARD16 widthInMillimeters B16;
CARD16 heightInMillimeters B16;
} xScreenSizes;
#define sz_xScreenSizes 8
/*
......@@ -76,6 +77,7 @@ typedef struct {
CARD32 majorVersion B32;
CARD32 minorVersion B32;
} xRRQueryVersionReq;
#define sz_xRRQueryVersionReq 12
typedef struct {
......@@ -90,6 +92,7 @@ typedef struct {
CARD32 pad4 B32;
CARD32 pad5 B32;
} xRRQueryVersionReply;
#define sz_xRRQueryVersionReply 32
typedef struct {
......@@ -98,6 +101,7 @@ typedef struct {
CARD16 length B16;
Window window B32;
} xRRGetScreenInfoReq;
#define sz_xRRGetScreenInfoReq 8
/*
......@@ -106,7 +110,6 @@ typedef struct {
* the size information
*/
typedef struct {
BYTE type; /* X_Reply */
BYTE setOfRotations;
......@@ -122,6 +125,7 @@ typedef struct {
CARD16 nrateEnts B16;
CARD16 pad B16;
} xRRGetScreenInfoReply;
#define sz_xRRGetScreenInfoReply 32
typedef struct {
......@@ -134,6 +138,7 @@ typedef struct {
SizeID sizeID B16;
Rotation rotation B16;
} xRR1_0SetScreenConfigReq;
#define sz_xRR1_0SetScreenConfigReq 20
typedef struct {
......@@ -148,6 +153,7 @@ typedef struct {
CARD16 rate B16;
CARD16 pad B16;
} xRRSetScreenConfigReq;
#define sz_xRRSetScreenConfigReq 24
typedef struct {
......@@ -163,6 +169,7 @@ typedef struct {
CARD32 pad5 B32;
CARD32 pad6 B32;
} xRRSetScreenConfigReply;
#define sz_xRRSetScreenConfigReply 32
typedef struct {
......@@ -173,6 +180,7 @@ typedef struct {
CARD16 enable B16;
CARD16 pad2 B16;
} xRRSelectInputReq;
#define sz_xRRSelectInputReq 12
/*
......@@ -194,6 +202,7 @@ typedef struct _xRRModeInfo {
CARD16 nameLength B16;
RRModeFlags modeFlags B32;
} xRRModeInfo;
#define sz_xRRModeInfo 32
typedef struct {
......@@ -202,6 +211,7 @@ typedef struct {
CARD16 length B16;
Window window B32;
} xRRGetScreenSizeRangeReq;
#define sz_xRRGetScreenSizeRangeReq 8
typedef struct {
......@@ -218,6 +228,7 @@ typedef struct {
CARD32 pad2 B32;
CARD32 pad3 B32;
} xRRGetScreenSizeRangeReply;
#define sz_xRRGetScreenSizeRangeReply 32
typedef struct {
......@@ -230,6 +241,7 @@ typedef struct {
CARD32 widthInMillimeters B32;
CARD32 heightInMillimeters B32;
} xRRSetScreenSizeReq;
#define sz_xRRSetScreenSizeReq 20
typedef struct {
......@@ -238,6 +250,7 @@ typedef struct {
CARD16 length B16;
Window window B32;
} xRRGetScreenResourcesReq;
#define sz_xRRGetScreenResourcesReq 8
typedef struct {
......@@ -254,6 +267,7 @@ typedef struct {
CARD32 pad1 B32;
CARD32 pad2 B32;
} xRRGetScreenResourcesReply;
#define sz_xRRGetScreenResourcesReply 32
typedef struct {
......@@ -263,6 +277,7 @@ typedef struct {
RROutput output B32;
Time configTimestamp B32;
} xRRGetOutputInfoReq;
#define sz_xRRGetOutputInfoReq 12
typedef struct {
......@@ -282,6 +297,7 @@ typedef struct {
CARD16 nClones B16;
CARD16 nameLength B16;
} xRRGetOutputInfoReply;
#define sz_xRRGetOutputInfoReply 36
typedef struct {
......@@ -290,6 +306,7 @@ typedef struct {
CARD16 length B16;
RROutput output B32;
} xRRListOutputPropertiesReq;
#define sz_xRRListOutputPropertiesReq 8
typedef struct {
......@@ -305,6 +322,7 @@ typedef struct {
CARD32 pad5 B32;
CARD32 pad6 B32;
} xRRListOutputPropertiesReply;
#define sz_xRRListOutputPropertiesReply 32
typedef struct {
......@@ -314,6 +332,7 @@ typedef struct {
RROutput output B32;
Atom property B32;
} xRRQueryOutputPropertyReq;
#define sz_xRRQueryOutputPropertyReq 12
typedef struct {
......@@ -331,6 +350,7 @@ typedef struct {
CARD32 pad5 B32;
CARD32 pad6 B32;
} xRRQueryOutputPropertyReply;
#define sz_xRRQueryOutputPropertyReply 32
typedef struct {
......@@ -343,6 +363,7 @@ typedef struct {
BOOL range;
CARD16 pad B16;
} xRRConfigureOutputPropertyReq;
#define sz_xRRConfigureOutputPropertyReq 16
typedef struct {
......@@ -357,6 +378,7 @@ typedef struct {
CARD16 pad;
CARD32 nUnits B32;
} xRRChangeOutputPropertyReq;
#define sz_xRRChangeOutputPropertyReq 24
typedef struct {
......@@ -366,6 +388,7 @@ typedef struct {
RROutput output B32;
Atom property B32;
} xRRDeleteOutputPropertyReq;
#define sz_xRRDeleteOutputPropertyReq 12
typedef struct {
......@@ -385,6 +408,7 @@ typedef struct {
BOOL pending;
CARD16 pad1 B16;
} xRRGetOutputPropertyReq;
#define sz_xRRGetOutputPropertyReq 28
typedef struct {
......@@ -399,6 +423,7 @@ typedef struct {
CARD32 pad2 B32;
CARD32 pad3 B32;
} xRRGetOutputPropertyReply;
#define sz_xRRGetOutputPropertyReply 32
typedef struct {
......@@ -408,6 +433,7 @@ typedef struct {
Window window B32;
xRRModeInfo modeInfo;
} xRRCreateModeReq;
#define sz_xRRCreateModeReq 40
typedef struct {
......@@ -422,6 +448,7 @@ typedef struct {
CARD32 pad4 B32;
CARD32 pad5 B32;
} xRRCreateModeReply;
#define sz_xRRCreateModeReply 32
typedef struct {
......@@ -430,6 +457,7 @@ typedef struct {
CARD16 length B16;
RRMode mode B32;
} xRRDestroyModeReq;
#define sz_xRRDestroyModeReq 8
typedef struct {
......@@ -439,6 +467,7 @@ typedef struct {
RROutput output B32;
RRMode mode B32;
} xRRAddOutputModeReq;
#define sz_xRRAddOutputModeReq 12
typedef struct {
......@@ -448,6 +477,7 @@ typedef struct {
RROutput output B32;
RRMode mode B32;
} xRRDeleteOutputModeReq;
#define sz_xRRDeleteOutputModeReq 12
typedef struct {
......@@ -457,6 +487,7 @@ typedef struct {
RRCrtc crtc B32;
Time configTimestamp B32;
} xRRGetCrtcInfoReq;
#define sz_xRRGetCrtcInfoReq 12
typedef struct {
......@@ -475,6 +506,7 @@ typedef struct {
CARD16 nOutput B16;
CARD16 nPossibleOutput B16;
} xRRGetCrtcInfoReply;
#define sz_xRRGetCrtcInfoReply 32
typedef struct {
......@@ -490,6 +522,7 @@ typedef struct {
Rotation rotation B16;
CARD16 pad B16;
} xRRSetCrtcConfigReq;
#define sz_xRRSetCrtcConfigReq 28
typedef struct {
......@@ -504,6 +537,7 @@ typedef struct {
CARD32 pad4 B32;
CARD32 pad5 B32;
} xRRSetCrtcConfigReply;
#define sz_xRRSetCrtcConfigReply 32
typedef struct {
......@@ -512,6 +546,7 @@ typedef struct {
CARD16 length B16;
RRCrtc crtc B32;
} xRRGetCrtcGammaSizeReq;
#define sz_xRRGetCrtcGammaSizeReq 8
typedef struct {
......@@ -527,6 +562,7 @@ typedef struct {
CARD32 pad5 B32;
CARD32 pad6 B32;
} xRRGetCrtcGammaSizeReply;
#define sz_xRRGetCrtcGammaSizeReply 32
typedef struct {
......@@ -535,6 +571,7 @@ typedef struct {
CARD16 length B16;
RRCrtc crtc B32;
} xRRGetCrtcGammaReq;
#define sz_xRRGetCrtcGammaReq 8
typedef struct {
......@@ -550,6 +587,7 @@ typedef struct {
CARD32 pad5 B32;
CARD32 pad6 B32;
} xRRGetCrtcGammaReply;
#define sz_xRRGetCrtcGammaReply 32
typedef struct {
......@@ -560,6 +598,7 @@ typedef struct {
CARD16 size B16;
CARD16 pad1 B16;
} xRRSetCrtcGammaReq;
#define sz_xRRSetCrtcGammaReq 12
/*
......@@ -580,6 +619,7 @@ typedef struct {
CARD16 widthInMillimeters B16;
CARD16 heightInMillimeters B16;
} xRRScreenChangeNotifyEvent;
#define sz_xRRScreenChangeNotifyEvent 32
typedef struct {
......@@ -597,6 +637,7 @@ typedef struct {
CARD16 width B16; /* new size */
CARD16 height B16;
} xRRCrtcChangeNotifyEvent;
#define sz_xRRCrtcChangeNotifyEvent 32
typedef struct {
......@@ -613,6 +654,7 @@ typedef struct {
CARD8 connection; /* connection status */
CARD8 subpixelOrder; /* subpixel order */
} xRROutputChangeNotifyEvent;
#define sz_xRROutputChangeNotifyEvent 32
typedef struct {
......@@ -629,6 +671,7 @@ typedef struct {
CARD32 pad3 B32;
CARD32 pad4 B32;
} xRROutputPropertyNotifyEvent;
#define sz_xRROutputPropertyNotifyEvent 32
#undef RRModeFlags
......
......@@ -66,8 +66,8 @@ typedef XID RRCrtc;
extern int RREventBase, RRErrorBase;
extern int (*ProcRandrVector[RRNumberRequests])(ClientPtr);
extern int (*SProcRandrVector[RRNumberRequests])(ClientPtr);
extern int (*ProcRandrVector[RRNumberRequests]) (ClientPtr);
extern int (*SProcRandrVector[RRNumberRequests]) (ClientPtr);
/*
* Modeline for a monitor. Name follows directly after this struct
......@@ -151,8 +151,7 @@ struct _rrOutput {
typedef Bool (*RRScreenSetSizeProcPtr) (ScreenPtr pScreen,
CARD16 width,
CARD16 height,
CARD32 mmWidth,
CARD32 mmHeight);
CARD32 mmWidth, CARD32 mmHeight);
typedef Bool (*RRCrtcSetProcPtr) (ScreenPtr pScreen,
RRCrtcPtr crtc,
......@@ -160,11 +159,9 @@ typedef Bool (*RRCrtcSetProcPtr) (ScreenPtr pScreen,
int x,
int y,
Rotation rotation,
int numOutputs,
RROutputPtr *outputs);
int numOutputs, RROutputPtr * outputs);
typedef Bool (*RRCrtcSetGammaProcPtr) (ScreenPtr pScreen,
RRCrtcPtr crtc);
typedef Bool (*RRCrtcSetGammaProcPtr) (ScreenPtr pScreen, RRCrtcPtr crtc);
typedef Bool (*RROutputSetPropertyProcPtr) (ScreenPtr pScreen,
RROutputPtr output,
......@@ -175,13 +172,12 @@ typedef Bool (*RROutputValidateModeProcPtr) (ScreenPtr pScreen,
RROutputPtr output,
RRModePtr mode);
typedef void (*RRModeDestroyProcPtr) (ScreenPtr pScreen,
RRModePtr mode);
typedef void (*RRModeDestroyProcPtr) (ScreenPtr pScreen, RRModePtr mode);
#endif
typedef Bool (*RRGetInfoProcPtr) (ScreenPtr pScreen, Rotation *rotations);
typedef Bool (*RRCloseScreenProcPtr) ( int i, ScreenPtr pscreen);
typedef Bool (*RRGetInfoProcPtr) (ScreenPtr pScreen, Rotation * rotations);
typedef Bool (*RRCloseScreenProcPtr) (int i, ScreenPtr pscreen);
/* These are for 1.0 compatibility */
......@@ -202,12 +198,10 @@ typedef struct _rrScreenSize {
typedef Bool (*RRSetConfigProcPtr) (ScreenPtr pScreen,
Rotation rotation,
int rate,
RRScreenSizePtr pSize);
int rate, RRScreenSizePtr pSize);
#endif
typedef struct _rrScrPriv {
/*
* 'public' part of the structure; DDXen fill this in
......@@ -317,6 +311,7 @@ typedef struct _RRClient {
} RRClientRec, *RRClientPtr;
extern RESTYPE RRClientType, RREventType; /* resource types for event masks */
#ifndef NXAGENT_SERVER
extern DevPrivateKey RRClientPrivateKey;
#else
......@@ -352,18 +347,17 @@ extern RESTYPE RRCrtcType, RRModeType, RROutputType;
/* Initialize the extension */
void
RRExtensionInit (void);
RRExtensionInit(void);
#ifdef RANDR_12_INTERFACE
/*
* Set the range of sizes for the screen
*/
void
RRScreenSetSizeRange (ScreenPtr pScreen,
RRScreenSetSizeRange(ScreenPtr pScreen,
CARD16 minWidth,
CARD16 minHeight,
CARD16 maxWidth,
CARD16 maxHeight);
CARD16 minHeight, CARD16 maxWidth, CARD16 maxHeight);
#endif
/* rrscreen.c */
......@@ -373,108 +367,99 @@ RRScreenSetSizeRange (ScreenPtr pScreen,
* the size of the screen
*/
void
RRScreenSizeNotify (ScreenPtr pScreen);
RRScreenSizeNotify(ScreenPtr 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);
/*
* Send ConfigureNotify event to root window when 'something' happens
*/
void
RRSendConfigNotify (ScreenPtr pScreen);
RRSendConfigNotify(ScreenPtr pScreen);
/*
* screen dispatch
*/
int
ProcRRGetScreenSizeRange (ClientPtr client);
ProcRRGetScreenSizeRange(ClientPtr client);
int
ProcRRSetScreenSize (ClientPtr client);
ProcRRSetScreenSize(ClientPtr client);
int
ProcRRGetScreenResources (ClientPtr client);
ProcRRGetScreenResources(ClientPtr client);
int
ProcRRSetScreenConfig (ClientPtr client);
ProcRRSetScreenConfig(ClientPtr client);
int
ProcRRGetScreenInfo (ClientPtr client);
ProcRRGetScreenInfo(ClientPtr client);
/*
* Deliver a ScreenNotify event
*/
void
RRDeliverScreenEvent (ClientPtr client, WindowPtr pWin, ScreenPtr pScreen);
RRDeliverScreenEvent(ClientPtr client, WindowPtr pWin, ScreenPtr pScreen);
/* mirandr.c */
Bool
miRandRInit (ScreenPtr pScreen);
miRandRInit(ScreenPtr pScreen);
Bool
miRRGetInfo (ScreenPtr pScreen, Rotation *rotations);
miRRGetInfo(ScreenPtr pScreen, Rotation * rotations);
Bool
miRRGetScreenInfo (ScreenPtr pScreen);
miRRGetScreenInfo(ScreenPtr pScreen);
Bool
miRRCrtcSet (ScreenPtr pScreen,
miRRCrtcSet(ScreenPtr pScreen,
RRCrtcPtr crtc,
RRModePtr mode,
int x,
int y,
Rotation rotation,
int numOutput,
RROutputPtr *outputs);
int y, Rotation rotation, int numOutput, RROutputPtr * outputs);
Bool
miRROutputSetProperty (ScreenPtr pScreen,
miRROutputSetProperty(ScreenPtr pScreen,
RROutputPtr output,
Atom property,
RRPropertyValuePtr value);
Atom property, RRPropertyValuePtr value);
Bool
miRROutputValidateMode (ScreenPtr pScreen,
RROutputPtr output,
RRModePtr mode);
miRROutputValidateMode(ScreenPtr pScreen, RROutputPtr output, RRModePtr mode);
void
miRRModeDestroy (ScreenPtr pScreen,
RRModePtr mode);
miRRModeDestroy(ScreenPtr pScreen, RRModePtr mode);
/* randr.c */
/*
* Send all pending events
*/
void
RRTellChanged (ScreenPtr pScreen);
RRTellChanged(ScreenPtr pScreen);
/*
* Poll the driver for changed information
*/
Bool
RRGetInfo (ScreenPtr pScreen);
RRGetInfo(ScreenPtr pScreen);
Bool RRInit (void);
Bool RRInit(void);
Bool RRScreenInit(ScreenPtr pScreen);
RROutputPtr
RRFirstOutput (ScreenPtr pScreen);
RROutputPtr RRFirstOutput(ScreenPtr pScreen);
Rotation
RRGetRotation (ScreenPtr pScreen);
Rotation RRGetRotation(ScreenPtr pScreen);
CARD16
RRVerticalRefresh (xRRModeInfo *mode);
RRVerticalRefresh(xRRModeInfo * mode);
#ifdef RANDR_10_INTERFACE
/*
......@@ -487,36 +472,28 @@ RRVerticalRefresh (xRRModeInfo *mode);
*/
RRScreenSizePtr
RRRegisterSize (ScreenPtr pScreen,
short width,
short height,
short mmWidth,
short mmHeight);
RRRegisterSize(ScreenPtr pScreen,
short width, short height, short mmWidth, short mmHeight);
Bool RRRegisterRate (ScreenPtr pScreen,
RRScreenSizePtr pSize,
int rate);
Bool RRRegisterRate(ScreenPtr pScreen, RRScreenSizePtr pSize, int rate);
/*
* Finally, set the current configuration of the screen
*/
void
RRSetCurrentConfig (ScreenPtr pScreen,
Rotation rotation,
int rate,
RRScreenSizePtr pSize);
Bool RRScreenInit (ScreenPtr pScreen);
RRSetCurrentConfig(ScreenPtr pScreen,
Rotation rotation, int rate, RRScreenSizePtr pSize);
Bool RRScreenInit(ScreenPtr pScreen);
Rotation
RRGetRotation (ScreenPtr pScreen);
Rotation RRGetRotation(ScreenPtr pScreen);
int
RRSetScreenConfig (ScreenPtr pScreen,
Rotation rotation,
int rate,
RRScreenSizePtr pSize);
RRSetScreenConfig(ScreenPtr pScreen,
Rotation rotation, int rate, RRScreenSizePtr pSize);
#endif
......@@ -527,57 +504,49 @@ RRSetScreenConfig (ScreenPtr pScreen,
* some position or size element changed
*/
void
RRCrtcChanged (RRCrtcPtr crtc, Bool layoutChanged);
RRCrtcChanged(RRCrtcPtr crtc, Bool layoutChanged);
/*
* Create a CRTC
*/
RRCrtcPtr
RRCrtcCreate (ScreenPtr pScreen, void *devPrivate);
RRCrtcPtr RRCrtcCreate(ScreenPtr pScreen, void *devPrivate);
/*
* Set the allowed rotations on a CRTC
*/
void
RRCrtcSetRotations (RRCrtcPtr crtc, Rotation rotations);
RRCrtcSetRotations(RRCrtcPtr crtc, Rotation rotations);
/*
* Notify the extension that the Crtc has been reconfigured,
* the driver calls this whenever it has updated the mode
*/
Bool
RRCrtcNotify (RRCrtcPtr crtc,
RRCrtcNotify(RRCrtcPtr crtc,
RRModePtr mode,
int x,
int y,
Rotation rotation,
int numOutputs,
RROutputPtr *outputs);
int y, Rotation rotation, int numOutputs, RROutputPtr * outputs);
void
RRDeliverCrtcEvent (ClientPtr client, WindowPtr pWin, RRCrtcPtr crtc);
RRDeliverCrtcEvent(ClientPtr client, WindowPtr pWin, RRCrtcPtr crtc);
/*
* Request that the Crtc be reconfigured
*/
Bool
RRCrtcSet (RRCrtcPtr crtc,
RRCrtcSet(RRCrtcPtr crtc,
RRModePtr mode,
int x,
int y,
Rotation rotation,
int numOutput,
RROutputPtr *outputs);
int y, Rotation rotation, int numOutput, RROutputPtr * outputs);
/*
* Request that the Crtc gamma be changed
*/
Bool
RRCrtcGammaSet (RRCrtcPtr crtc,
CARD16 *red,
CARD16 *green,
CARD16 *blue);
RRCrtcGammaSet(RRCrtcPtr crtc, CARD16 *red, CARD16 *green, CARD16 *blue);
/*
* Notify the extension that the Crtc gamma has been changed
......@@ -586,15 +555,14 @@ RRCrtcGammaSet (RRCrtcPtr crtc,
*/
Bool
RRCrtcGammaNotify (RRCrtcPtr crtc);
RRCrtcGammaNotify(RRCrtcPtr crtc);
/*
* Set the size of the gamma table at server startup time
*/
Bool
RRCrtcGammaSetSize (RRCrtcPtr crtc,
int size);
RRCrtcGammaSetSize(RRCrtcPtr crtc, int size);
/*
* Return the area of the frame buffer scanned out by the crtc,
......@@ -602,85 +570,82 @@ RRCrtcGammaSetSize (RRCrtcPtr crtc,
*/
void
RRCrtcGetScanoutSize(RRCrtcPtr crtc, int *width, int *height);
RRCrtcGetScanoutSize(RRCrtcPtr crtc, int *width, int *height);
/*
* Destroy a Crtc at shutdown
*/
void
RRCrtcDestroy (RRCrtcPtr crtc);
RRCrtcDestroy(RRCrtcPtr crtc);
/*
* Initialize crtc type
*/
Bool
RRCrtcInit (void);
RRCrtcInit(void);
/*
* Crtc dispatch
*/
int
ProcRRGetCrtcInfo (ClientPtr client);
ProcRRGetCrtcInfo(ClientPtr client);
int
ProcRRSetCrtcConfig (ClientPtr client);
ProcRRSetCrtcConfig(ClientPtr client);
int
ProcRRGetCrtcGammaSize (ClientPtr client);
ProcRRGetCrtcGammaSize(ClientPtr client);
int
ProcRRGetCrtcGamma (ClientPtr client);
ProcRRGetCrtcGamma(ClientPtr client);
int
ProcRRSetCrtcGamma (ClientPtr client);
ProcRRSetCrtcGamma(ClientPtr client);
/* rrdispatch.c */
Bool
RRClientKnowsRates (ClientPtr pClient);
RRClientKnowsRates(ClientPtr pClient);
/* rrmode.c */
/*
* Find, and if necessary, create a mode
*/
RRModePtr
RRModeGet (xRRModeInfo *modeInfo,
const char *name);
RRModePtr RRModeGet(xRRModeInfo * modeInfo, const char *name);
void
RRModePruneUnused (ScreenPtr pScreen);
RRModePruneUnused(ScreenPtr pScreen);
/*
* Destroy a mode.
*/
void
RRModeDestroy (RRModePtr mode);
RRModeDestroy(RRModePtr mode);
/*
* Return a list of modes that are valid for some output in pScreen
*/
RRModePtr *
RRModesForScreen (ScreenPtr pScreen, int *num_ret);
RRModePtr *RRModesForScreen(ScreenPtr pScreen, int *num_ret);
/*
* Initialize mode type
*/
Bool
RRModeInit (void);
RRModeInit(void);
int
ProcRRCreateMode (ClientPtr client);
ProcRRCreateMode(ClientPtr client);
int
ProcRRDestroyMode (ClientPtr client);
ProcRRDestroyMode(ClientPtr client);
int
ProcRRAddOutputMode (ClientPtr client);
ProcRRAddOutputMode(ClientPtr client);
int
ProcRRDeleteOutputMode (ClientPtr client);
ProcRRDeleteOutputMode(ClientPtr client);
/* rroutput.c */
......@@ -691,127 +656,115 @@ ProcRRDeleteOutputMode (ClientPtr client);
* (which crtc is in use)
*/
void
RROutputChanged (RROutputPtr output, Bool configChanged);
RROutputChanged(RROutputPtr output, Bool configChanged);
/*
* Create an output
*/
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
*/
Bool
RROutputSetClones (RROutputPtr output,
RROutputPtr *clones,
int numClones);
RROutputSetClones(RROutputPtr output, RROutputPtr * clones, int numClones);
Bool
RROutputSetModes (RROutputPtr output,
RRModePtr *modes,
int numModes,
int numPreferred);
RROutputSetModes(RROutputPtr output,
RRModePtr * modes, int numModes, int numPreferred);
int
RROutputAddUserMode (RROutputPtr output,
RRModePtr mode);
RROutputAddUserMode(RROutputPtr output, RRModePtr mode);
int
RROutputDeleteUserMode (RROutputPtr output,
RRModePtr mode);
RROutputDeleteUserMode(RROutputPtr output, RRModePtr mode);
Bool
RROutputSetCrtcs (RROutputPtr output,
RRCrtcPtr *crtcs,
int numCrtcs);
RROutputSetCrtcs(RROutputPtr output, RRCrtcPtr * crtcs, int numCrtcs);
Bool
RROutputSetConnection (RROutputPtr output,
CARD8 connection);
RROutputSetConnection(RROutputPtr output, CARD8 connection);
Bool
RROutputSetSubpixelOrder (RROutputPtr output,
int subpixelOrder);
RROutputSetSubpixelOrder(RROutputPtr output, int subpixelOrder);
Bool
RROutputSetPhysicalSize (RROutputPtr output,
int mmWidth,
int mmHeight);
RROutputSetPhysicalSize(RROutputPtr output, int mmWidth, int mmHeight);
void
RRDeliverOutputEvent(ClientPtr client, WindowPtr pWin, RROutputPtr output);
RRDeliverOutputEvent(ClientPtr client, WindowPtr pWin, RROutputPtr output);
void
RROutputDestroy (RROutputPtr output);
RROutputDestroy(RROutputPtr output);
int
ProcRRGetOutputInfo (ClientPtr client);
ProcRRGetOutputInfo(ClientPtr client);
/*
* Initialize output type
*/
Bool
RROutputInit (void);
RROutputInit(void);
/* rrpointer.c */
void
RRPointerMoved (ScreenPtr pScreen, int x, int y);
RRPointerMoved(ScreenPtr pScreen, int x, int y);
void
RRPointerScreenConfigured (ScreenPtr pScreen);
RRPointerScreenConfigured(ScreenPtr pScreen);
/* rrproperty.c */
void
RRDeleteAllOutputProperties (RROutputPtr output);
RRDeleteAllOutputProperties(RROutputPtr output);
RRPropertyValuePtr
RRGetOutputProperty (RROutputPtr output, Atom property, Bool pending);
RRGetOutputProperty(RROutputPtr output, Atom property, Bool pending);
RRPropertyPtr
RRQueryOutputProperty (RROutputPtr output, Atom property);
RRPropertyPtr RRQueryOutputProperty(RROutputPtr output, Atom property);
void
RRDeleteOutputProperty (RROutputPtr output, Atom property);
RRDeleteOutputProperty(RROutputPtr output, Atom property);
Bool
RRPostPendingProperties (RROutputPtr output);
RRPostPendingProperties(RROutputPtr output);
int
RRChangeOutputProperty (RROutputPtr output, Atom property, Atom type,
RRChangeOutputProperty(RROutputPtr output, Atom property, Atom type,
int format, int mode, unsigned long len,
void * value, Bool sendevent, Bool pending);
void *value, Bool sendevent, Bool pending);
int
RRConfigureOutputProperty (RROutputPtr output, Atom property,
RRConfigureOutputProperty(RROutputPtr output, Atom property,
Bool pending, Bool range, Bool immutable,
int num_values, INT32 *values);
int
ProcRRChangeOutputProperty (ClientPtr client);
ProcRRChangeOutputProperty(ClientPtr client);
int
ProcRRGetOutputProperty (ClientPtr client);
ProcRRGetOutputProperty(ClientPtr client);
int
ProcRRListOutputProperties (ClientPtr client);
ProcRRListOutputProperties(ClientPtr client);
int
ProcRRQueryOutputProperty (ClientPtr client);
ProcRRQueryOutputProperty(ClientPtr client);
int
ProcRRConfigureOutputProperty (ClientPtr client);
ProcRRConfigureOutputProperty(ClientPtr client);
int
ProcRRDeleteOutputProperty (ClientPtr client);
ProcRRDeleteOutputProperty(ClientPtr client);
/* rrxinerama.c */
void
RRXineramaExtensionInit(void);
RRXineramaExtensionInit(void);
#endif /* _RANDRSTR_H_ */
......
......@@ -29,7 +29,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* not be a stack variable.
*/
void RegisterResourceName(RESTYPE type, char *name);
void RegisterExtensionNames(ExtensionEntry *ext);
void RegisterExtensionNames(ExtensionEntry * ext);
/*
* Lookup functions. The returned string must not be modified or freed.
......
......@@ -47,13 +47,12 @@ RESTYPE RRCrtcType;
* Notify the CRTC of some change
*/
void
RRCrtcChanged (RRCrtcPtr crtc, Bool layoutChanged)
RRCrtcChanged(RRCrtcPtr crtc, Bool layoutChanged)
{
ScreenPtr pScreen = crtc->pScreen;
crtc->changed = TRUE;
if (pScreen)
{
if (pScreen) {
rrScrPriv(pScreen);
pScrPriv->changed = TRUE;
......@@ -69,7 +68,7 @@ RRCrtcChanged (RRCrtcPtr crtc, Bool layoutChanged)
* Create a CRTC
*/
RRCrtcPtr
RRCrtcCreate (ScreenPtr pScreen, void *devPrivate)
RRCrtcCreate(ScreenPtr pScreen, void *devPrivate)
{
RRCrtcPtr crtc;
RRCrtcPtr *crtcs;
......@@ -82,18 +81,18 @@ RRCrtcCreate (ScreenPtr pScreen, void *devPrivate)
/* make space for the crtc pointer */
if (pScrPriv->numCrtcs)
crtcs = xrealloc (pScrPriv->crtcs,
(pScrPriv->numCrtcs + 1) * sizeof (RRCrtcPtr));
crtcs = xrealloc(pScrPriv->crtcs,
(pScrPriv->numCrtcs + 1) * sizeof(RRCrtcPtr));
else
crtcs = xalloc (sizeof (RRCrtcPtr));
crtcs = xalloc(sizeof(RRCrtcPtr));
if (!crtcs)
return FALSE;
pScrPriv->crtcs = crtcs;
crtc = xcalloc (1, sizeof (RRCrtcRec));
crtc = xcalloc(1, sizeof(RRCrtcRec));
if (!crtc)
return NULL;
crtc->id = FakeClientID (0);
crtc->id = FakeClientID(0);
crtc->pScreen = pScreen;
crtc->mode = NULL;
crtc->x = 0;
......@@ -107,7 +106,7 @@ RRCrtcCreate (ScreenPtr pScreen, void *devPrivate)
crtc->changed = FALSE;
crtc->devPrivate = devPrivate;
if (!AddResource (crtc->id, RRCrtcType, (void *) crtc))
if (!AddResource(crtc->id, RRCrtcType, (void *) crtc))
return NULL;
/* attach the screen and crtc together */
......@@ -121,7 +120,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;
}
......@@ -131,13 +130,10 @@ RRCrtcSetRotations (RRCrtcPtr crtc, Rotation rotations)
* the driver calls this whenever it has updated the mode
*/
Bool
RRCrtcNotify (RRCrtcPtr crtc,
RRCrtcNotify(RRCrtcPtr crtc,
RRModePtr mode,
int x,
int y,
Rotation rotation,
int numOutputs,
RROutputPtr *outputs)
int y, Rotation rotation, int numOutputs, RROutputPtr * outputs)
{
int i, j;
......@@ -145,56 +141,49 @@ RRCrtcNotify (RRCrtcPtr crtc,
* 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 (i = 0; i < numOutputs; i++) {
for (j = 0; j < crtc->numOutputs; j++)
if (outputs[i] == crtc->outputs[j])
break;
if (j == crtc->numOutputs)
{
if (j == crtc->numOutputs) {
outputs[i]->crtc = crtc;
RROutputChanged (outputs[i], FALSE);
RRCrtcChanged (crtc, FALSE);
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 (j = 0; j < crtc->numOutputs; j++) {
for (i = 0; i < numOutputs; i++)
if (outputs[i] == crtc->outputs[j])
break;
if (i == numOutputs)
{
if (i == numOutputs) {
if (crtc->outputs[j]->crtc == crtc)
crtc->outputs[j]->crtc = NULL;
RROutputChanged (crtc->outputs[j], FALSE);
RRCrtcChanged (crtc, FALSE);
RROutputChanged(crtc->outputs[j], FALSE);
RRCrtcChanged(crtc, FALSE);
}
}
/*
* Reallocate the crtc output array if necessary
*/
if (numOutputs != crtc->numOutputs)
{
if (numOutputs != crtc->numOutputs) {
RROutputPtr *newoutputs;
if (numOutputs)
{
if (numOutputs) {
if (crtc->numOutputs)
newoutputs = xrealloc (crtc->outputs,
numOutputs * sizeof (RROutputPtr));
newoutputs = xrealloc(crtc->outputs,
numOutputs * sizeof(RROutputPtr));
else
newoutputs = xalloc (numOutputs * sizeof (RROutputPtr));
newoutputs = xalloc(numOutputs * sizeof(RROutputPtr));
if (!newoutputs)
return FALSE;
}
else
{
else {
if (crtc->outputs)
xfree (crtc->outputs);
xfree(crtc->outputs);
newoutputs = NULL;
}
crtc->outputs = newoutputs;
......@@ -203,42 +192,39 @@ RRCrtcNotify (RRCrtcPtr crtc,
/*
* 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 (mode != crtc->mode) {
if (crtc->mode)
RRModeDestroy (crtc->mode);
RRModeDestroy(crtc->mode);
crtc->mode = mode;
if (mode != NULL)
mode->refcnt++;
RRCrtcChanged (crtc, TRUE);
RRCrtcChanged(crtc, TRUE);
}
if (x != crtc->x)
{
if (x != crtc->x) {
crtc->x = x;
RRCrtcChanged (crtc, TRUE);
RRCrtcChanged(crtc, TRUE);
}
if (y != crtc->y)
{
if (y != crtc->y) {
crtc->y = y;
RRCrtcChanged (crtc, TRUE);
RRCrtcChanged(crtc, TRUE);
}
if (rotation != crtc->rotation)
{
if (rotation != crtc->rotation) {
crtc->rotation = rotation;
RRCrtcChanged (crtc, TRUE);
RRCrtcChanged(crtc, TRUE);
}
return TRUE;
}
void
RRDeliverCrtcEvent (ClientPtr client, WindowPtr pWin, RRCrtcPtr crtc)
RRDeliverCrtcEvent(ClientPtr client, WindowPtr pWin, RRCrtcPtr crtc)
{
ScreenPtr pScreen = pWin->drawable.pScreen;
rrScrPriv (pScreen);
rrScrPriv(pScreen);
xRRCrtcChangeNotifyEvent ce;
RRModePtr mode = crtc->mode;
......@@ -249,35 +235,34 @@ RRDeliverCrtcEvent (ClientPtr client, WindowPtr pWin, RRCrtcPtr crtc)
ce.window = pWin->drawable.id;
ce.crtc = crtc->id;
ce.rotation = crtc->rotation;
if (mode)
{
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
{
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;
rrScrPriv(pScreen);
int o;
for (o = 0; o < pScrPriv->numOutputs; o++)
{
for (o = 0; o < pScrPriv->numOutputs; o++) {
RROutputPtr output = pScrPriv->outputs[o];
if (output->crtc == crtc && output->pendingProperties)
return TRUE;
}
......@@ -288,16 +273,14 @@ RRCrtcPendingProperties (RRCrtcPtr crtc)
* Request that the Crtc be reconfigured
*/
Bool
RRCrtcSet (RRCrtcPtr crtc,
RRCrtcSet(RRCrtcPtr crtc,
RRModePtr mode,
int x,
int y,
Rotation rotation,
int numOutputs,
RROutputPtr *outputs)
int y, Rotation rotation, int numOutputs, RROutputPtr * outputs)
{
ScreenPtr pScreen = crtc->pScreen;
Bool ret = FALSE;
rrScrPriv(pScreen);
/* See if nothing changed */
......@@ -306,16 +289,13 @@ RRCrtcSet (RRCrtcPtr crtc,
crtc->y == y &&
crtc->rotation == rotation &&
crtc->numOutputs == numOutputs &&
!memcmp (crtc->outputs, outputs, numOutputs * sizeof (RROutputPtr)) &&
!RRCrtcPendingProperties (crtc))
{
!memcmp(crtc->outputs, outputs, numOutputs * sizeof(RROutputPtr)) &&
!RRCrtcPendingProperties(crtc)) {
ret = TRUE;
}
else
{
else {
#if RANDR_12_INTERFACE
if (pScrPriv->rrCrtcSet)
{
if (pScrPriv->rrCrtcSet) {
ret = (*pScrPriv->rrCrtcSet) (pScreen, crtc, mode, x, y,
rotation, numOutputs, outputs);
}
......@@ -323,53 +303,49 @@ RRCrtcSet (RRCrtcPtr crtc,
#endif
{
#if RANDR_10_INTERFACE
if (pScrPriv->rrSetConfig)
{
if (pScrPriv->rrSetConfig) {
RRScreenSize size;
RRScreenRate rate;
if (!mode)
{
RRCrtcNotify (crtc, NULL, x, y, rotation, 0, NULL);
if (!mode) {
RRCrtcNotify(crtc, NULL, x, y, rotation, 0, NULL);
ret = TRUE;
}
else
{
else {
size.width = mode->mode.width;
size.height = mode->mode.height;
if (outputs[0]->mmWidth && outputs[0]->mmHeight)
{
if (outputs[0]->mmWidth && outputs[0]->mmHeight) {
size.mmWidth = outputs[0]->mmWidth;
size.mmHeight = outputs[0]->mmHeight;
}
else
{
else {
size.mmWidth = pScreen->mmWidth;
size.mmHeight = pScreen->mmHeight;
}
size.nRates = 1;
rate.rate = RRVerticalRefresh (&mode->mode);
rate.rate = RRVerticalRefresh(&mode->mode);
size.pRates = &rate;
ret = (*pScrPriv->rrSetConfig) (pScreen, rotation, rate.rate, &size);
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, 1, outputs);
RRScreenSizeNotify (pScreen);
if (ret) {
RRCrtcNotify(crtc, mode, x, y, rotation, 1, outputs);
RRScreenSizeNotify(pScreen);
}
}
}
#endif
}
if (ret)
{
if (ret) {
int o;
RRTellChanged (pScreen);
RRTellChanged(pScreen);
for (o = 0; o < numOutputs; o++)
RRPostPendingProperties (outputs[o]);
RRPostPendingProperties(outputs[o]);
}
}
return ret;
......@@ -379,38 +355,35 @@ RRCrtcSet (RRCrtcPtr crtc,
* Destroy a Crtc at shutdown
*/
void
RRCrtcDestroy (RRCrtcPtr crtc)
RRCrtcDestroy(RRCrtcPtr crtc)
{
FreeResource (crtc->id, 0);
FreeResource(crtc->id, 0);
}
static int
RRCrtcDestroyResource (void * value, XID pid)
RRCrtcDestroyResource(void *value, XID pid)
{
RRCrtcPtr crtc = (RRCrtcPtr) value;
ScreenPtr pScreen = crtc->pScreen;
if (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));
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 (crtc->gammaRed)
xfree (crtc->gammaRed);
xfree(crtc->gammaRed);
if (crtc->mode)
RRModeDestroy (crtc->mode);
xfree (crtc);
RRModeDestroy(crtc->mode);
xfree(crtc);
return 1;
}
......@@ -419,22 +392,19 @@ RRCrtcDestroyResource (void * 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;
#if RANDR_12_INTERFACE
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)
{
if (pScreen) {
rrScrPriv(pScreen);
if (pScrPriv->rrCrtcSetGamma)
ret = (*pScrPriv->rrCrtcSetGamma) (pScreen, crtc);
......@@ -450,7 +420,7 @@ RRCrtcGammaSet (RRCrtcPtr crtc,
*/
Bool
RRCrtcGammaNotify (RRCrtcPtr crtc)
RRCrtcGammaNotify(RRCrtcPtr crtc)
{
return TRUE; /* not much going on here */
}
......@@ -486,26 +456,24 @@ RRCrtcGetScanoutSize(RRCrtcPtr crtc, int *width, int *height)
*/
Bool
RRCrtcGammaSetSize (RRCrtcPtr crtc,
int size)
RRCrtcGammaSetSize(RRCrtcPtr crtc, int size)
{
CARD16 *gamma;
if (size == crtc->gammaSize)
return TRUE;
if (size)
{
gamma = xalloc (size * 3 * sizeof (CARD16));
if (size) {
gamma = xalloc(size * 3 * sizeof(CARD16));
if (!gamma)
return FALSE;
}
else
gamma = NULL;
if (crtc->gammaRed)
xfree (crtc->gammaRed);
xfree(crtc->gammaRed);
crtc->gammaRed = gamma;
crtc->gammaGreen = gamma + size;
crtc->gammaBlue = gamma + size*2;
crtc->gammaBlue = gamma + size * 2;
crtc->gammaSize = size;
return TRUE;
}
......@@ -514,17 +482,17 @@ RRCrtcGammaSetSize (RRCrtcPtr crtc,
* Initialize crtc type
*/
Bool
RRCrtcInit (void)
RRCrtcInit(void)
{
RRCrtcType = CreateNewResourceType (RRCrtcDestroyResource);
RRCrtcType = CreateNewResourceType(RRCrtcDestroyResource);
if (!RRCrtcType)
return FALSE;
RegisterResourceName (RRCrtcType, "CRTC");
RegisterResourceName(RRCrtcType, "CRTC");
return TRUE;
}
int
ProcRRGetCrtcInfo (ClientPtr client)
ProcRRGetCrtcInfo(ClientPtr client)
{
REQUEST(xRRGetCrtcInfoReq);
xRRGetCrtcInfoReply rep;
......@@ -560,7 +528,7 @@ ProcRRGetCrtcInfo (ClientPtr client)
rep.timestamp = pScrPriv->lastSetTime.milliseconds;
rep.x = crtc->x;
rep.y = crtc->y;
RRCrtcGetScanoutSize (crtc, &width, &height);
RRCrtcGetScanoutSize(crtc, &width, &height);
rep.width = width;
rep.height = height;
rep.mode = mode ? mode->mode.id : 0;
......@@ -577,9 +545,8 @@ ProcRRGetCrtcInfo (ClientPtr client)
rep.length = rep.nOutput + rep.nPossibleOutput;
extraLen = rep.length << 2;
if (extraLen)
{
extra = xalloc (extraLen);
if (extraLen) {
extra = xalloc(extraLen);
if (!extra)
return BadAlloc;
}
......@@ -589,20 +556,18 @@ ProcRRGetCrtcInfo (ClientPtr client)
outputs = (RROutput *) extra;
possible = (RROutput *) (outputs + rep.nOutput);
for (i = 0; i < crtc->numOutputs; i++)
{
for (i = 0; i < crtc->numOutputs; i++) {
outputs[i] = crtc->outputs[i]->id;
if (client->swapped)
swapl (&outputs[i], n);
swapl(&outputs[i], n);
}
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)
{
if (pScrPriv->outputs[i]->crtcs[j] == crtc) {
possible[k] = pScrPriv->outputs[i]->id;
if (client->swapped)
swapl (&possible[k], n);
swapl(&possible[k], n);
k++;
}
......@@ -620,18 +585,17 @@ ProcRRGetCrtcInfo (ClientPtr client)
swaps(&rep.nOutput, n);
swaps(&rep.nPossibleOutput, n);
}
WriteToClient(client, sizeof(xRRGetCrtcInfoReply), (char *)&rep);
if (extraLen)
{
WriteToClient (client, extraLen, (char *) extra);
xfree (extra);
WriteToClient(client, sizeof(xRRGetCrtcInfoReply), (char *) &rep);
if (extraLen) {
WriteToClient(client, extraLen, (char *) extra);
xfree(extra);
}
return client->noClientException;
}
int
ProcRRSetCrtcConfig (ClientPtr client)
ProcRRSetCrtcConfig(ClientPtr client)
{
REQUEST(xRRSetCrtcConfigReq);
xRRSetCrtcConfigReply rep;
......@@ -647,34 +611,29 @@ ProcRRSetCrtcConfig (ClientPtr client)
int i, j;
REQUEST_AT_LEAST_SIZE(xRRSetCrtcConfigReq);
numOutputs = (stuff->length - (SIZEOF (xRRSetCrtcConfigReq) >> 2));
numOutputs = (stuff->length - (SIZEOF(xRRSetCrtcConfigReq) >> 2));
crtc = LookupIDByType (stuff->crtc, RRCrtcType);
if (!crtc)
{
crtc = LookupIDByType(stuff->crtc, RRCrtcType);
if (!crtc) {
client->errorValue = stuff->crtc;
return RRErrorBase + BadRRCrtc;
}
if (stuff->mode == None)
{
if (stuff->mode == None) {
mode = NULL;
if (numOutputs > 0)
return BadMatch;
}
else
{
mode = LookupIDByType (stuff->mode, RRModeType);
if (!mode)
{
else {
mode = LookupIDByType(stuff->mode, RRModeType);
if (!mode) {
client->errorValue = stuff->mode;
return RRErrorBase + BadRRMode;
}
if (numOutputs == 0)
return BadMatch;
}
if (numOutputs)
{
outputs = xalloc (numOutputs * sizeof (RROutputPtr));
if (numOutputs) {
outputs = xalloc(numOutputs * sizeof(RROutputPtr));
if (!outputs)
return BadAlloc;
}
......@@ -682,59 +641,51 @@ ProcRRSetCrtcConfig (ClientPtr client)
outputs = NULL;
outputIds = (RROutput *) (stuff + 1);
for (i = 0; i < numOutputs; i++)
{
outputs[i] = (RROutputPtr) LookupIDByType (outputIds[i], RROutputType);
if (!outputs[i])
{
for (i = 0; i < numOutputs; i++) {
outputs[i] = (RROutputPtr) LookupIDByType(outputIds[i], RROutputType);
if (!outputs[i]) {
client->errorValue = outputIds[i];
if (outputs)
xfree (outputs);
xfree(outputs);
return RRErrorBase + BadRROutput;
}
/* 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)
{
if (j == outputs[i]->numCrtcs) {
if (outputs)
xfree (outputs);
xfree(outputs);
return BadMatch;
}
/* validate mode for this output */
for (j = 0; j < outputs[i]->numModes + outputs[i]->numUserModes; j++)
{
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)
{
if (j == outputs[i]->numModes + outputs[i]->numUserModes) {
if (outputs)
xfree (outputs);
xfree(outputs);
return BadMatch;
}
}
/* validate clones */
for (i = 0; i < numOutputs; i++)
{
for (j = 0; j < numOutputs; j++)
{
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++)
{
for (k = 0; k < outputs[i]->numClones; k++) {
if (outputs[i]->clones[k] == outputs[j])
break;
}
if (k == outputs[i]->numClones)
{
if (k == outputs[i]->numClones) {
if (outputs)
xfree (outputs);
xfree(outputs);
return BadMatch;
}
}
......@@ -745,8 +696,7 @@ ProcRRSetCrtcConfig (ClientPtr client)
time = ClientTimeToServerTime(stuff->timestamp);
if (!pScrPriv)
{
if (!pScrPriv) {
time = currentTime;
rep.status = RRSetConfigFailed;
goto sendReply;
......@@ -770,20 +720,18 @@ ProcRRSetCrtcConfig (ClientPtr client)
*/
client->errorValue = stuff->rotation;
if (outputs)
xfree (outputs);
xfree(outputs);
return BadValue;
}
if (mode)
{
if ((~crtc->rotations) & rotation)
{
if (mode) {
if ((~crtc->rotations) & rotation) {
/*
* requested rotation or reflection not supported by screen
*/
client->errorValue = stuff->rotation;
if (outputs)
xfree (outputs);
xfree(outputs);
return BadMatch;
}
......@@ -793,29 +741,26 @@ ProcRRSetCrtcConfig (ClientPtr client)
* for setting screen size. Else, assume the CrtcSet sets
* the size along with the mode
*/
if (pScrPriv->rrScreenSetSize)
{
if (pScrPriv->rrScreenSetSize) {
int source_width = mode->mode.width;
int source_height = mode->mode.height;
if ((rotation & 0xf) == RR_Rotate_90 || (rotation & 0xf) == RR_Rotate_270)
{
if ((rotation & 0xf) == RR_Rotate_90 ||
(rotation & 0xf) == RR_Rotate_270) {
source_width = mode->mode.height;
source_height = mode->mode.width;
}
if (stuff->x + source_width > pScreen->width)
{
if (stuff->x + source_width > pScreen->width) {
client->errorValue = stuff->x;
if (outputs)
xfree (outputs);
xfree(outputs);
return BadValue;
}
if (stuff->y + source_height > pScreen->height)
{
if (stuff->y + source_height > pScreen->height) {
client->errorValue = stuff->y;
if (outputs)
xfree (outputs);
xfree(outputs);
return BadValue;
}
}
......@@ -826,24 +771,22 @@ ProcRRSetCrtcConfig (ClientPtr client)
* Make sure the requested set-time is not older than
* the last set-time
*/
if (CompareTimeStamps (time, pScrPriv->lastSetTime) < 0)
{
if (CompareTimeStamps(time, pScrPriv->lastSetTime) < 0) {
rep.status = RRSetConfigInvalidTime;
goto sendReply;
}
if (!RRCrtcSet (crtc, mode, stuff->x, stuff->y,
rotation, numOutputs, outputs))
{
if (!RRCrtcSet(crtc, mode, stuff->x, stuff->y,
rotation, numOutputs, outputs)) {
rep.status = RRSetConfigFailed;
goto sendReply;
}
rep.status = RRSetConfigSuccess;
pScrPriv->lastSetTime = time;
sendReply:
sendReply:
if (outputs)
xfree (outputs);
xfree(outputs);
rep.type = X_Reply;
/* rep.status has already been filled in */
......@@ -851,20 +794,20 @@ sendReply:
rep.sequenceNumber = client->sequence;
rep.newTimestamp = pScrPriv->lastSetTime.milliseconds;
if (client->swapped)
{
if (client->swapped) {
int n;
swaps(&rep.sequenceNumber, n);
swapl(&rep.length, n);
swapl(&rep.newTimestamp, n);
}
WriteToClient(client, sizeof(xRRSetCrtcConfigReply), (char *)&rep);
WriteToClient(client, sizeof(xRRSetCrtcConfigReply), (char *) &rep);
return client->noClientException;
}
int
ProcRRGetCrtcGammaSize (ClientPtr client)
ProcRRGetCrtcGammaSize(ClientPtr client)
{
REQUEST(xRRGetCrtcGammaSizeReq);
xRRGetCrtcGammaSizeReply reply;
......@@ -872,7 +815,7 @@ ProcRRGetCrtcGammaSize (ClientPtr client)
int n;
REQUEST_SIZE_MATCH(xRRGetCrtcGammaSizeReq);
crtc = LookupCrtc (client, stuff->crtc, DixReadAccess);
crtc = LookupCrtc(client, stuff->crtc, DixReadAccess);
if (!crtc)
return RRErrorBase + BadRRCrtc;
......@@ -881,16 +824,16 @@ ProcRRGetCrtcGammaSize (ClientPtr client)
reply.length = 0;
reply.size = crtc->gammaSize;
if (client->swapped) {
swaps (&reply.sequenceNumber, n);
swapl (&reply.length, n);
swaps (&reply.size, n);
swaps(&reply.sequenceNumber, n);
swapl(&reply.length, n);
swaps(&reply.size, n);
}
WriteToClient (client, sizeof (xRRGetCrtcGammaSizeReply), (char *) &reply);
WriteToClient(client, sizeof(xRRGetCrtcGammaSizeReply), (char *) &reply);
return client->noClientException;
}
int
ProcRRGetCrtcGamma (ClientPtr client)
ProcRRGetCrtcGamma(ClientPtr client)
{
REQUEST(xRRGetCrtcGammaReq);
xRRGetCrtcGammaReply reply;
......@@ -900,7 +843,7 @@ ProcRRGetCrtcGamma (ClientPtr client)
char *extra;
REQUEST_SIZE_MATCH(xRRGetCrtcGammaReq);
crtc = LookupCrtc (client, stuff->crtc, DixReadAccess);
crtc = LookupCrtc(client, stuff->crtc, DixReadAccess);
if (!crtc)
return RRErrorBase + BadRRCrtc;
......@@ -917,23 +860,22 @@ ProcRRGetCrtcGamma (ClientPtr client)
reply.length = (len + 3) >> 2;
reply.size = crtc->gammaSize;
if (client->swapped) {
swaps (&reply.sequenceNumber, n);
swapl (&reply.length, n);
swaps (&reply.size, n);
swaps(&reply.sequenceNumber, n);
swapl(&reply.length, n);
swaps(&reply.size, n);
}
WriteToClient (client, sizeof (xRRGetCrtcGammaReply), (char *) &reply);
if (crtc->gammaSize)
{
WriteToClient(client, sizeof(xRRGetCrtcGammaReply), (char *) &reply);
if (crtc->gammaSize) {
memcpy(extra, crtc->gammaRed, len);
client->pSwapReplyFunc = (ReplySwapPtr)CopySwap16Write;
WriteSwappedDataToClient (client, len, extra);
client->pSwapReplyFunc = (ReplySwapPtr) CopySwap16Write;
WriteSwappedDataToClient(client, len, extra);
xfree(extra);
}
return client->noClientException;
}
int
ProcRRSetCrtcGamma (ClientPtr client)
ProcRRSetCrtcGamma(ClientPtr client)
{
REQUEST(xRRSetCrtcGammaReq);
RRCrtcPtr crtc;
......@@ -941,11 +883,11 @@ ProcRRSetCrtcGamma (ClientPtr client)
CARD16 *red, *green, *blue;
REQUEST_AT_LEAST_SIZE(xRRSetCrtcGammaReq);
crtc = LookupCrtc (client, stuff->crtc, DixWriteAccess);
crtc = LookupCrtc(client, stuff->crtc, DixWriteAccess);
if (!crtc)
return RRErrorBase + BadRRCrtc;
len = client->req_len - (sizeof (xRRSetCrtcGammaReq) >> 2);
len = client->req_len - (sizeof(xRRSetCrtcGammaReq) >> 2);
if (len < (stuff->size * 3 + 1) >> 1)
return BadLength;
......@@ -956,8 +898,7 @@ ProcRRSetCrtcGamma (ClientPtr client)
green = red + crtc->gammaSize;
blue = green + crtc->gammaSize;
RRCrtcGammaSet (crtc, red, green, blue);
RRCrtcGammaSet(crtc, red, green, blue);
return Success;
}
......@@ -26,7 +26,7 @@
#define SERVER_RANDR_MINOR 2
Bool
RRClientKnowsRates (ClientPtr pClient)
RRClientKnowsRates(ClientPtr pClient)
{
rrClientPriv(pClient);
......@@ -35,10 +35,11 @@ RRClientKnowsRates (ClientPtr pClient)
}
static int
ProcRRQueryVersion (ClientPtr client)
ProcRRQueryVersion(ClientPtr client)
{
xRRQueryVersionReply rep;
register int n;
REQUEST(xRRQueryVersionReq);
rrClientPriv(client);
......@@ -60,12 +61,12 @@ ProcRRQueryVersion (ClientPtr client)
swapl(&rep.majorVersion, n);
swapl(&rep.minorVersion, n);
}
WriteToClient(client, sizeof(xRRQueryVersionReply), (char *)&rep);
WriteToClient(client, sizeof(xRRQueryVersionReply), (char *) &rep);
return (client->noClientException);
}
static int
ProcRRSelectInput (ClientPtr client)
ProcRRSelectInput(ClientPtr client)
{
REQUEST(xRRSelectInputReq);
rrClientPriv(client);
......@@ -76,38 +77,35 @@ ProcRRSelectInput (ClientPtr client)
int rc;
REQUEST_SIZE_MATCH(xRRSelectInputReq);
#ifndef NXAGENT_SERVER
#ifndef NXAGENT_SERVER
rc = dixLookupWindow(&pWin, stuff->window, client, DixWriteAccess);
#else
#else
pWin = SecurityLookupWindow(stuff->window, client, SecurityWriteAccess);
rc = pWin ? Success : BadWindow;
#endif
#endif
if (rc != Success)
return rc;
pHead = (RREventPtr *)SecurityLookupIDByType(client,
pWin->drawable.id, RREventType,
DixWriteAccess);
pHead = (RREventPtr *) SecurityLookupIDByType(client,
pWin->drawable.id,
RREventType, DixWriteAccess);
if (stuff->enable & (RRScreenChangeNotifyMask|
RRCrtcChangeNotifyMask|
RROutputChangeNotifyMask))
{
if (stuff->enable & (RRScreenChangeNotifyMask |
RRCrtcChangeNotifyMask | RROutputChangeNotifyMask)) {
ScreenPtr pScreen = pWin->drawable.pScreen;
rrScrPriv (pScreen);
rrScrPriv(pScreen);
pRREvent = NULL;
if (pHead)
{
if (pHead) {
/* check for existing entry. */
for (pRREvent = *pHead; pRREvent; pRREvent = pRREvent->next)
if (pRREvent->client == client)
break;
}
if (!pRREvent)
{
if (!pRREvent) {
/* build the entry */
pRREvent = (RREventPtr) xalloc (sizeof (RREventRec));
pRREvent = (RREventPtr) xalloc(sizeof(RREventRec));
if (!pRREvent)
return BadAlloc;
pRREvent->next = 0;
......@@ -118,9 +116,9 @@ ProcRRSelectInput (ClientPtr client)
* add a resource that will be deleted when
* the client goes away
*/
clientResource = FakeClientID (client->index);
clientResource = FakeClientID(client->index);
pRREvent->clientResource = clientResource;
if (!AddResource (clientResource, RRClientType, (void *)pRREvent))
if (!AddResource(clientResource, RRClientType, (void *) pRREvent))
return BadAlloc;
/*
* create a resource to contain a pointer to the list
......@@ -128,13 +126,12 @@ ProcRRSelectInput (ClientPtr client)
* the list may be arbitrarily rearranged which cannot be
* done through the resource database.
*/
if (!pHead)
{
pHead = (RREventPtr *) xalloc (sizeof (RREventPtr));
if (!pHead) {
pHead = (RREventPtr *) xalloc(sizeof(RREventPtr));
if (!pHead ||
!AddResource (pWin->drawable.id, RREventType, (void *)pHead))
{
FreeResource (clientResource, RT_NONE);
!AddResource(pWin->drawable.id, RREventType,
(void *) pHead)) {
FreeResource(clientResource, RT_NONE);
return BadAlloc;
}
*pHead = 0;
......@@ -145,47 +142,44 @@ ProcRRSelectInput (ClientPtr client)
/*
* Now see if the client needs an event
*/
if (pScrPriv && (pRREvent->mask & RRScreenChangeNotifyMask))
{
if (pScrPriv && (pRREvent->mask & RRScreenChangeNotifyMask)) {
pTimes = &((RRTimesPtr) (pRRClient + 1))[pScreen->myNum];
if (CompareTimeStamps (pTimes->setTime,
if (CompareTimeStamps(pTimes->setTime,
pScrPriv->lastSetTime) != 0 ||
CompareTimeStamps (pTimes->configTime,
pScrPriv->lastConfigTime) != 0)
{
RRDeliverScreenEvent (client, pWin, pScreen);
CompareTimeStamps(pTimes->configTime,
pScrPriv->lastConfigTime) != 0) {
RRDeliverScreenEvent(client, pWin, pScreen);
}
}
}
else if (stuff->enable == 0)
{
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);
FreeResource(pRREvent->clientResource, RRClientType);
if (pNewRREvent)
pNewRREvent->next = pRREvent->next;
else
*pHead = pRREvent->next;
xfree (pRREvent);
xfree(pRREvent);
}
}
}
else
{
else {
client->errorValue = stuff->enable;
return BadValue;
}
return Success;
}
int (*ProcRandrVector[RRNumberRequests])(ClientPtr) = {
int (*ProcRandrVector[RRNumberRequests]) (ClientPtr) = {
ProcRRQueryVersion, /* 0 */
/* we skip 1 to make old clients fail pretty immediately */
NULL, /* 1 ProcRandrOldGetScreenInfo */
......@@ -216,4 +210,3 @@ int (*ProcRandrVector[RRNumberRequests])(ClientPtr) = {
ProcRRGetCrtcGamma, /* 23 */
ProcRRSetCrtcGamma, /* 24 */
};
......@@ -24,9 +24,10 @@
#ifdef RANDR_10_INTERFACE
static RRModePtr
RROldModeAdd (RROutputPtr output, RRScreenSizePtr size, int refresh)
RROldModeAdd(RROutputPtr output, RRScreenSizePtr size, int refresh)
{
ScreenPtr pScreen = output->pScreen;
rrScrPriv(pScreen);
xRRModeInfo modeInfo;
char name[100];
......@@ -34,8 +35,8 @@ RROldModeAdd (RROutputPtr output, RRScreenSizePtr size, int refresh)
int i;
RRModePtr *modes;
memset (&modeInfo, '\0', sizeof (modeInfo));
sprintf (name, "%dx%d", size->width, size->height);
memset(&modeInfo, '\0', sizeof(modeInfo));
sprintf(name, "%dx%d", size->width, size->height);
modeInfo.width = size->width;
modeInfo.height = size->height;
......@@ -43,26 +44,24 @@ RROldModeAdd (RROutputPtr output, RRScreenSizePtr size, int refresh)
modeInfo.vTotal = size->height;
modeInfo.dotClock = ((CARD32) size->width * (CARD32) size->height *
(CARD32) refresh);
modeInfo.nameLength = strlen (name);
mode = RRModeGet (&modeInfo, name);
modeInfo.nameLength = strlen(name);
mode = RRModeGet(&modeInfo, name);
if (!mode)
return NULL;
for (i = 0; i < output->numModes; i++)
if (output->modes[i] == mode)
{
RRModeDestroy (mode);
if (output->modes[i] == mode) {
RRModeDestroy(mode);
return mode;
}
if (output->numModes)
modes = xrealloc (output->modes,
(output->numModes + 1) * sizeof (RRModePtr));
modes = xrealloc(output->modes,
(output->numModes + 1) * sizeof(RRModePtr));
else
modes = xalloc (sizeof (RRModePtr));
if (!modes)
{
RRModeDestroy (mode);
FreeResource (mode->mode.id, 0);
modes = xalloc(sizeof(RRModePtr));
if (!modes) {
RRModeDestroy(mode);
FreeResource(mode->mode.id, 0);
return NULL;
}
modes[output->numModes++] = mode;
......@@ -74,7 +73,7 @@ RROldModeAdd (RROutputPtr output, RRScreenSizePtr size, int refresh)
}
static void
RRScanOldConfig (ScreenPtr pScreen, Rotation rotations)
RRScanOldConfig(ScreenPtr pScreen, Rotation rotations)
{
rrScrPriv(pScreen);
RROutputPtr output;
......@@ -89,19 +88,17 @@ RRScanOldConfig (ScreenPtr pScreen, Rotation rotations)
* First time through, create a crtc and output and hook
* them together
*/
if (pScrPriv->numOutputs == 0 &&
pScrPriv->numCrtcs == 0)
{
crtc = RRCrtcCreate (pScreen, NULL);
if (pScrPriv->numOutputs == 0 && pScrPriv->numCrtcs == 0) {
crtc = RRCrtcCreate(pScreen, NULL);
if (!crtc)
return;
output = RROutputCreate (pScreen, "default", 7, NULL);
output = RROutputCreate(pScreen, "default", 7, NULL);
if (!output)
return;
RROutputSetCrtcs (output, &crtc, 1);
RROutputSetConnection (output, RR_Connected);
RROutputSetCrtcs(output, &crtc, 1);
RROutputSetConnection(output, RR_Connected);
#ifdef RENDER
RROutputSetSubpixelOrder (output, PictureGetSubpixelOrder (pScreen));
RROutputSetSubpixelOrder(output, PictureGetSubpixelOrder(pScreen));
#endif
}
......@@ -113,65 +110,60 @@ RRScanOldConfig (ScreenPtr pScreen, Rotation rotations)
return;
/* check rotations */
if (rotations != crtc->rotations)
{
if (rotations != crtc->rotations) {
crtc->rotations = rotations;
crtc->changed = TRUE;
pScrPriv->changed = TRUE;
}
/* regenerate mode list */
for (i = 0; i < pScrPriv->nSizes; i++)
{
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 (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)
{
size->pRates[r].rate == pScrPriv->rate) {
newMode = mode;
}
}
xfree (size->pRates);
xfree(size->pRates);
}
else
{
mode = RROldModeAdd (output, size, 0);
else {
mode = RROldModeAdd(output, size, 0);
if (i == pScrPriv->size)
newMode = mode;
}
}
if (pScrPriv->nSizes)
xfree (pScrPriv->pSizes);
xfree(pScrPriv->pSizes);
pScrPriv->pSizes = NULL;
pScrPriv->nSizes = 0;
/* find size bounds */
for (i = 0; i < output->numModes + output->numUserModes; i++)
{
for (i = 0; i < output->numModes + output->numUserModes; i++) {
mode = (i < output->numModes ?
output->modes[i] :
output->userModes[i-output->numModes]);
output->modes[i] : output->userModes[i - output->numModes]);
width = mode->mode.width;
height = mode->mode.height;
if (width < minWidth) minWidth = width;
if (width > maxWidth) maxWidth = width;
if (height < minHeight) minHeight = height;
if (height > maxHeight) maxHeight = 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,
1, &output);
RRCrtcNotify(crtc, newMode, 0, 0, pScrPriv->rotation, 1, &output);
}
#endif
......@@ -179,9 +171,9 @@ RRScanOldConfig (ScreenPtr pScreen, Rotation rotations)
* Poll the driver for changed information
*/
Bool
RRGetInfo (ScreenPtr pScreen)
RRGetInfo(ScreenPtr pScreen)
{
rrScrPriv (pScreen);
rrScrPriv(pScreen);
Rotation rotations;
int i;
......@@ -199,9 +191,9 @@ RRGetInfo (ScreenPtr pScreen)
#if RANDR_10_INTERFACE
if (pScrPriv->nSizes)
RRScanOldConfig (pScreen, rotations);
RRScanOldConfig(pScreen, rotations);
#endif
RRTellChanged (pScreen);
RRTellChanged(pScreen);
return TRUE;
}
......@@ -209,19 +201,16 @@ RRGetInfo (ScreenPtr pScreen)
* Register the range of sizes for the screen
*/
void
RRScreenSetSizeRange (ScreenPtr pScreen,
RRScreenSetSizeRange(ScreenPtr pScreen,
CARD16 minWidth,
CARD16 minHeight,
CARD16 maxWidth,
CARD16 maxHeight)
CARD16 minHeight, CARD16 maxWidth, CARD16 maxHeight)
{
rrScrPriv (pScreen);
rrScrPriv(pScreen);
if (!pScrPriv)
return;
if (pScrPriv->minWidth == minWidth && pScrPriv->minHeight == minHeight &&
pScrPriv->maxWidth == maxWidth && pScrPriv->maxHeight == maxHeight)
{
pScrPriv->maxWidth == maxWidth && pScrPriv->maxHeight == maxHeight) {
return;
}
......@@ -235,8 +224,7 @@ 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;
......@@ -250,13 +238,10 @@ RRScreenSizeMatches (RRScreenSizePtr a,
}
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);
rrScrPriv(pScreen);
int i;
RRScreenSize tmp;
RRScreenSizePtr pNew;
......@@ -266,26 +251,25 @@ RRRegisterSize (ScreenPtr pScreen,
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]))
if (RRScreenSizeMatches(&tmp, &pScrPriv->pSizes[i]))
return &pScrPriv->pSizes[i];
pNew = xrealloc (pScrPriv->pSizes,
(pScrPriv->nSizes + 1) * sizeof (RRScreenSize));
pNew = xrealloc(pScrPriv->pSizes,
(pScrPriv->nSizes + 1) * sizeof(RRScreenSize));
if (!pNew)
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;
......@@ -298,8 +282,7 @@ Bool RRRegisterRate (ScreenPtr pScreen,
if (pSize->pRates[i].rate == rate)
return TRUE;
pNew = xrealloc (pSize->pRates,
(pSize->nRates + 1) * sizeof (RRScreenRate));
pNew = xrealloc(pSize->pRates, (pSize->nRates + 1) * sizeof(RRScreenRate));
if (!pNew)
return FALSE;
pRate = &pNew[pSize->nRates++];
......@@ -311,7 +294,7 @@ Bool RRRegisterRate (ScreenPtr pScreen,
Rotation
RRGetRotation(ScreenPtr pScreen)
{
RROutputPtr output = RRFirstOutput (pScreen);
RROutputPtr output = RRFirstOutput(pScreen);
if (!output)
return RR_Rotate_0;
......@@ -320,12 +303,10 @@ RRGetRotation(ScreenPtr pScreen)
}
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;
......
......@@ -43,20 +43,32 @@
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;
}
......@@ -67,33 +79,30 @@ 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 ())
if (!RRInit())
return NULL;
mode = xalloc (sizeof (RRModeRec) + modeInfo->nameLength + 1);
mode = xalloc(sizeof(RRModeRec) + modeInfo->nameLength + 1);
if (!mode)
return NULL;
mode->refcnt = 1;
mode->mode = *modeInfo;
mode->name = (char *) (mode + 1);
memcpy (mode->name, name, modeInfo->nameLength);
memcpy(mode->name, name, modeInfo->nameLength);
mode->name[modeInfo->nameLength] = '\0';
mode->userScreen = userScreen;
if (num_modes)
newModes = xrealloc (modes, (num_modes + 1) * sizeof (RRModePtr));
newModes = xrealloc(modes, (num_modes + 1) * sizeof(RRModePtr));
else
newModes = xalloc (sizeof (RRModePtr));
newModes = xalloc(sizeof(RRModePtr));
if (!newModes)
{
xfree (mode);
if (!newModes) {
xfree(mode);
return NULL;
}
......@@ -109,24 +118,23 @@ RRModeCreate (xRRModeInfo *modeInfo,
*/
++mode->refcnt;
#ifdef DEBUG
fprintf(stderr, "RRModeCreate: num_modes [%d] new mode [%s] ([%p]) refcnt [%d]\n", num_modes, mode->name, mode, mode->refcnt);
fprintf(stderr,
"RRModeCreate: num_modes [%d] new mode [%s] ([%p]) refcnt [%d]\n",
num_modes, mode->name, mode, mode->refcnt);
#endif
return mode;
}
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++)
{
for (i = 0; i < num_modes; i++) {
mode = modes[i];
if (mode->mode.nameLength == nameLength &&
!memcmp (name, mode->name, nameLength))
{
!memcmp(name, mode->name, nameLength)) {
return mode;
}
}
......@@ -134,20 +142,20 @@ RRModeFindByName (const char *name,
}
RRModePtr
RRModeGet (xRRModeInfo *modeInfo,
const char *name)
RRModeGet(xRRModeInfo * modeInfo, const char *name)
{
int i;
for (i = 0; i < num_modes; i++)
{
for (i = 0; i < num_modes; i++) {
RRModePtr mode = modes[i];
if (RRModeEqual (&mode->mode, modeInfo) &&
!memcmp (name, mode->name, modeInfo->nameLength))
{
if (RRModeEqual(&mode->mode, modeInfo) &&
!memcmp(name, mode->name, modeInfo->nameLength)) {
++mode->refcnt;
#ifdef DEBUG
fprintf(stderr, "RRModeGet: return existing mode [%s] ([%p]) refcnt [%d]\n", mode->name, mode, mode->refcnt);
fprintf(stderr,
"RRModeGet: return existing mode [%s] ([%p]) refcnt [%d]\n",
mode->name, mode, mode->refcnt);
#endif
return mode;
}
......@@ -155,33 +163,31 @@ RRModeGet (xRRModeInfo *modeInfo,
#ifdef DEBUG
{
RRModePtr mode = RRModeCreate (modeInfo, name, NULL);
fprintf(stderr, "RRModeGet: return new mode [%s] ([%p]) refcnt [%d]\n", mode->name, mode, mode->refcnt);
RRModePtr mode = RRModeCreate(modeInfo, name, NULL);
fprintf(stderr, "RRModeGet: return new mode [%s] ([%p]) refcnt [%d]\n",
mode->name, mode, mode->refcnt);
return mode;
}
#else
return RRModeCreate (modeInfo, name, NULL);
return RRModeCreate(modeInfo, name, NULL);
#endif
}
static RRModePtr
RRModeCreateUser (ScreenPtr pScreen,
xRRModeInfo *modeInfo,
const char *name,
int *error)
RRModeCreateUser(ScreenPtr pScreen,
xRRModeInfo * modeInfo, const char *name, int *error)
{
RRModePtr mode;
mode = RRModeFindByName (name, modeInfo->nameLength);
if (mode)
{
mode = RRModeFindByName(name, modeInfo->nameLength);
if (mode) {
*error = BadName;
return NULL;
}
mode = RRModeCreate (modeInfo, name, pScreen);
if (!mode)
{
mode = RRModeCreate(modeInfo, name, pScreen);
if (!mode) {
*error = BadAlloc;
return NULL;
}
......@@ -190,30 +196,28 @@ RRModeCreateUser (ScreenPtr pScreen,
}
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;
screen_modes = xalloc ((num_modes ? num_modes : 1) * sizeof (RRModePtr));
screen_modes = xalloc((num_modes ? num_modes : 1) * sizeof(RRModePtr));
if (!screen_modes)
return NULL;
/*
* Add modes from all outputs
*/
for (o = 0; o < pScrPriv->numOutputs; o++)
{
for (o = 0; o < pScrPriv->numOutputs; o++) {
RROutputPtr output = pScrPriv->outputs[o];
int n;
for (m = 0; m < output->numModes + output->numUserModes; m++)
{
for (m = 0; m < output->numModes + output->numUserModes; m++) {
RRModePtr mode = (m < output->numModes ?
output->modes[m] :
output->userModes[m-output->numModes]);
output->userModes[m - output->numModes]);
for (n = 0; n < num_screen_modes; n++)
if (screen_modes[n] == mode)
break;
......@@ -226,13 +230,13 @@ RRModesForScreen (ScreenPtr pScreen, int *num_ret)
* make sure all available and active modes
* are visible to the client
*/
for (c = 0; c < pScrPriv->numCrtcs; c++)
{
for (c = 0; c < pScrPriv->numCrtcs; c++) {
RRCrtcPtr crtc = pScrPriv->crtcs[c];
RRModePtr mode = crtc->mode;
int n;
if (!mode) continue;
if (!mode)
continue;
for (n = 0; n < num_screen_modes; n++)
if (screen_modes[n] == mode)
break;
......@@ -242,8 +246,7 @@ RRModesForScreen (ScreenPtr pScreen, int *num_ret)
/*
* Add all user modes for this screen
*/
for (m = 0; m < num_modes; m++)
{
for (m = 0; m < num_modes; m++) {
RRModePtr mode = modes[m];
int n;
......@@ -261,26 +264,24 @@ RRModesForScreen (ScreenPtr pScreen, int *num_ret)
}
void
RRModeDestroy (RRModePtr mode)
RRModeDestroy(RRModePtr mode)
{
int m;
if (--mode->refcnt > 0) {
#ifdef DEBUG
fprintf(stderr, "RRModeDestroy: mode [%s] ([%p]) refcnt [%d -> %d]\n", mode->name, mode, mode->refcnt + 1, mode->refcnt);
fprintf(stderr, "RRModeDestroy: mode [%s] ([%p]) refcnt [%d -> %d]\n",
mode->name, mode, mode->refcnt + 1, mode->refcnt);
#endif
return;
}
for (m = 0; m < num_modes; m++)
{
if (modes[m] == mode)
{
memmove (modes + m, modes + m + 1,
(num_modes - m - 1) * sizeof (RRModePtr));
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)
{
xfree (modes);
if (!num_modes) {
xfree(modes);
modes = NULL;
}
break;
......@@ -288,35 +289,38 @@ RRModeDestroy (RRModePtr mode)
}
#ifdef DEBUG
fprintf(stderr, "RRModeDestroy: destroyed mode [%s] ([%p])\n", mode->name, mode);
fprintf(stderr, "RRModeDestroy: destroyed mode [%s] ([%p])\n", mode->name,
mode);
#endif
xfree (mode);
xfree(mode);
}
static int
RRModeDestroyResource (void * value, XID pid)
RRModeDestroyResource(void *value, XID pid)
{
#ifdef DEBUG
fprintf(stderr, "RRModeDestroyResource: mode [%s] ([%p]) refcnt [%d]\n", ((RRModePtr)value)->name, (RRModePtr)value, ((RRModePtr)value)->refcnt);
fprintf(stderr, "RRModeDestroyResource: mode [%s] ([%p]) refcnt [%d]\n",
((RRModePtr) value)->name, (RRModePtr) value,
((RRModePtr) value)->refcnt);
#endif
RRModeDestroy ((RRModePtr) value);
RRModeDestroy((RRModePtr) value);
return 1;
}
Bool
RRModeInit (void)
RRModeInit(void)
{
assert (num_modes == 0);
assert (modes == NULL);
RRModeType = CreateNewResourceType (RRModeDestroyResource);
assert(num_modes == 0);
assert(modes == NULL);
RRModeType = CreateNewResourceType(RRModeDestroyResource);
if (!RRModeType)
return FALSE;
RegisterResourceName (RRModeType, "MODE");
RegisterResourceName(RRModeType, "MODE");
return TRUE;
}
int
ProcRRCreateMode (ClientPtr client)
ProcRRCreateMode(ClientPtr client)
{
REQUEST(xRRCreateModeReq);
xRRCreateModeReply rep;
......@@ -328,13 +332,13 @@ ProcRRCreateMode (ClientPtr client)
int error, rc;
RRModePtr mode;
REQUEST_AT_LEAST_SIZE (xRRCreateModeReq);
#ifndef NXAGENT_SERVER
REQUEST_AT_LEAST_SIZE(xRRCreateModeReq);
#ifndef NXAGENT_SERVER
rc = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess);
#else
#else
pWin = SecurityLookupWindow(stuff->window, client, SecurityReadAccess);
rc = pWin ? Success : BadWindow;
#endif
#endif
if (rc != Success)
return rc;
......@@ -342,13 +346,13 @@ ProcRRCreateMode (ClientPtr client)
modeInfo = &stuff->modeInfo;
name = (char *) (stuff + 1);
units_after = (stuff->length - (sizeof (xRRCreateModeReq) >> 2));
units_after = (stuff->length - (sizeof(xRRCreateModeReq) >> 2));
/* check to make sure requested name fits within the data provided */
if ((int) (modeInfo->nameLength + 3) >> 2 > units_after)
return BadLength;
mode = RRModeCreateUser (pScreen, modeInfo, name, &error);
mode = RRModeCreateUser(pScreen, modeInfo, name, &error);
if (!mode)
return error;
......@@ -357,29 +361,28 @@ ProcRRCreateMode (ClientPtr client)
rep.sequenceNumber = client->sequence;
rep.length = 0;
rep.mode = mode->mode.id;
if (client->swapped)
{
if (client->swapped) {
int n;
swaps(&rep.sequenceNumber, n);
swapl(&rep.length, n);
swapl(&rep.mode, n);
}
WriteToClient(client, sizeof(xRRCreateModeReply), (char *)&rep);
WriteToClient(client, sizeof(xRRCreateModeReply), (char *) &rep);
/* Drop out reference to this mode */
RRModeDestroy (mode);
RRModeDestroy(mode);
return client->noClientException;
}
int
ProcRRDestroyMode (ClientPtr client)
ProcRRDestroyMode(ClientPtr client)
{
REQUEST(xRRDestroyModeReq);
RRModePtr mode;
REQUEST_SIZE_MATCH(xRRDestroyModeReq);
mode = LookupIDByType (stuff->mode, RRModeType);
if (!mode)
{
mode = LookupIDByType(stuff->mode, RRModeType);
if (!mode) {
client->errorValue = stuff->mode;
return RRErrorBase + BadRRMode;
}
......@@ -387,12 +390,12 @@ ProcRRDestroyMode (ClientPtr client)
return BadMatch;
if (mode->refcnt > 1)
return BadAccess;
FreeResource (stuff->mode, 0);
FreeResource(stuff->mode, 0);
return Success;
}
int
ProcRRAddOutputMode (ClientPtr client)
ProcRRAddOutputMode(ClientPtr client)
{
REQUEST(xRRAddOutputModeReq);
RRModePtr mode;
......@@ -401,24 +404,22 @@ ProcRRAddOutputMode (ClientPtr client)
REQUEST_SIZE_MATCH(xRRAddOutputModeReq);
output = LookupOutput(client, stuff->output, DixReadAccess);
if (!output)
{
if (!output) {
client->errorValue = stuff->output;
return RRErrorBase + BadRROutput;
}
mode = LookupIDByType (stuff->mode, RRModeType);
if (!mode)
{
mode = LookupIDByType(stuff->mode, RRModeType);
if (!mode) {
client->errorValue = stuff->mode;
return RRErrorBase + BadRRMode;
}
return RROutputAddUserMode (output, mode);
return RROutputAddUserMode(output, mode);
}
int
ProcRRDeleteOutputMode (ClientPtr client)
ProcRRDeleteOutputMode(ClientPtr client)
{
REQUEST(xRRDeleteOutputModeReq);
RRModePtr mode;
......@@ -427,18 +428,16 @@ ProcRRDeleteOutputMode (ClientPtr client)
REQUEST_SIZE_MATCH(xRRDeleteOutputModeReq);
output = LookupOutput(client, stuff->output, DixReadAccess);
if (!output)
{
if (!output) {
client->errorValue = stuff->output;
return RRErrorBase + BadRROutput;
}
mode = LookupIDByType (stuff->mode, RRModeType);
if (!mode)
{
mode = LookupIDByType(stuff->mode, RRModeType);
if (!mode) {
client->errorValue = stuff->mode;
return RRErrorBase + BadRRMode;
}
return RROutputDeleteUserMode (output, mode);
return RROutputDeleteUserMode(output, mode);
}
......@@ -29,14 +29,13 @@ RESTYPE RROutputType;
* Notify the output of some change
*/
void
RROutputChanged (RROutputPtr output, Bool configChanged)
RROutputChanged(RROutputPtr output, Bool configChanged)
{
ScreenPtr pScreen = output->pScreen;
output->changed = TRUE;
if (pScreen)
{
rrScrPriv (pScreen);
if (pScreen) {
rrScrPriv(pScreen);
pScrPriv->changed = TRUE;
if (configChanged)
pScrPriv->configChanged = TRUE;
......@@ -48,10 +47,8 @@ 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;
......@@ -63,23 +60,23 @@ RROutputCreate (ScreenPtr pScreen,
pScrPriv = rrGetScrPriv(pScreen);
if (pScrPriv->numOutputs)
outputs = xrealloc (pScrPriv->outputs,
(pScrPriv->numOutputs + 1) * sizeof (RROutputPtr));
outputs = xrealloc(pScrPriv->outputs,
(pScrPriv->numOutputs + 1) * sizeof(RROutputPtr));
else
outputs = xalloc (sizeof (RROutputPtr));
outputs = xalloc(sizeof(RROutputPtr));
if (!outputs)
return FALSE;
pScrPriv->outputs = outputs;
output = xalloc (sizeof (RROutputRec) + nameLength + 1);
output = xalloc(sizeof(RROutputRec) + nameLength + 1);
if (!output)
return NULL;
output->id = FakeClientID (0);
output->id = FakeClientID(0);
output->pScreen = pScreen;
output->name = (char *) (output + 1);
output->nameLength = nameLength;
memcpy (output->name, name, nameLength);
memcpy(output->name, name, nameLength);
output->name[nameLength] = '\0';
output->connection = RR_UnknownConnection;
output->subpixelOrder = SubPixelUnknown;
......@@ -100,7 +97,7 @@ RROutputCreate (ScreenPtr pScreen,
output->changed = FALSE;
output->devPrivate = devPrivate;
if (!AddResource (output->id, RROutputType, (void *) output))
if (!AddResource(output->id, RROutputType, (void *) output))
return NULL;
pScrPriv->outputs[pScrPriv->numOutputs++] = output;
......@@ -111,94 +108,83 @@ 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)
{
if (numClones == output->numClones) {
for (i = 0; i < numClones; i++)
if (output->clones[i] != clones[i])
break;
if (i == numClones)
return TRUE;
}
if (numClones)
{
newClones = xalloc (numClones * sizeof (RROutputPtr));
if (numClones) {
newClones = xalloc(numClones * sizeof(RROutputPtr));
if (!newClones)
return FALSE;
}
else
newClones = NULL;
if (output->clones)
xfree (output->clones);
memcpy (newClones, clones, numClones * sizeof (RROutputPtr));
xfree(output->clones);
memcpy(newClones, clones, numClones * sizeof(RROutputPtr));
output->clones = newClones;
output->numClones = numClones;
RROutputChanged (output, TRUE);
RROutputChanged(output, TRUE);
return TRUE;
}
Bool
RROutputSetModes (RROutputPtr output,
RRModePtr *modes,
int numModes,
int numPreferred)
RROutputSetModes(RROutputPtr output,
RRModePtr * modes, int numModes, int numPreferred)
{
RRModePtr *newModes;
int i;
if (numModes == output->numModes && numPreferred == output->numPreferred)
{
if (numModes == output->numModes && numPreferred == output->numPreferred) {
for (i = 0; i < numModes; i++)
if (output->modes[i] != modes[i])
break;
if (i == numModes)
{
if (i == numModes) {
for (i = 0; i < numModes; i++)
RRModeDestroy (modes[i]);
RRModeDestroy(modes[i]);
return TRUE;
}
}
if (numModes)
{
newModes = xalloc (numModes * sizeof (RRModePtr));
if (numModes) {
newModes = xalloc(numModes * sizeof(RRModePtr));
if (!newModes)
return FALSE;
}
else
newModes = NULL;
if (output->modes)
{
if (output->modes) {
for (i = 0; i < output->numModes; i++)
RRModeDestroy (output->modes[i]);
xfree (output->modes);
RRModeDestroy(output->modes[i]);
xfree(output->modes);
}
memcpy (newModes, modes, numModes * sizeof (RRModePtr));
memcpy(newModes, modes, numModes * sizeof(RRModePtr));
output->modes = newModes;
output->numModes = numModes;
output->numPreferred = numPreferred;
RROutputChanged (output, TRUE);
RROutputChanged(output, TRUE);
return TRUE;
}
int
RROutputAddUserMode (RROutputPtr output,
RRModePtr mode)
RROutputAddUserMode(RROutputPtr output, RRModePtr mode)
{
int m;
ScreenPtr pScreen = output->pScreen;
rrScrPriv(pScreen);
RRModePtr *newModes;
/* Check to see if this mode is already listed for this output */
for (m = 0; m < output->numModes + output->numUserModes; m++)
{
for (m = 0; m < output->numModes + output->numUserModes; m++) {
RRModePtr e = (m < output->numModes ?
output->modes[m] :
output->userModes[m - output->numModes]);
......@@ -208,34 +194,32 @@ RROutputAddUserMode (RROutputPtr output,
/* Check with the DDX to see if this mode is OK */
if (pScrPriv->rrOutputValidateMode)
if (!pScrPriv->rrOutputValidateMode (pScreen, output, mode))
if (!pScrPriv->rrOutputValidateMode(pScreen, output, mode))
return BadMatch;
if (output->userModes)
newModes = xrealloc (output->userModes,
(output->numUserModes + 1) * sizeof (RRModePtr));
newModes = xrealloc(output->userModes,
(output->numUserModes + 1) * sizeof(RRModePtr));
else
newModes = xalloc (sizeof (RRModePtr));
newModes = xalloc(sizeof(RRModePtr));
if (!newModes)
return BadAlloc;
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;
/* Find this mode in the user mode list */
for (m = 0; m < output->numUserModes; m++)
{
for (m = 0; m < output->numUserModes; m++) {
RRModePtr e = output->userModes[m];
if (mode == e)
......@@ -249,88 +233,80 @@ RROutputDeleteUserMode (RROutputPtr output,
if (output->crtc && output->crtc->mode == mode)
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)
{
if (numCrtcs == output->numCrtcs) {
for (i = 0; i < numCrtcs; i++)
if (output->crtcs[i] != crtcs[i])
break;
if (i == numCrtcs)
return TRUE;
}
if (numCrtcs)
{
newCrtcs = xalloc (numCrtcs * sizeof (RRCrtcPtr));
if (numCrtcs) {
newCrtcs = xalloc(numCrtcs * sizeof(RRCrtcPtr));
if (!newCrtcs)
return FALSE;
}
else
newCrtcs = NULL;
if (output->crtcs)
xfree (output->crtcs);
memcpy (newCrtcs, crtcs, numCrtcs * sizeof (RRCrtcPtr));
xfree(output->crtcs);
memcpy(newCrtcs, crtcs, numCrtcs * sizeof(RRCrtcPtr));
output->crtcs = newCrtcs;
output->numCrtcs = numCrtcs;
RROutputChanged (output, TRUE);
RROutputChanged(output, TRUE);
return TRUE;
}
Bool
RROutputSetConnection (RROutputPtr output,
CARD8 connection)
RROutputSetConnection(RROutputPtr output, CARD8 connection)
{
if (output->connection == connection)
return TRUE;
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;
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;
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);
rrScrPriv(pScreen);
xRROutputChangeNotifyEvent oe;
RRCrtcPtr crtc = output->crtc;
RRModePtr mode = crtc ? crtc->mode : 0;
......@@ -342,73 +318,67 @@ RRDeliverOutputEvent(ClientPtr client, WindowPtr pWin, RROutputPtr output)
oe.configTimestamp = pScrPriv->lastConfigTime.milliseconds;
oe.window = pWin->drawable.id;
oe.output = output->id;
if (crtc)
{
if (crtc) {
oe.crtc = crtc->id;
oe.mode = mode ? mode->mode.id : None;
oe.rotation = crtc->rotation;
}
else
{
else {
oe.crtc = None;
oe.mode = None;
oe.rotation = RR_Rotate_0;
}
oe.connection = output->connection;
oe.subpixelOrder = output->subpixelOrder;
WriteEventsToClient (client, 1, (xEvent *) &oe);
WriteEventsToClient(client, 1, (xEvent *) &oe);
}
/*
* Destroy a Output at shutdown
*/
void
RROutputDestroy (RROutputPtr output)
RROutputDestroy(RROutputPtr output)
{
FreeResource (output->id, 0);
FreeResource(output->id, 0);
}
static int
RROutputDestroyResource (void * value, XID pid)
RROutputDestroyResource(void *value, XID pid)
{
RROutputPtr output = (RROutputPtr) value;
ScreenPtr pScreen = output->pScreen;
int m;
if (pScreen)
{
if (pScreen) {
rrScrPriv(pScreen);
int i;
for (i = 0; i < pScrPriv->numOutputs; i++)
{
if (pScrPriv->outputs[i] == output)
{
memmove (pScrPriv->outputs + i, pScrPriv->outputs + i + 1,
(pScrPriv->numOutputs - (i + 1)) * sizeof (RROutputPtr));
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)
{
if (output->modes) {
for (m = 0; m < output->numModes; m++)
RRModeDestroy (output->modes[m]);
xfree (output->modes);
RRModeDestroy(output->modes[m]);
xfree(output->modes);
}
for (m = 0; m < output->numUserModes; m++)
RRModeDestroy (output->userModes[m]);
RRModeDestroy(output->userModes[m]);
if (output->userModes)
xfree (output->userModes);
xfree(output->userModes);
if (output->crtcs)
xfree (output->crtcs);
xfree(output->crtcs);
if (output->clones)
xfree (output->clones);
RRDeleteAllOutputProperties (output);
xfree (output);
xfree(output->clones);
RRDeleteAllOutputProperties(output);
xfree(output);
return 1;
}
......@@ -416,19 +386,19 @@ RROutputDestroyResource (void * value, XID pid)
* Initialize output type
*/
Bool
RROutputInit (void)
RROutputInit(void)
{
RROutputType = CreateNewResourceType (RROutputDestroyResource);
RROutputType = CreateNewResourceType(RROutputDestroyResource);
if (!RROutputType)
return FALSE;
RegisterResourceName (RROutputType, "OUTPUT");
RegisterResourceName(RROutputType, "OUTPUT");
return TRUE;
}
#define OutputInfoExtra (SIZEOF(xRRGetOutputInfoReply) - 32)
int
ProcRRGetOutputInfo (ClientPtr client)
ProcRRGetOutputInfo(ClientPtr client)
{
REQUEST(xRRGetOutputInfoReq);
xRRGetOutputInfoReply rep;
......@@ -446,8 +416,7 @@ ProcRRGetOutputInfo (ClientPtr client)
REQUEST_SIZE_MATCH(xRRGetOutputInfoReq);
output = LookupOutput(client, stuff->output, DixReadAccess);
if (!output)
{
if (!output) {
client->errorValue = stuff->output;
return RRErrorBase + BadRROutput;
}
......@@ -473,13 +442,11 @@ ProcRRGetOutputInfo (ClientPtr client)
extraLen = ((output->numCrtcs +
output->numModes + output->numUserModes +
output->numClones +
((rep.nameLength + 3) >> 2)) << 2);
output->numClones + ((rep.nameLength + 3) >> 2)) << 2);
if (extraLen)
{
if (extraLen) {
rep.length += extraLen >> 2;
extra = xalloc (extraLen);
extra = xalloc(extraLen);
if (!extra)
return BadAlloc;
}
......@@ -491,28 +458,25 @@ ProcRRGetOutputInfo (ClientPtr client)
clones = (RROutput *) (modes + output->numModes + output->numUserModes);
name = (char *) (clones + output->numClones);
for (i = 0; i < output->numCrtcs; i++)
{
for (i = 0; i < output->numCrtcs; i++) {
crtcs[i] = output->crtcs[i]->id;
if (client->swapped)
swapl (&crtcs[i], n);
swapl(&crtcs[i], n);
}
for (i = 0; i < output->numModes + output->numUserModes; 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], n);
swapl(&modes[i], n);
}
for (i = 0; i < output->numClones; i++)
{
for (i = 0; i < output->numClones; i++) {
clones[i] = output->clones[i]->id;
if (client->swapped)
swapl (&clones[i], n);
swapl(&clones[i], n);
}
memcpy (name, output->name, output->nameLength);
memcpy(name, output->name, output->nameLength);
if (client->swapped) {
swaps(&rep.sequenceNumber, n);
swapl(&rep.length, n);
......@@ -525,11 +489,10 @@ ProcRRGetOutputInfo (ClientPtr client)
swaps(&rep.nClones, n);
swaps(&rep.nameLength, n);
}
WriteToClient(client, sizeof(xRRGetOutputInfoReply), (char *)&rep);
if (extraLen)
{
WriteToClient (client, extraLen, (char *) extra);
xfree (extra);
WriteToClient(client, sizeof(xRRGetOutputInfoReply), (char *) &rep);
if (extraLen) {
WriteToClient(client, extraLen, (char *) extra);
xfree(extra);
}
return client->noClientException;
......
......@@ -31,7 +31,7 @@
*/
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;
......@@ -39,7 +39,7 @@ RRCrtcContainsPosition (RRCrtcPtr crtc, int x, int y)
if (!mode)
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)
......@@ -51,16 +51,15 @@ RRCrtcContainsPosition (RRCrtcPtr crtc, int x, int y)
* Find the CRTC nearest the specified position, ignoring 'skip'
*/
static void
RRPointerToNearestCrtc (ScreenPtr pScreen, int x, int y, RRCrtcPtr skip)
RRPointerToNearestCrtc(ScreenPtr pScreen, int x, int y, RRCrtcPtr skip)
{
rrScrPriv (pScreen);
rrScrPriv(pScreen);
int c;
RRCrtcPtr nearest = NULL;
int best = 0;
int best_dx = 0, best_dy = 0;
for (c = 0; c < pScrPriv->numCrtcs; c++)
{
for (c = 0; c < pScrPriv->numCrtcs; c++) {
RRCrtcPtr crtc = pScrPriv->crtcs[c];
RRModePtr mode = crtc->mode;
int dx, dy;
......@@ -72,7 +71,7 @@ RRPointerToNearestCrtc (ScreenPtr pScreen, int x, int y, RRCrtcPtr skip)
if (crtc == skip)
continue;
RRCrtcGetScanoutSize (crtc, &scan_width, &scan_height);
RRCrtcGetScanoutSize(crtc, &scan_width, &scan_height);
if (x < crtc->x)
dx = crtc->x - x;
......@@ -87,8 +86,7 @@ RRPointerToNearestCrtc (ScreenPtr pScreen, int x, int y, RRCrtcPtr skip)
else
dy = 0;
dist = dx + dy;
if (!nearest || dist < best)
{
if (!nearest || dist < best) {
nearest = crtc;
best_dx = dx;
best_dy = dy;
......@@ -100,23 +98,21 @@ RRPointerToNearestCrtc (ScreenPtr pScreen, int x, int y, RRCrtcPtr skip)
}
void
RRPointerMoved (ScreenPtr pScreen, int x, int y)
RRPointerMoved(ScreenPtr pScreen, int x, int y)
{
rrScrPriv (pScreen);
rrScrPriv(pScreen);
RRCrtcPtr pointerCrtc = pScrPriv->pointerCrtc;
int c;
/* Check last known CRTC */
if (pointerCrtc && RRCrtcContainsPosition (pointerCrtc, x, y))
if (pointerCrtc && RRCrtcContainsPosition(pointerCrtc, x, y))
return;
/* Check all CRTCs */
for (c = 0; c < pScrPriv->numCrtcs; c++)
{
for (c = 0; c < pScrPriv->numCrtcs; c++) {
RRCrtcPtr crtc = pScrPriv->crtcs[c];
if (RRCrtcContainsPosition (crtc, x, y))
{
if (RRCrtcContainsPosition(crtc, x, y)) {
/* Remember containing CRTC */
pScrPriv->pointerCrtc = crtc;
return;
......@@ -124,7 +120,7 @@ RRPointerMoved (ScreenPtr pScreen, int x, int y)
}
/* None contain pointer, find nearest */
RRPointerToNearestCrtc (pScreen, x, y, pointerCrtc);
RRPointerToNearestCrtc(pScreen, x, y, pointerCrtc);
}
/*
......@@ -132,14 +128,14 @@ RRPointerMoved (ScreenPtr pScreen, int x, int y)
* CRTC
*/
void
RRPointerScreenConfigured (ScreenPtr pScreen)
RRPointerScreenConfigured(ScreenPtr pScreen)
{
WindowPtr pRoot = GetCurrentRootWindow ();
WindowPtr pRoot = GetCurrentRootWindow();
ScreenPtr pCurrentScreen = pRoot ? pRoot->drawable.pScreen : NULL;
int x, y;
if (pScreen != pCurrentScreen)
return;
GetSpritePosition (&x, &y);
RRPointerToNearestCrtc (pScreen, x, y, NULL);
GetSpritePosition(&x, &y);
RRPointerToNearestCrtc(pScreen, x, y, NULL);
}
......@@ -25,19 +25,18 @@
#include "swaprep.h"
static void
RRDeliverEvent (ScreenPtr pScreen, xEvent *event, CARD32 mask)
RRDeliverEvent(ScreenPtr pScreen, xEvent *event, CARD32 mask)
{
}
void
RRDeleteAllOutputProperties (RROutputPtr output)
RRDeleteAllOutputProperties(RROutputPtr output)
{
RRPropertyPtr prop, next;
xRROutputPropertyNotifyEvent event;
for (prop = output->properties; prop; prop = next)
{
for (prop = output->properties; prop; prop = next) {
next = prop->next;
event.type = RREventBase + RRNotify;
event.subCode = RRNotify_OutputProperty;
......@@ -45,7 +44,8 @@ RRDeleteAllOutputProperties (RROutputPtr output)
event.state = PropertyDelete;
event.atom = prop->propertyName;
event.timestamp = currentTime.milliseconds;
RRDeliverEvent (output->pScreen, (xEvent *) &event, RROutputPropertyNotifyMask);
RRDeliverEvent(output->pScreen, (xEvent *) &event,
RROutputPropertyNotifyMask);
if (prop->current.data)
xfree(prop->current.data);
if (prop->pending.data)
......@@ -55,7 +55,7 @@ RRDeleteAllOutputProperties (RROutputPtr output)
}
static void
RRInitOutputPropertyValue (RRPropertyValuePtr property_value)
RRInitOutputPropertyValue(RRPropertyValuePtr property_value)
{
property_value->type = None;
property_value->format = 0;
......@@ -64,11 +64,11 @@ RRInitOutputPropertyValue (RRPropertyValuePtr property_value)
}
static RRPropertyPtr
RRCreateOutputProperty (Atom property)
RRCreateOutputProperty(Atom property)
{
RRPropertyPtr prop;
prop = (RRPropertyPtr)xalloc(sizeof(RRPropertyRec));
prop = (RRPropertyPtr) xalloc(sizeof(RRPropertyRec));
if (!prop)
return NULL;
prop->next = NULL;
......@@ -78,16 +78,16 @@ 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;
}
static void
RRDestroyOutputProperty (RRPropertyPtr prop)
RRDestroyOutputProperty(RRPropertyPtr prop)
{
if (prop->valid_values)
xfree (prop->valid_values);
xfree(prop->valid_values);
if (prop->current.data)
xfree(prop->current.data);
if (prop->pending.data)
......@@ -96,7 +96,7 @@ RRDestroyOutputProperty (RRPropertyPtr prop)
}
void
RRDeleteOutputProperty (RROutputPtr output, Atom property)
RRDeleteOutputProperty(RROutputPtr output, Atom property)
{
RRPropertyPtr prop, *prev;
xRROutputPropertyNotifyEvent event;
......@@ -104,8 +104,7 @@ RRDeleteOutputProperty (RROutputPtr output, Atom property)
for (prev = &output->properties; (prop = *prev); prev = &(prop->next))
if (prop->propertyName == property)
break;
if (prop)
{
if (prop) {
*prev = prop->next;
event.type = RREventBase + RRNotify;
event.subCode = RRNotify_OutputProperty;
......@@ -113,15 +112,16 @@ RRDeleteOutputProperty (RROutputPtr output, Atom property)
event.state = PropertyDelete;
event.atom = prop->propertyName;
event.timestamp = currentTime.milliseconds;
RRDeliverEvent (output->pScreen, (xEvent *) &event, RROutputPropertyNotifyMask);
RRDestroyOutputProperty (prop);
RRDeliverEvent(output->pScreen, (xEvent *) &event,
RROutputPropertyNotifyMask);
RRDestroyOutputProperty(prop);
}
}
int
RRChangeOutputProperty (RROutputPtr output, Atom property, Atom type,
RRChangeOutputProperty(RROutputPtr output, Atom property, Atom type,
int format, int mode, unsigned long len,
void * value, Bool sendevent, Bool pending)
void *value, Bool sendevent, Bool pending)
{
RRPropertyPtr prop;
xRROutputPropertyNotifyEvent event;
......@@ -136,12 +136,11 @@ RRChangeOutputProperty (RROutputPtr output, Atom property, Atom type,
size_in_bytes = format >> 3;
/* first see if property already exists */
prop = RRQueryOutputProperty (output, property);
if (!prop) /* just add to list */
{
prop = RRCreateOutputProperty (property);
prop = RRQueryOutputProperty(output, property);
if (!prop) { /* just add to list */
prop = RRCreateOutputProperty(property);
if (!prop)
return(BadAlloc);
return (BadAlloc);
add = TRUE;
mode = PropModeReplace;
}
......@@ -156,25 +155,23 @@ RRChangeOutputProperty (RROutputPtr output, Atom property, Atom type,
"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;
else
total_len = prop_value->size + len;
if (mode == PropModeReplace || len > 0)
{
if (mode == PropModeReplace || len > 0) {
void *new_data = NULL, *old_data = NULL;
total_size = total_len * size_in_bytes;
new_value.data = (void *)xalloc (total_size);
if (!new_value.data && total_size)
{
new_value.data = (void *) xalloc(total_size);
if (!new_value.data && total_size) {
if (add)
RRDestroyOutputProperty (prop);
RRDestroyOutputProperty(prop);
return BadAlloc;
}
new_value.size = len;
......@@ -198,31 +195,28 @@ RRChangeOutputProperty (RROutputPtr output, Atom property, Atom type,
break;
}
if (new_data)
memcpy ((char *) new_data, (char *) value, len * size_in_bytes);
memcpy((char *) new_data, (char *) value, len * size_in_bytes);
if (old_data)
memcpy ((char *) old_data, (char *) prop_value->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))
{
prop->propertyName, &new_value)) {
if (new_value.data)
xfree (new_value.data);
xfree(new_value.data);
return (BadValue);
}
if (prop_value->data)
xfree (prop_value->data);
xfree(prop_value->data);
*prop_value = new_value;
}
else if (len == 0)
{
else if (len == 0) {
/* do nothing */
}
if (add)
{
if (add) {
prop->next = output->properties;
output->properties = prop;
}
......@@ -230,21 +224,21 @@ RRChangeOutputProperty (RROutputPtr output, Atom property, Atom type,
if (pending && prop->is_pending)
output->pendingProperties = TRUE;
if (sendevent)
{
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;
RRDeliverEvent (output->pScreen, (xEvent *) &event, RROutputPropertyNotifyMask);
RRDeliverEvent(output->pScreen, (xEvent *) &event,
RROutputPropertyNotifyMask);
}
return(Success);
return (Success);
}
Bool
RRPostPendingProperties (RROutputPtr output)
RRPostPendingProperties(RROutputPtr output)
{
RRPropertyValuePtr pending_value;
RRPropertyValuePtr current_value;
......@@ -255,8 +249,7 @@ RRPostPendingProperties (RROutputPtr output)
return TRUE;
output->pendingProperties = FALSE;
for (property = output->properties; property; property = property->next)
{
for (property = output->properties; property; property = property->next) {
/* Skip non-pending properties */
if (!property->is_pending)
continue;
......@@ -271,22 +264,21 @@ RRPostPendingProperties (RROutputPtr output)
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,
!memcmp(pending_value->data, current_value->data,
pending_value->size))
continue;
if (RRChangeOutputProperty (output, property->propertyName,
if (RRChangeOutputProperty(output, property->propertyName,
pending_value->type, pending_value->format,
PropModeReplace, pending_value->size,
pending_value->data, TRUE,
FALSE) != Success)
pending_value->data, TRUE, FALSE) != Success)
ret = FALSE;
}
return ret;
}
RRPropertyPtr
RRQueryOutputProperty (RROutputPtr output, Atom property)
RRQueryOutputProperty(RROutputPtr output, Atom property)
{
RRPropertyPtr prop;
......@@ -297,9 +289,9 @@ RRQueryOutputProperty (RROutputPtr output, Atom property)
}
RRPropertyValuePtr
RRGetOutputProperty (RROutputPtr output, Atom property, Bool pending)
RRGetOutputProperty(RROutputPtr output, Atom property, Bool pending)
{
RRPropertyPtr prop = RRQueryOutputProperty (output, property);
RRPropertyPtr prop = RRQueryOutputProperty(output, property);
if (!prop)
return NULL;
......@@ -310,22 +302,22 @@ RRGetOutputProperty (RROutputPtr output, Atom property, Bool pending)
}
int
RRConfigureOutputProperty (RROutputPtr output, Atom property,
RRConfigureOutputProperty(RROutputPtr output, Atom property,
Bool pending, Bool range, Bool immutable,
int num_values, INT32 *values)
{
RRPropertyPtr prop = RRQueryOutputProperty (output, property);
RRPropertyPtr prop = RRQueryOutputProperty(output, property);
Bool add = FALSE;
INT32 *new_values;
if (!prop) {
prop = RRCreateOutputProperty(property);
if (!prop)
{
prop = RRCreateOutputProperty (property);
if (!prop)
return(BadAlloc);
return (BadAlloc);
add = TRUE;
} else if (prop->immutable && !immutable)
return(BadAccess);
}
else if (prop->immutable && !immutable)
return (BadAccess);
/*
* ranges must have even number of values
......@@ -333,21 +325,20 @@ RRConfigureOutputProperty (RROutputPtr output, Atom property,
if (range && (num_values & 1))
return BadMatch;
new_values = xalloc (num_values * sizeof (INT32));
new_values = xalloc(num_values * sizeof(INT32));
if (!new_values && num_values)
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)
{
if (prop->is_pending && !pending) {
if (prop->pending.data)
xfree (prop->pending.data);
RRInitOutputPropertyValue (&prop->pending);
xfree(prop->pending.data);
RRInitOutputPropertyValue(&prop->pending);
}
prop->is_pending = pending;
......@@ -355,7 +346,7 @@ RRConfigureOutputProperty (RROutputPtr output, Atom property,
prop->immutable = immutable;
prop->num_valid = num_values;
if (prop->valid_values)
xfree (prop->valid_values);
xfree(prop->valid_values);
prop->valid_values = new_values;
if (add) {
......@@ -367,7 +358,7 @@ RRConfigureOutputProperty (RROutputPtr output, Atom property,
}
int
ProcRRListOutputProperties (ClientPtr client)
ProcRRListOutputProperties(ClientPtr client)
{
REQUEST(xRRListOutputPropertiesReq);
Atom *pAtoms = NULL, *temppAtoms;
......@@ -378,7 +369,7 @@ ProcRRListOutputProperties (ClientPtr client)
REQUEST_SIZE_MATCH(xRRListOutputPropertiesReq);
output = LookupOutput (client, stuff->output, DixReadAccess);
output = LookupOutput(client, stuff->output, DixReadAccess);
if (!output)
return RRErrorBase + BadRROutput;
......@@ -386,36 +377,35 @@ ProcRRListOutputProperties (ClientPtr client)
for (prop = output->properties; prop; prop = prop->next)
numProps++;
if (numProps)
if(!(pAtoms = (Atom *)xalloc(numProps * sizeof(Atom))))
return(BadAlloc);
if (!(pAtoms = (Atom *) xalloc(numProps * sizeof(Atom))))
return (BadAlloc);
rep.type = X_Reply;
rep.length = (numProps * sizeof(Atom)) >> 2;
rep.sequenceNumber = client->sequence;
rep.nAtoms = numProps;
if (client->swapped)
{
if (client->swapped) {
int n;
swaps (&rep.sequenceNumber, n);
swapl (&rep.length, n);
swaps (&rep.nAtoms, n);
swaps(&rep.sequenceNumber, n);
swapl(&rep.length, n);
swaps(&rep.nAtoms, n);
}
temppAtoms = pAtoms;
for (prop = output->properties; prop; prop = prop->next)
*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);
xfree(pAtoms);
}
return(client->noClientException);
return (client->noClientException);
}
int
ProcRRQueryOutputProperty (ClientPtr client)
ProcRRQueryOutputProperty(ClientPtr client)
{
REQUEST(xRRQueryOutputPropertyReq);
xRRQueryOutputPropertyReply rep;
......@@ -425,12 +415,12 @@ ProcRRQueryOutputProperty (ClientPtr client)
REQUEST_SIZE_MATCH(xRRQueryOutputPropertyReq);
output = LookupOutput (client, stuff->output, DixReadAccess);
output = LookupOutput(client, stuff->output, DixReadAccess);
if (!output)
return RRErrorBase + BadRROutput;
prop = RRQueryOutputProperty (output, stuff->property);
prop = RRQueryOutputProperty(output, stuff->property);
if (!prop)
return BadName;
......@@ -445,26 +435,25 @@ ProcRRQueryOutputProperty (ClientPtr client)
rep.pending = prop->is_pending;
rep.range = prop->range;
rep.immutable = prop->immutable;
if (client->swapped)
{
if (client->swapped) {
int n;
swaps (&rep.sequenceNumber, n);
swapl (&rep.length, n);
swaps(&rep.sequenceNumber, n);
swapl(&rep.length, n);
}
WriteToClient (client, sizeof (xRRQueryOutputPropertyReply), (char*)&rep);
if (prop->num_valid)
{
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);
xfree(extra);
}
return(client->noClientException);
return (client->noClientException);
}
int
ProcRRConfigureOutputProperty (ClientPtr client)
ProcRRConfigureOutputProperty(ClientPtr client)
{
REQUEST(xRRConfigureOutputPropertyReq);
RROutputPtr output;
......@@ -472,20 +461,19 @@ ProcRRConfigureOutputProperty (ClientPtr client)
REQUEST_AT_LEAST_SIZE(xRRConfigureOutputPropertyReq);
output = LookupOutput (client, stuff->output, DixReadAccess);
output = LookupOutput(client, stuff->output, DixReadAccess);
if (!output)
return RRErrorBase + BadRROutput;
num_valid = stuff->length - (sizeof (xRRConfigureOutputPropertyReq) >> 2);
return RRConfigureOutputProperty (output, stuff->property,
num_valid = stuff->length - (sizeof(xRRConfigureOutputPropertyReq) >> 2);
return RRConfigureOutputProperty(output, stuff->property,
stuff->pending, stuff->range,
FALSE, num_valid,
(INT32 *) (stuff + 1));
FALSE, num_valid, (INT32 *) (stuff + 1));
}
int
ProcRRChangeOutputProperty (ClientPtr client)
ProcRRChangeOutputProperty(ClientPtr client)
{
REQUEST(xRRChangeOutputPropertyReq);
RROutputPtr output;
......@@ -500,41 +488,38 @@ ProcRRChangeOutputProperty (ClientPtr client)
format = stuff->format;
mode = stuff->mode;
if ((mode != PropModeReplace) && (mode != PropModeAppend) &&
(mode != PropModePrepend))
{
(mode != PropModePrepend)) {
client->errorValue = mode;
return BadValue;
}
if ((format != 8) && (format != 16) && (format != 32))
{
if ((format != 8) && (format != 16) && (format != 32)) {
client->errorValue = format;
return BadValue;
}
len = stuff->nUnits;
if (len > ((0xffffffff - sizeof(xChangePropertyReq)) >> 2))
return BadLength;
sizeInBytes = format>>3;
sizeInBytes = format >> 3;
totalSize = len * sizeInBytes;
REQUEST_FIXED_SIZE(xRRChangeOutputPropertyReq, totalSize);
output = LookupOutput (client, stuff->output, DixWriteAccess);
output = LookupOutput(client, stuff->output, DixWriteAccess);
if (!output)
return RRErrorBase + BadRROutput;
if (!ValidAtom(stuff->property))
{
if (!ValidAtom(stuff->property)) {
client->errorValue = stuff->property;
return(BadAtom);
return (BadAtom);
}
if (!ValidAtom(stuff->type))
{
if (!ValidAtom(stuff->type)) {
client->errorValue = stuff->type;
return(BadAtom);
return (BadAtom);
}
err = RRChangeOutputProperty(output, stuff->property,
stuff->type, (int)format,
(int)mode, len, (void *)&stuff[1], TRUE, TRUE);
stuff->type, (int) format,
(int) mode, len, (void *) &stuff[1], TRUE,
TRUE);
if (err != Success)
return err;
else
......@@ -542,30 +527,28 @@ ProcRRChangeOutputProperty (ClientPtr client)
}
int
ProcRRDeleteOutputProperty (ClientPtr client)
ProcRRDeleteOutputProperty(ClientPtr client)
{
REQUEST(xRRDeleteOutputPropertyReq);
RROutputPtr output;
REQUEST_SIZE_MATCH(xRRDeleteOutputPropertyReq);
UpdateCurrentTime();
output = LookupOutput (client, stuff->output, DixWriteAccess);
output = LookupOutput(client, stuff->output, DixWriteAccess);
if (!output)
return RRErrorBase + BadRROutput;
if (!ValidAtom(stuff->property))
{
if (!ValidAtom(stuff->property)) {
client->errorValue = stuff->property;
return (BadAtom);
}
RRDeleteOutputProperty(output, stuff->property);
return client->noClientException;
}
int
ProcRRGetOutputProperty (ClientPtr client)
ProcRRGetOutputProperty(ClientPtr client)
{
REQUEST(xRRGetOutputPropertyReq);
RRPropertyPtr prop, *prev;
......@@ -578,26 +561,22 @@ ProcRRGetOutputProperty (ClientPtr client)
REQUEST_SIZE_MATCH(xRRGetOutputPropertyReq);
if (stuff->delete)
UpdateCurrentTime();
output = LookupOutput (client, stuff->output,
stuff->delete ? DixWriteAccess :
DixReadAccess);
output = LookupOutput(client, stuff->output,
stuff->delete ? DixWriteAccess : DixReadAccess);
if (!output)
return RRErrorBase + BadRROutput;
if (!ValidAtom(stuff->property))
{
if (!ValidAtom(stuff->property)) {
client->errorValue = stuff->property;
return(BadAtom);
return (BadAtom);
}
if ((stuff->delete != xTrue) && (stuff->delete != xFalse))
{
if ((stuff->delete != xTrue) && (stuff->delete != xFalse)) {
client->errorValue = stuff->delete;
return(BadValue);
return (BadValue);
}
if ((stuff->type != AnyPropertyType) && !ValidAtom(stuff->type))
{
if ((stuff->type != AnyPropertyType) && !ValidAtom(stuff->type)) {
client->errorValue = stuff->type;
return(BadAtom);
return (BadAtom);
}
for (prev = &output->properties; (prop = *prev); prev = &prop->next)
......@@ -606,8 +585,7 @@ ProcRRGetOutputProperty (ClientPtr client)
reply.type = X_Reply;
reply.sequenceNumber = client->sequence;
if (!prop)
{
if (!prop) {
reply.nItems = 0;
reply.length = 0;
reply.bytesAfter = 0;
......@@ -623,7 +601,7 @@ ProcRRGetOutputProperty (ClientPtr client)
swapl(&reply.nItems, n);
}
WriteToClient(client, sizeof(xRRGetOutputPropertyReply), &reply);
return(client->noClientException);
return (client->noClientException);
}
if (prop->immutable && stuff->delete)
......@@ -637,10 +615,8 @@ ProcRRGetOutputProperty (ClientPtr client)
/* 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))
)
{
if (((stuff->type != prop_value->type) && (stuff->type != AnyPropertyType))
) {
reply.bytesAfter = prop_value->size;
reply.format = prop_value->format;
reply.length = 0;
......@@ -656,20 +632,19 @@ ProcRRGetOutputProperty (ClientPtr client)
swapl(&reply.nItems, n);
}
WriteToClient(client, sizeof(xRRGetOutputPropertyReply), &reply);
return(client->noClientException);
return (client->noClientException);
}
/*
* Return type, format, value to client
*/
n = (prop_value->format/8) * prop_value->size; /* size (bytes) of prop */
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 (n < ind)
{
if (n < ind) {
client->errorValue = stuff->longOffset;
return BadValue;
}
......@@ -690,8 +665,7 @@ ProcRRGetOutputProperty (ClientPtr client)
reply.nItems = 0;
reply.propertyType = prop_value->type;
if (stuff->delete && (reply.bytesAfter == 0))
{
if (stuff->delete && (reply.bytesAfter == 0)) {
xRROutputPropertyNotifyEvent event;
event.type = RREventBase + RRNotify;
......@@ -700,7 +674,8 @@ ProcRRGetOutputProperty (ClientPtr client)
event.state = PropertyDelete;
event.atom = prop->propertyName;
event.timestamp = currentTime.milliseconds;
RRDeliverEvent (output->pScreen, (xEvent *) &event, RROutputPropertyNotifyMask);
RRDeliverEvent(output->pScreen, (xEvent *) &event,
RROutputPropertyNotifyMask);
}
if (client->swapped) {
......@@ -713,24 +688,26 @@ ProcRRGetOutputProperty (ClientPtr client)
swapl(&reply.nItems, n);
}
WriteToClient(client, sizeof(xGenericReply), &reply);
if (len)
{
memcpy(extra, (char *)prop_value->data + ind, len);
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;
case 32:
client->pSwapReplyFunc = (ReplySwapPtr) CopySwap32Write;
break;
case 16:
client->pSwapReplyFunc = (ReplySwapPtr) CopySwap16Write;
break;
default:
client->pSwapReplyFunc = (ReplySwapPtr) WriteToClient;
break;
}
WriteSwappedDataToClient(client, len,
extra);
WriteSwappedDataToClient(client, len, extra);
xfree(extra);
}
if (stuff->delete && (reply.bytesAfter == 0))
{ /* delete the Property */
if (stuff->delete && (reply.bytesAfter == 0)) { /* delete the Property */
*prev = prop->next;
RRDestroyOutputProperty (prop);
RRDestroyOutputProperty(prop);
}
return(client->noClientException);
return (client->noClientException);
}
......@@ -41,17 +41,17 @@
extern char *ConnectionInfo;
static int padlength[4] = {0, 3, 2, 1};
static 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;
......@@ -63,22 +63,19 @@ RREditConnectionInfo (ScreenPtr pScreen)
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]);
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));
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));
depth->nVisuals * sizeof(xVisualType));
}
root = (xWindowRoot *) ((char *) depth);
screen++;
......@@ -90,7 +87,7 @@ RREditConnectionInfo (ScreenPtr pScreen)
}
void
RRSendConfigNotify (ScreenPtr pScreen)
RRSendConfigNotify(ScreenPtr pScreen)
{
WindowPtr pWin = WindowTable[pScreen->myNum];
xEvent event;
......@@ -105,15 +102,15 @@ RRSendConfigNotify (ScreenPtr pScreen)
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);
rrScrPriv(pScreen);
xRRScreenChangeNotifyEvent se;
RRCrtcPtr crtc = pScrPriv->numCrtcs ? pScrPriv->crtcs[0] : NULL;
WindowPtr pRoot = WindowTable[pScreen->myNum];
......@@ -126,27 +123,28 @@ RRDeliverScreenEvent (ClientPtr client, WindowPtr pWin, ScreenPtr pScreen)
se.root = pRoot->drawable.id;
se.window = pWin->drawable.id;
#ifdef RENDER
se.subpixelOrder = PictureGetSubpixelOrder (pScreen);
se.subpixelOrder = PictureGetSubpixelOrder(pScreen);
#else
se.subpixelOrder = SubPixelUnknown;
#endif
se.sequenceNumber = client->sequence;
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 {
}
else {
se.widthInPixels = pScreen->width;
se.heightInPixels = pScreen->height;
se.widthInMillimeters = pScreen->mmWidth;
se.heightInMillimeters = pScreen->mmHeight;
}
WriteEventsToClient (client, 1, (xEvent *) &se);
WriteEventsToClient(client, 1, (xEvent *) &se);
}
/*
......@@ -155,7 +153,7 @@ RRDeliverScreenEvent (ClientPtr client, WindowPtr pWin, ScreenPtr pScreen)
* the size of the screen
*/
void
RRScreenSizeNotify (ScreenPtr pScreen)
RRScreenSizeNotify(ScreenPtr pScreen)
{
rrScrPriv(pScreen);
/*
......@@ -175,40 +173,34 @@ RRScreenSizeNotify (ScreenPtr pScreen)
pScrPriv->changed = TRUE;
/* pScrPriv->sizeChanged = TRUE; */
RRTellChanged (pScreen);
RRSendConfigNotify (pScreen);
RREditConnectionInfo (pScreen);
RRTellChanged(pScreen);
RRSendConfigNotify(pScreen);
RREditConnectionInfo(pScreen);
RRPointerScreenConfigured (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)
{
if (pScrPriv->rrScreenSetSize) {
return (*pScrPriv->rrScreenSetSize) (pScreen,
width, height,
mmWidth, mmHeight);
width, height, mmWidth, mmHeight);
}
#endif
#if RANDR_10_INTERFACE
if (pScrPriv->rrSetConfig)
{
if (pScrPriv->rrSetConfig) {
return TRUE; /* can't set size separately */
}
#endif
......@@ -219,7 +211,7 @@ RRScreenSizeSet (ScreenPtr pScreen,
* Retrieve valid screen size range
*/
int
ProcRRGetScreenSizeRange (ClientPtr client)
ProcRRGetScreenSizeRange(ClientPtr client)
{
REQUEST(xRRGetScreenSizeRangeReq);
xRRGetScreenSizeRangeReply rep;
......@@ -229,12 +221,12 @@ ProcRRGetScreenSizeRange (ClientPtr client)
int rc;
REQUEST_SIZE_MATCH(xRRGetScreenSizeRangeReq);
#ifndef NXAGENT_SERVER
#ifndef NXAGENT_SERVER
rc = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess);
#else
#else
pWin = SecurityLookupWindow(stuff->window, client, SecurityReadAccess);
rc = pWin ? Success : BadWindow;
#endif
#endif
if (rc != Success)
return rc;
......@@ -246,22 +238,19 @@ ProcRRGetScreenSizeRange (ClientPtr client)
rep.sequenceNumber = client->sequence;
rep.length = 0;
if (pScrPriv)
{
if (!RRGetInfo (pScreen))
if (pScrPriv) {
if (!RRGetInfo(pScreen))
return BadAlloc;
rep.minWidth = pScrPriv->minWidth;
rep.minHeight = pScrPriv->minHeight;
rep.maxWidth = pScrPriv->maxWidth;
rep.maxHeight = pScrPriv->maxHeight;
}
else
{
else {
rep.maxWidth = rep.minWidth = pScreen->width;
rep.maxHeight = rep.minHeight = pScreen->height;
}
if (client->swapped)
{
if (client->swapped) {
int n;
swaps(&rep.sequenceNumber, n);
......@@ -271,12 +260,12 @@ ProcRRGetScreenSizeRange (ClientPtr client)
swaps(&rep.maxWidth, n);
swaps(&rep.maxHeight, n);
}
WriteToClient(client, sizeof(xRRGetScreenSizeRangeReply), (char *)&rep);
WriteToClient(client, sizeof(xRRGetScreenSizeRangeReply), (char *) &rep);
return (client->noClientException);
}
int
ProcRRSetScreenSize (ClientPtr client)
ProcRRSetScreenSize(ClientPtr client)
{
REQUEST(xRRSetScreenSizeReq);
WindowPtr pWin;
......@@ -285,40 +274,36 @@ ProcRRSetScreenSize (ClientPtr client)
int i, rc;
REQUEST_SIZE_MATCH(xRRSetScreenSizeReq);
#ifndef NXAGENT_SERVER
#ifndef NXAGENT_SERVER
rc = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess);
#else
#else
pWin = SecurityLookupWindow(stuff->window, client, SecurityReadAccess);
rc = pWin ? Success : BadWindow;
#endif
#endif
if (rc != Success)
return rc;
pScreen = pWin->drawable.pScreen;
pScrPriv = rrGetScrPriv(pScreen);
if (stuff->width < pScrPriv->minWidth || pScrPriv->maxWidth < stuff->width)
{
if (stuff->width < pScrPriv->minWidth || pScrPriv->maxWidth < stuff->width) {
client->errorValue = stuff->width;
return BadValue;
}
if (stuff->height < pScrPriv->minHeight ||
pScrPriv->maxHeight < stuff->height)
{
pScrPriv->maxHeight < stuff->height) {
client->errorValue = stuff->height;
return BadValue;
}
for (i = 0; i < pScrPriv->numCrtcs; i++)
{
for (i = 0; i < pScrPriv->numCrtcs; i++) {
RRCrtcPtr crtc = pScrPriv->crtcs[i];
RRModePtr mode = crtc->mode;
if (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)
{
if (rotation == RR_Rotate_90 || rotation == RR_Rotate_270) {
source_width = mode->mode.height;
source_height = mode->mode.width;
}
......@@ -328,23 +313,21 @@ ProcRRSetScreenSize (ClientPtr client)
return BadMatch;
}
}
if (stuff->widthInMillimeters == 0 || stuff->heightInMillimeters == 0)
{
if (stuff->widthInMillimeters == 0 || stuff->heightInMillimeters == 0) {
client->errorValue = 0;
return BadValue;
}
if (!RRScreenSizeSet (pScreen,
if (!RRScreenSizeSet(pScreen,
stuff->width, stuff->height,
stuff->widthInMillimeters,
stuff->heightInMillimeters))
{
stuff->heightInMillimeters)) {
return BadMatch;
}
return Success;
}
int
ProcRRGetScreenResources (ClientPtr client)
ProcRRGetScreenResources(ClientPtr client)
{
REQUEST(xRRGetScreenResourcesReq);
xRRGetScreenResourcesReply rep;
......@@ -360,12 +343,12 @@ ProcRRGetScreenResources (ClientPtr client)
CARD8 *names;
REQUEST_SIZE_MATCH(xRRGetScreenResourcesReq);
#ifndef NXAGENT_SERVER
#ifndef NXAGENT_SERVER
rc = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess);
#else
#else
pWin = SecurityLookupWindow(stuff->window, client, SecurityReadAccess);
rc = pWin ? Success : BadWindow;
#endif
#endif
if (rc != Success)
return rc;
......@@ -374,11 +357,10 @@ ProcRRGetScreenResources (ClientPtr client)
rep.pad = 0;
if (pScrPriv)
if (!RRGetInfo (pScreen))
if (!RRGetInfo(pScreen))
return BadAlloc;
if (!pScrPriv)
{
if (!pScrPriv) {
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
rep.length = 0;
......@@ -391,12 +373,11 @@ ProcRRGetScreenResources (ClientPtr client)
extra = NULL;
extraLen = 0;
}
else
{
else {
RRModePtr *modes;
int num_modes;
modes = RRModesForScreen (pScreen, &num_modes);
modes = RRModesForScreen(pScreen, &num_modes);
if (!modes)
return BadAlloc;
......@@ -419,12 +400,10 @@ ProcRRGetScreenResources (ClientPtr client)
((rep.nbytesNames + 3) >> 2));
extraLen = rep.length << 2;
if (extraLen)
{
extra = xalloc (extraLen);
if (!extra)
{
xfree (modes);
if (extraLen) {
extra = xalloc(extraLen);
if (!extra) {
xfree(modes);
return BadAlloc;
}
}
......@@ -436,46 +415,42 @@ ProcRRGetScreenResources (ClientPtr client)
modeinfos = (xRRModeInfo *) (outputs + pScrPriv->numOutputs);
names = (CARD8 *) (modeinfos + num_modes);
for (i = 0; i < pScrPriv->numCrtcs; i++)
{
for (i = 0; i < pScrPriv->numCrtcs; i++) {
crtcs[i] = pScrPriv->crtcs[i]->id;
if (client->swapped)
swapl (&crtcs[i], n);
swapl(&crtcs[i], n);
}
for (i = 0; i < pScrPriv->numOutputs; i++)
{
for (i = 0; i < pScrPriv->numOutputs; i++) {
outputs[i] = pScrPriv->outputs[i]->id;
if (client->swapped)
swapl (&outputs[i], n);
swapl(&outputs[i], n);
}
for (i = 0; i < num_modes; i++)
{
for (i = 0; i < num_modes; i++) {
RRModePtr mode = modes[i];
modeinfos[i] = mode->mode;
if (client->swapped)
{
swapl (&modeinfos[i].id, n);
swaps (&modeinfos[i].width, n);
swaps (&modeinfos[i].height, n);
swapl (&modeinfos[i].dotClock, n);
swaps (&modeinfos[i].hSyncStart, n);
swaps (&modeinfos[i].hSyncEnd, n);
swaps (&modeinfos[i].hTotal, n);
swaps (&modeinfos[i].hSkew, n);
swaps (&modeinfos[i].vSyncStart, n);
swaps (&modeinfos[i].vSyncEnd, n);
swaps (&modeinfos[i].vTotal, n);
swaps (&modeinfos[i].nameLength, n);
swapl (&modeinfos[i].modeFlags, n);
}
memcpy (names, mode->name,
mode->mode.nameLength);
if (client->swapped) {
swapl(&modeinfos[i].id, n);
swaps(&modeinfos[i].width, n);
swaps(&modeinfos[i].height, n);
swapl(&modeinfos[i].dotClock, n);
swaps(&modeinfos[i].hSyncStart, n);
swaps(&modeinfos[i].hSyncEnd, n);
swaps(&modeinfos[i].hTotal, n);
swaps(&modeinfos[i].hSkew, n);
swaps(&modeinfos[i].vSyncStart, n);
swaps(&modeinfos[i].vSyncEnd, n);
swaps(&modeinfos[i].vTotal, n);
swaps(&modeinfos[i].nameLength, n);
swapl(&modeinfos[i].modeFlags, n);
}
memcpy(names, mode->name, mode->mode.nameLength);
names += mode->mode.nameLength;
}
xfree (modes);
assert (((((char *) names - (char *) extra) + 3) >> 2) == rep.length);
xfree(modes);
assert(((((char *) names - (char *) extra) + 3) >> 2) == rep.length);
}
if (client->swapped) {
......@@ -488,11 +463,10 @@ ProcRRGetScreenResources (ClientPtr client)
swaps(&rep.nModes, n);
swaps(&rep.nbytesNames, n);
}
WriteToClient(client, sizeof(xRRGetScreenResourcesReply), (char *)&rep);
if (extraLen)
{
WriteToClient (client, extraLen, (char *) extra);
xfree (extra);
WriteToClient(client, sizeof(xRRGetScreenResourcesReply), (char *) &rep);
if (extraLen) {
WriteToClient(client, extraLen, (char *) extra);
xfree(extra);
}
return client->noClientException;
}
......@@ -509,7 +483,7 @@ typedef struct _RR10Data {
* Convert 1.2 monitor data into 1.0 screen data
*/
static RR10DataPtr
RR10GetData (ScreenPtr pScreen, RROutputPtr output)
RR10GetData(ScreenPtr pScreen, RROutputPtr output)
{
RR10DataPtr data;
RRScreenSizePtr size;
......@@ -521,16 +495,15 @@ RR10GetData (ScreenPtr pScreen, RROutputPtr output)
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;
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;
......@@ -540,9 +513,9 @@ RR10GetData (ScreenPtr pScreen, RROutputPtr output)
/*
* find modes not yet listed
*/
for (o = 0; o < output->numModes + output->numUserModes; o++)
{
if (used[o]) continue;
for (o = 0; o < output->numModes + output->numUserModes; o++) {
if (used[o])
continue;
if (o < output->numModes)
mode = output->modes[o];
......@@ -556,7 +529,8 @@ RR10GetData (ScreenPtr pScreen, RROutputPtr output)
if (output->mmWidth && output->mmHeight) {
size[l].mmWidth = output->mmWidth;
size[l].mmHeight = output->mmHeight;
} else {
}
else {
size[l].mmWidth = pScreen->mmWidth;
size[l].mmHeight = pScreen->mmHeight;
}
......@@ -567,30 +541,26 @@ RR10GetData (ScreenPtr pScreen, RROutputPtr output)
/*
* Find all modes with matching size
*/
for (os = o; os < output->numModes + output->numUserModes; os++)
{
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);
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)
{
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)
{
if (mode == output->crtc->mode) {
data->size = l;
data->refresh = vRefresh;
}
......@@ -601,7 +571,7 @@ RR10GetData (ScreenPtr pScreen, RROutputPtr output)
}
int
ProcRRGetScreenInfo (ClientPtr client)
ProcRRGetScreenInfo(ClientPtr client)
{
REQUEST(xRRGetScreenInfoReq);
xRRGetScreenInfoReply rep;
......@@ -614,12 +584,12 @@ ProcRRGetScreenInfo (ClientPtr client)
RROutputPtr output;
REQUEST_SIZE_MATCH(xRRGetScreenInfoReq);
#ifndef NXAGENT_SERVER
#ifndef NXAGENT_SERVER
rc = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess);
#else
#else
pWin = SecurityLookupWindow(stuff->window, client, SecurityReadAccess);
rc = pWin ? Success : BadWindow;
#endif
#endif
if (rc != Success)
return rc;
......@@ -628,13 +598,12 @@ ProcRRGetScreenInfo (ClientPtr client)
rep.pad = 0;
if (pScrPriv)
if (!RRGetInfo (pScreen))
if (!RRGetInfo(pScreen))
return BadAlloc;
output = RRFirstOutput (pScreen);
output = RRFirstOutput(pScreen);
if (!pScrPriv || !output)
{
if (!pScrPriv || !output) {
rep.type = X_Reply;
rep.setOfRotations = RR_Rotate_0;;
rep.sequenceNumber = client->sequence;
......@@ -650,17 +619,16 @@ ProcRRGetScreenInfo (ClientPtr client)
extra = 0;
extraLen = 0;
}
else
{
else {
int i, j;
xScreenSizes *size;
CARD16 *rates;
CARD8 *data8;
Bool has_rate = RRClientKnowsRates (client);
Bool has_rate = RRClientKnowsRates(client);
RR10DataPtr pData;
RRScreenSizePtr pSize;
pData = RR10GetData (pScreen, output);
pData = RR10GetData(pScreen, output);
if (!pData)
return BadAlloc;
......@@ -677,16 +645,14 @@ ProcRRGetScreenInfo (ClientPtr client)
rep.sizeID = pData->size;
rep.rate = pData->refresh;
extraLen = rep.nSizes * sizeof (xScreenSizes);
extraLen = rep.nSizes * sizeof(xScreenSizes);
if (has_rate)
extraLen += rep.nrateEnts * sizeof (CARD16);
if (extraLen)
{
extra = (CARD8 *) xalloc (extraLen);
if (!extra)
{
xfree (pData);
extraLen += rep.nrateEnts * sizeof(CARD16);
if (extraLen) {
extra = (CARD8 *) xalloc(extraLen);
if (!extra) {
xfree(pData);
return BadAlloc;
}
}
......@@ -698,47 +664,41 @@ ProcRRGetScreenInfo (ClientPtr client)
*/
size = (xScreenSizes *) extra;
rates = (CARD16 *) (size + rep.nSizes);
for (i = 0; i < pData->nsize; i++)
{
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, n);
swaps (&size->heightInPixels, n);
swaps (&size->widthInMillimeters, n);
swaps (&size->heightInMillimeters, n);
if (client->swapped) {
swaps(&size->widthInPixels, n);
swaps(&size->heightInPixels, n);
swaps(&size->widthInMillimeters, n);
swaps(&size->heightInMillimeters, n);
}
size++;
if (has_rate)
{
if (has_rate) {
*rates = pSize->nRates;
if (client->swapped)
{
swaps (rates, n);
if (client->swapped) {
swaps(rates, n);
}
rates++;
for (j = 0; j < pSize->nRates; j++)
{
for (j = 0; j < pSize->nRates; j++) {
*rates = pSize->pRates[j].rate;
if (client->swapped)
{
swaps (rates, n);
if (client->swapped) {
swaps(rates, n);
}
rates++;
}
}
}
xfree (pData);
xfree(pData);
data8 = (CARD8 *) rates;
if (data8 - (CARD8 *) extra != extraLen)
FatalError ("RRGetScreenInfo bad extra len %ld != %ld\n",
(unsigned long)(data8 - (CARD8 *) extra), extraLen);
FatalError("RRGetScreenInfo bad extra len %ld != %ld\n",
(unsigned long) (data8 - (CARD8 *) extra), extraLen);
rep.length = (extraLen + 3) >> 2;
}
if (client->swapped) {
......@@ -752,17 +712,16 @@ ProcRRGetScreenInfo (ClientPtr client)
swaps(&rep.rate, n);
swaps(&rep.nrateEnts, n);
}
WriteToClient(client, sizeof(xRRGetScreenInfoReply), (char *)&rep);
if (extraLen)
{
WriteToClient (client, extraLen, (char *) extra);
xfree (extra);
WriteToClient(client, sizeof(xRRGetScreenInfoReply), (char *) &rep);
if (extraLen) {
WriteToClient(client, extraLen, (char *) extra);
xfree(extra);
}
return (client->noClientException);
}
int
ProcRRSetScreenConfig (ClientPtr client)
ProcRRSetScreenConfig(ClientPtr client)
{
REQUEST(xRRSetScreenConfigReq);
xRRSetScreenConfigReply rep;
......@@ -782,25 +741,24 @@ ProcRRSetScreenConfig (ClientPtr client)
RRScreenSizePtr pSize;
int width, height;
UpdateCurrentTime ();
UpdateCurrentTime();
if (RRClientKnowsRates (client))
{
REQUEST_SIZE_MATCH (xRRSetScreenConfigReq);
if (RRClientKnowsRates(client)) {
REQUEST_SIZE_MATCH(xRRSetScreenConfigReq);
has_rate = TRUE;
}
else
{
REQUEST_SIZE_MATCH (xRR1_0SetScreenConfigReq);
else {
REQUEST_SIZE_MATCH(xRR1_0SetScreenConfigReq);
has_rate = FALSE;
}
#ifndef NXAGENT_SERVER
#ifndef NXAGENT_SERVER
rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, DixWriteAccess);
#else
pDraw = SecurityLookupDrawable(stuff->drawable, client, SecurityWriteAccess);
#else
pDraw =
SecurityLookupDrawable(stuff->drawable, client, SecurityWriteAccess);
rc = pDraw ? Success : BadDrawable;
#endif
#endif
if (rc != Success)
return rc;
......@@ -810,18 +768,16 @@ ProcRRSetScreenConfig (ClientPtr client)
time = ClientTimeToServerTime(stuff->timestamp);
if (!pScrPriv)
{
if (!pScrPriv) {
time = currentTime;
rep.status = RRSetConfigFailed;
goto sendReply;
}
if (!RRGetInfo (pScreen))
if (!RRGetInfo(pScreen))
return BadAlloc;
output = RRFirstOutput (pScreen);
if (!output)
{
output = RRFirstOutput(pScreen);
if (!output) {
time = currentTime;
rep.status = RRSetConfigFailed;
goto sendReply;
......@@ -838,23 +794,21 @@ 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)
{
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)
{
if (stuff->sizeID >= pData->nsize) {
/*
* Invalid size ID
*/
client->errorValue = stuff->sizeID;
xfree (pData);
xfree(pData);
return BadValue;
}
pSize = &pData->sizes[stuff->sizeID];
......@@ -876,17 +830,16 @@ ProcRRSetScreenConfig (ClientPtr client)
* Invalid rotation
*/
client->errorValue = stuff->rotation;
xfree (pData);
xfree(pData);
return BadValue;
}
if ((~crtc->rotations) & rotation)
{
if ((~crtc->rotations) & rotation) {
/*
* requested rotation or reflection not supported by screen
*/
client->errorValue = stuff->rotation;
xfree (pData);
xfree(pData);
return BadMatch;
}
......@@ -898,20 +851,17 @@ ProcRRSetScreenConfig (ClientPtr client)
else
rate = 0;
if (rate)
{
for (i = 0; i < pSize->nRates; i++)
{
if (rate) {
for (i = 0; i < pSize->nRates; i++) {
if (pSize->pRates[i].rate == rate)
break;
}
if (i == pSize->nRates)
{
if (i == pSize->nRates) {
/*
* Invalid rate
*/
client->errorValue = rate;
xfree (pData);
xfree(pData);
return BadValue;
}
mode = pSize->pRates[i].mode;
......@@ -923,8 +873,7 @@ ProcRRSetScreenConfig (ClientPtr client)
* Make sure the requested set-time is not older than
* the last set-time
*/
if (CompareTimeStamps (time, pScrPriv->lastSetTime) < 0)
{
if (CompareTimeStamps(time, pScrPriv->lastSetTime) < 0) {
rep.status = RRSetConfigInvalidTime;
goto sendReply;
}
......@@ -935,47 +884,42 @@ ProcRRSetScreenConfig (ClientPtr client)
*/
width = mode->mode.width;
height = mode->mode.height;
if (rotation & (RR_Rotate_90|RR_Rotate_270))
{
if (rotation & (RR_Rotate_90 | RR_Rotate_270)) {
width = mode->mode.height;
height = mode->mode.width;
}
if (width < pScrPriv->minWidth || pScrPriv->maxWidth < width) {
client->errorValue = width;
xfree (pData);
xfree(pData);
return BadValue;
}
if (height < pScrPriv->minHeight || pScrPriv->maxHeight < height) {
client->errorValue = height;
xfree (pData);
xfree(pData);
return BadValue;
}
if (width != pScreen->width || height != pScreen->height)
{
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))
{
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))
{
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))
if (!RRCrtcSet(crtc, mode, 0, 0, stuff->rotation, 1, &output))
rep.status = RRSetConfigFailed;
else {
pScrPriv->lastSetTime = time;
......@@ -986,10 +930,10 @@ ProcRRSetScreenConfig (ClientPtr client)
* XXX Configure other crtcs to mirror as much as possible
*/
sendReply:
sendReply:
if (pData)
xfree (pData);
xfree(pData);
rep.type = X_Reply;
/* rep.status has already been filled in */
......@@ -1000,39 +944,37 @@ sendReply:
rep.newConfigTimestamp = pScrPriv->lastConfigTime.milliseconds;
rep.root = WindowTable[pDraw->pScreen->myNum]->drawable.id;
if (client->swapped)
{
if (client->swapped) {
swaps(&rep.sequenceNumber, n);
swapl(&rep.length, n);
swapl(&rep.newTimestamp, n);
swapl(&rep.newConfigTimestamp, n);
swapl(&rep.root, n);
}
WriteToClient(client, sizeof(xRRSetScreenConfigReply), (char *)&rep);
WriteToClient(client, sizeof(xRRSetScreenConfigReply), (char *) &rep);
return (client->noClientException);
}
static CARD16
RR10CurrentSizeID (ScreenPtr pScreen)
RR10CurrentSizeID(ScreenPtr pScreen)
{
CARD16 sizeID = 0xffff;
RROutputPtr output = RRFirstOutput (pScreen);
RROutputPtr output = RRFirstOutput(pScreen);
if (output)
{
RR10DataPtr data = RR10GetData (pScreen, output);
if (data)
{
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)
{
data->sizes[i].height == pScreen->height) {
sizeID = (CARD16) i;
break;
}
xfree (data);
xfree(data);
}
}
return sizeID;
......
......@@ -23,9 +23,10 @@
#include "randrstr.h"
static int
SProcRRQueryVersion (ClientPtr client)
SProcRRQueryVersion(ClientPtr client)
{
register int n;
REQUEST(xRRQueryVersionReq);
REQUEST_SIZE_MATCH(xRRQueryVersionReq);
......@@ -36,9 +37,10 @@ SProcRRQueryVersion (ClientPtr client)
}
static int
SProcRRGetScreenInfo (ClientPtr client)
SProcRRGetScreenInfo(ClientPtr client)
{
register int n;
REQUEST(xRRGetScreenInfoReq);
REQUEST_SIZE_MATCH(xRRGetScreenInfoReq);
......@@ -48,19 +50,18 @@ SProcRRGetScreenInfo (ClientPtr client)
}
static int
SProcRRSetScreenConfig (ClientPtr client)
SProcRRSetScreenConfig(ClientPtr client)
{
register int n;
REQUEST(xRRSetScreenConfigReq);
if (RRClientKnowsRates (client))
{
REQUEST_SIZE_MATCH (xRRSetScreenConfigReq);
swaps (&stuff->rate, n);
if (RRClientKnowsRates(client)) {
REQUEST_SIZE_MATCH(xRRSetScreenConfigReq);
swaps(&stuff->rate, n);
}
else
{
REQUEST_SIZE_MATCH (xRR1_0SetScreenConfigReq);
else {
REQUEST_SIZE_MATCH(xRR1_0SetScreenConfigReq);
}
swaps(&stuff->length, n);
......@@ -72,9 +73,10 @@ SProcRRSetScreenConfig (ClientPtr client)
}
static int
SProcRRSelectInput (ClientPtr client)
SProcRRSelectInput(ClientPtr client)
{
register int n;
REQUEST(xRRSelectInputReq);
REQUEST_SIZE_MATCH(xRRSelectInputReq);
......@@ -85,9 +87,10 @@ SProcRRSelectInput (ClientPtr client)
}
static int
SProcRRGetScreenSizeRange (ClientPtr client)
SProcRRGetScreenSizeRange(ClientPtr client)
{
int n;
REQUEST(xRRGetScreenSizeRangeReq);
REQUEST_SIZE_MATCH(xRRGetScreenSizeRangeReq);
......@@ -97,9 +100,10 @@ SProcRRGetScreenSizeRange (ClientPtr client)
}
static int
SProcRRSetScreenSize (ClientPtr client)
SProcRRSetScreenSize(ClientPtr client)
{
int n;
REQUEST(xRRSetScreenSizeReq);
REQUEST_SIZE_MATCH(xRRSetScreenSizeReq);
......@@ -113,9 +117,10 @@ SProcRRSetScreenSize (ClientPtr client)
}
static int
SProcRRGetScreenResources (ClientPtr client)
SProcRRGetScreenResources(ClientPtr client)
{
int n;
REQUEST(xRRGetScreenResourcesReq);
REQUEST_SIZE_MATCH(xRRGetScreenResourcesReq);
......@@ -125,9 +130,10 @@ SProcRRGetScreenResources (ClientPtr client)
}
static int
SProcRRGetOutputInfo (ClientPtr client)
SProcRRGetOutputInfo(ClientPtr client)
{
int n;
REQUEST(xRRGetOutputInfoReq);;
REQUEST_SIZE_MATCH(xRRGetOutputInfoReq);
......@@ -138,9 +144,10 @@ SProcRRGetOutputInfo (ClientPtr client)
}
static int
SProcRRListOutputProperties (ClientPtr client)
SProcRRListOutputProperties(ClientPtr client)
{
int n;
REQUEST(xRRListOutputPropertiesReq);
REQUEST_SIZE_MATCH(xRRListOutputPropertiesReq);
......@@ -150,9 +157,10 @@ SProcRRListOutputProperties (ClientPtr client)
}
static int
SProcRRQueryOutputProperty (ClientPtr client)
SProcRRQueryOutputProperty(ClientPtr client)
{
int n;
REQUEST(xRRQueryOutputPropertyReq);
REQUEST_SIZE_MATCH(xRRQueryOutputPropertyReq);
......@@ -163,9 +171,10 @@ SProcRRQueryOutputProperty (ClientPtr client)
}
static int
SProcRRConfigureOutputProperty (ClientPtr client)
SProcRRConfigureOutputProperty(ClientPtr client)
{
int n;
REQUEST(xRRConfigureOutputPropertyReq);
swaps(&stuff->length, n);
......@@ -176,18 +185,19 @@ SProcRRConfigureOutputProperty (ClientPtr client)
}
static int
SProcRRChangeOutputProperty (ClientPtr client)
SProcRRChangeOutputProperty(ClientPtr client)
{
int n;
REQUEST(xRRChangeOutputPropertyReq);
REQUEST_AT_LEAST_SIZE (xRRChangeOutputPropertyReq);
REQUEST_AT_LEAST_SIZE(xRRChangeOutputPropertyReq);
swaps(&stuff->length, n);
swapl(&stuff->output, n);
swapl(&stuff->property, n);
swapl(&stuff->type, n);
swapl(&stuff->nUnits, n);
switch(stuff->format) {
switch (stuff->format) {
case 8:
break;
case 16:
......@@ -204,9 +214,10 @@ SProcRRChangeOutputProperty (ClientPtr client)
}
static int
SProcRRDeleteOutputProperty (ClientPtr client)
SProcRRDeleteOutputProperty(ClientPtr client)
{
int n;
REQUEST(xRRDeleteOutputPropertyReq);
REQUEST_SIZE_MATCH(xRRDeleteOutputPropertyReq);
......@@ -217,9 +228,10 @@ SProcRRDeleteOutputProperty (ClientPtr client)
}
static int
SProcRRGetOutputProperty (ClientPtr client)
SProcRRGetOutputProperty(ClientPtr client)
{
int n;
REQUEST(xRRGetOutputPropertyReq);
REQUEST_SIZE_MATCH(xRRGetOutputPropertyReq);
......@@ -233,10 +245,11 @@ SProcRRGetOutputProperty (ClientPtr client)
}
static int
SProcRRCreateMode (ClientPtr client)
SProcRRCreateMode(ClientPtr client)
{
int n;
xRRModeInfo *modeinfo;
REQUEST(xRRCreateModeReq);
REQUEST_AT_LEAST_SIZE(xRRCreateModeReq);
......@@ -260,9 +273,10 @@ SProcRRCreateMode (ClientPtr client)
}
static int
SProcRRDestroyMode (ClientPtr client)
SProcRRDestroyMode(ClientPtr client)
{
int n;
REQUEST(xRRDestroyModeReq);
REQUEST_SIZE_MATCH(xRRDestroyModeReq);
......@@ -272,9 +286,10 @@ SProcRRDestroyMode (ClientPtr client)
}
static int
SProcRRAddOutputMode (ClientPtr client)
SProcRRAddOutputMode(ClientPtr client)
{
int n;
REQUEST(xRRAddOutputModeReq);
REQUEST_SIZE_MATCH(xRRAddOutputModeReq);
......@@ -285,9 +300,10 @@ SProcRRAddOutputMode (ClientPtr client)
}
static int
SProcRRDeleteOutputMode (ClientPtr client)
SProcRRDeleteOutputMode(ClientPtr client)
{
int n;
REQUEST(xRRDeleteOutputModeReq);
REQUEST_SIZE_MATCH(xRRDeleteOutputModeReq);
......@@ -298,9 +314,10 @@ SProcRRDeleteOutputMode (ClientPtr client)
}
static int
SProcRRGetCrtcInfo (ClientPtr client)
SProcRRGetCrtcInfo(ClientPtr client)
{
int n;
REQUEST(xRRGetCrtcInfoReq);
REQUEST_SIZE_MATCH(xRRGetCrtcInfoReq);
......@@ -311,9 +328,10 @@ SProcRRGetCrtcInfo (ClientPtr client)
}
static int
SProcRRSetCrtcConfig (ClientPtr client)
SProcRRSetCrtcConfig(ClientPtr client)
{
int n;
REQUEST(xRRSetCrtcConfigReq);
REQUEST_AT_LEAST_SIZE(xRRSetCrtcConfigReq);
......@@ -330,9 +348,10 @@ SProcRRSetCrtcConfig (ClientPtr client)
}
static int
SProcRRGetCrtcGammaSize (ClientPtr client)
SProcRRGetCrtcGammaSize(ClientPtr client)
{
int n;
REQUEST(xRRGetCrtcGammaSizeReq);
REQUEST_SIZE_MATCH(xRRGetCrtcGammaSizeReq);
......@@ -342,9 +361,10 @@ SProcRRGetCrtcGammaSize (ClientPtr client)
}
static int
SProcRRGetCrtcGamma (ClientPtr client)
SProcRRGetCrtcGamma(ClientPtr client)
{
int n;
REQUEST(xRRGetCrtcGammaReq);
REQUEST_SIZE_MATCH(xRRGetCrtcGammaReq);
......@@ -354,9 +374,10 @@ SProcRRGetCrtcGamma (ClientPtr client)
}
static int
SProcRRSetCrtcGamma (ClientPtr client)
SProcRRSetCrtcGamma(ClientPtr client)
{
int n;
REQUEST(xRRSetCrtcGammaReq);
REQUEST_AT_LEAST_SIZE(xRRSetCrtcGammaReq);
......@@ -367,7 +388,7 @@ SProcRRSetCrtcGamma (ClientPtr client)
return (*ProcRandrVector[stuff->randrReqType]) (client);
}
int (*SProcRandrVector[RRNumberRequests])(ClientPtr) = {
int (*SProcRandrVector[RRNumberRequests]) (ClientPtr) = {
SProcRRQueryVersion, /* 0 */
/* we skip 1 to make old clients fail pretty immediately */
NULL, /* 1 SProcRandrOldGetScreenInfo */
......@@ -382,11 +403,11 @@ int (*SProcRandrVector[RRNumberRequests])(ClientPtr) = {
SProcRRSetScreenSize, /* 7 */
SProcRRGetScreenResources, /* 8 */
SProcRRGetOutputInfo, /* 9 */
SProcRRListOutputProperties,/* 10 */
SProcRRListOutputProperties, /* 10 */
SProcRRQueryOutputProperty, /* 11 */
SProcRRConfigureOutputProperty, /* 12 */
SProcRRChangeOutputProperty,/* 13 */
SProcRRDeleteOutputProperty,/* 14 */
SProcRRChangeOutputProperty, /* 13 */
SProcRRDeleteOutputProperty, /* 14 */
SProcRRGetOutputProperty, /* 15 */
SProcRRCreateMode, /* 16 */
SProcRRDestroyMode, /* 17 */
......@@ -398,4 +419,3 @@ int (*SProcRandrVector[RRNumberRequests])(ClientPtr) = {
SProcRRGetCrtcGamma, /* 23 */
SProcRRSetCrtcGamma, /* 24 */
};
......@@ -123,13 +123,13 @@ ProcRRXineramaQueryVersion(ClientPtr client)
rep.sequenceNumber = client->sequence;
rep.majorVersion = RR_XINERAMA_MAJOR_VERSION;
rep.minorVersion = RR_XINERAMA_MINOR_VERSION;
if(client->swapped) {
if (client->swapped) {
swaps(&rep.sequenceNumber, n);
swapl(&rep.length, n);
swaps(&rep.majorVersion, n);
swaps(&rep.minorVersion, n);
}
WriteToClient(client, sizeof(xPanoramiXQueryVersionReply), (char *)&rep);
WriteToClient(client, sizeof(xPanoramiXQueryVersionReply), (char *) &rep);
return (client->noClientException);
}
......@@ -145,19 +145,18 @@ ProcRRXineramaGetState(ClientPtr client)
Bool active = FALSE;
REQUEST_SIZE_MATCH(xPanoramiXGetStateReq);
#ifndef NXAGENT_SERVER
#ifndef NXAGENT_SERVER
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
#else
#else
pWin = SecurityLookupWindow(stuff->window, client, SecurityReadAccess);
rc = pWin ? Success : BadWindow;
#endif
if(rc != Success)
#endif
if (rc != Success)
return rc;
pScreen = pWin->drawable.pScreen;
pScrPriv = rrGetScrPriv(pScreen);
if (pScrPriv)
{
if (pScrPriv) {
/* XXX do we need more than this? */
active = TRUE;
}
......@@ -167,41 +166,40 @@ ProcRRXineramaGetState(ClientPtr client)
rep.sequenceNumber = client->sequence;
rep.state = active;
rep.window = stuff->window;
if(client->swapped) {
swaps (&rep.sequenceNumber, n);
swapl (&rep.length, n);
swapl (&rep.window, n);
if (client->swapped) {
swaps(&rep.sequenceNumber, n);
swapl(&rep.length, n);
swapl(&rep.window, n);
}
WriteToClient(client, sizeof(xPanoramiXGetStateReply), (char *)&rep);
WriteToClient(client, sizeof(xPanoramiXGetStateReply), (char *) &rep);
return client->noClientException;
}
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;
n = 0;
if (rrGetScrPriv (pScreen))
{
if (rrGetScrPriv(pScreen)) {
rrScrPriv(pScreen);
for (i = 0; i < pScrPriv->numCrtcs; i++)
if (RRXineramaCrtcActive (pScrPriv->crtcs[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
......@@ -213,26 +211,26 @@ ProcRRXineramaGetScreenCount(ClientPtr client)
register int n, rc;
REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq);
#ifndef NXAGENT_SERVER
#ifndef NXAGENT_SERVER
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
#else
#else
pWin = SecurityLookupWindow(stuff->window, client, SecurityReadAccess);
rc = pWin ? Success : BadWindow;
#endif
#endif
if (rc != Success)
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) {
if (client->swapped) {
swaps(&rep.sequenceNumber, n);
swapl(&rep.length, n);
swapl(&rep.window, n);
}
WriteToClient(client, sizeof(xPanoramiXGetScreenCountReply), (char *)&rep);
WriteToClient(client, sizeof(xPanoramiXGetScreenCountReply), (char *) &rep);
return client->noClientException;
}
......@@ -246,12 +244,12 @@ ProcRRXineramaGetScreenSize(ClientPtr client)
register int n, rc;
REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
#ifndef NXAGENT_SERVER
#ifndef NXAGENT_SERVER
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
#else
#else
pWin = SecurityLookupWindow(stuff->window, client, SecurityReadAccess);
rc = pWin ? Success : BadWindow;
#endif
#endif
if (rc != Success)
return rc;
......@@ -265,7 +263,7 @@ ProcRRXineramaGetScreenSize(ClientPtr client)
rep.height = pRoot->drawable.height;
rep.window = stuff->window;
rep.screen = stuff->screen;
if(client->swapped) {
if (client->swapped) {
swaps(&rep.sequenceNumber, n);
swapl(&rep.length, n);
swapl(&rep.width, n);
......@@ -273,7 +271,7 @@ ProcRRXineramaGetScreenSize(ClientPtr client)
swapl(&rep.window, n);
swapl(&rep.screen, n);
}
WriteToClient(client, sizeof(xPanoramiXGetScreenSizeReply), (char *)&rep);
WriteToClient(client, sizeof(xPanoramiXGetScreenSizeReply), (char *) &rep);
return client->noClientException;
}
......@@ -288,9 +286,10 @@ 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) {
rep.state = RRXineramaScreenActive(screenInfo.screens[RR_XINERAMA_SCREEN]);
if (client->swapped) {
register int n;
swaps(&rep.sequenceNumber, n);
swapl(&rep.length, n);
swapl(&rep.state, n);
......@@ -307,48 +306,50 @@ ProcRRXineramaQueryScreens(ClientPtr client)
REQUEST_SIZE_MATCH(xXineramaQueryScreensReq);
if (RRXineramaScreenActive (pScreen))
{
if (RRXineramaScreenActive(pScreen)) {
rrScrPriv(pScreen);
if (pScrPriv->numCrtcs == 0 || pScrPriv->numOutputs == 0)
RRGetInfo (pScreen);
RRGetInfo(pScreen);
}
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
rep.number = RRXineramaScreenCount (pScreen);
rep.number = RRXineramaScreenCount(pScreen);
rep.length = rep.number * sz_XineramaScreenInfo >> 2;
if(client->swapped) {
if (client->swapped) {
register int n;
swaps(&rep.sequenceNumber, n);
swapl(&rep.length, n);
swapl(&rep.number, n);
}
WriteToClient(client, sizeof(xXineramaQueryScreensReply), (char *)&rep);
WriteToClient(client, sizeof(xXineramaQueryScreensReply), (char *) &rep);
if(rep.number) {
if (rep.number) {
rrScrPriv(pScreen);
xXineramaScreenInfo scratch;
int i;
for(i = 0; i < pScrPriv->numCrtcs; i++) {
for (i = 0; i < pScrPriv->numCrtcs; i++) {
RRCrtcPtr crtc = pScrPriv->crtcs[i];
if (RRXineramaCrtcActive (crtc))
{
if (RRXineramaCrtcActive(crtc)) {
int width, height;
RRCrtcGetScanoutSize (crtc, &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) {
if (client->swapped) {
register int n;
swaps(&scratch.x_org, n);
swaps(&scratch.y_org, n);
swaps(&scratch.width, n);
swaps(&scratch.height, n);
}
WriteToClient(client, sz_XineramaScreenInfo, (char *)&scratch);
WriteToClient(client, sz_XineramaScreenInfo, (char *) &scratch);
}
}
}
......@@ -380,12 +381,13 @@ ProcRRXineramaDispatch(ClientPtr client)
/* SProc */
static int
SProcRRXineramaQueryVersion (ClientPtr client)
SProcRRXineramaQueryVersion(ClientPtr client)
{
REQUEST(xPanoramiXQueryVersionReq);
register int n;
swaps(&stuff->length,n);
REQUEST_SIZE_MATCH (xPanoramiXQueryVersionReq);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xPanoramiXQueryVersionReq);
return ProcRRXineramaQueryVersion(client);
}
......@@ -394,9 +396,10 @@ SProcRRXineramaGetState(ClientPtr client)
{
REQUEST(xPanoramiXGetStateReq);
register int n;
swaps (&stuff->length, n);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xPanoramiXGetStateReq);
swapl (&stuff->window, n);
swapl(&stuff->window, n);
return ProcRRXineramaGetState(client);
}
......@@ -405,9 +408,10 @@ SProcRRXineramaGetScreenCount(ClientPtr client)
{
REQUEST(xPanoramiXGetScreenCountReq);
register int n;
swaps (&stuff->length, n);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq);
swapl (&stuff->window, n);
swapl(&stuff->window, n);
return ProcRRXineramaGetScreenCount(client);
}
......@@ -416,10 +420,11 @@ SProcRRXineramaGetScreenSize(ClientPtr client)
{
REQUEST(xPanoramiXGetScreenSizeReq);
register int n;
swaps (&stuff->length, n);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
swapl (&stuff->window, n);
swapl (&stuff->screen, n);
swapl(&stuff->window, n);
swapl(&stuff->screen, n);
return ProcRRXineramaGetScreenSize(client);
}
......@@ -428,7 +433,8 @@ SProcRRXineramaIsActive(ClientPtr client)
{
REQUEST(xXineramaIsActiveReq);
register int n;
swaps (&stuff->length, n);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xXineramaIsActiveReq);
return ProcRRXineramaIsActive(client);
}
......@@ -438,7 +444,8 @@ SProcRRXineramaQueryScreens(ClientPtr client)
{
REQUEST(xXineramaQueryScreensReq);
register int n;
swaps (&stuff->length, n);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xXineramaQueryScreensReq);
return ProcRRXineramaQueryScreens(client);
}
......@@ -465,7 +472,7 @@ SProcRRXineramaDispatch(ClientPtr client)
}
static void
RRXineramaResetProc(ExtensionEntry* extEntry)
RRXineramaResetProc(ExtensionEntry * extEntry)
{
}
......@@ -473,7 +480,7 @@ void
RRXineramaExtensionInit(void)
{
#ifdef PANORAMIX
if(!noPanoramiXExtension)
if (!noPanoramiXExtension)
return;
#endif
......@@ -485,9 +492,8 @@ RRXineramaExtensionInit(void)
if (screenInfo.numScreens > 1)
return;
(void) AddExtension(PANORAMIX_PROTOCOL_NAME, 0,0,
(void) AddExtension(PANORAMIX_PROTOCOL_NAME, 0, 0,
ProcRRXineramaDispatch,
SProcRRXineramaDispatch,
RRXineramaResetProc,
StandardMinorOpcode);
RRXineramaResetProc, StandardMinorOpcode);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment