diff options
author | Keith Packard <keithp@keithp.com> | 2012-03-21 12:55:09 -0700 |
---|---|---|
committer | Jeremy Huddleston <jeremyhu@apple.com> | 2012-03-27 11:50:40 -0700 |
commit | 8384075e1a0fb3189f9c37c17f9e12e1aae5102c (patch) | |
tree | 2ef3a1cf71bff62caa3d7abc9b59cc1f9457c1d2 | |
parent | d9a9788bb163731f681951e9f0ac0e37fd095e6b (diff) |
Introduce a consistent coding style
This is strictly the application of the script 'x-indent-all.sh'
from util/modular. Compared to the patch that Daniel posted in
January, I've added a few indent flags:
-bap
-psl
-T PrivatePtr
-T pmWait
-T _XFUNCPROTOBEGIN
-T _XFUNCPROTOEND
-T _X_EXPORT
The typedefs were needed to make the output of sdksyms.sh match the
previous output, otherwise, the code is formatted badly enough that
sdksyms.sh generates incorrect output.
The generated code was compared with the previous version and found to
be essentially identical -- "assert" line numbers and BUILD_TIME were
the only differences found.
The comparison was done with this script:
dir1=$1
dir2=$2
for dir in $dir1 $dir2; do
(cd $dir && find . -name '*.o' | while read file; do
dir=`dirname $file`
base=`basename $file .o`
dump=$dir/$base.dump
objdump -d $file > $dump
done)
done
find $dir1 -name '*.dump' | while read dump; do
otherdump=`echo $dump | sed "s;$dir1;$dir2;"`
diff -u $dump $otherdump
done
Signed-off-by: Keith Packard <keithp@keithp.com>
Acked-by: Daniel Stone <daniel@fooishbar.org>
Acked-by: Alan Coopersmith <alan.coopersmith@oracle.com>
(cherry picked from commit 9838b7032ea9792bec21af424c53c07078636d21)
1258 files changed, 264651 insertions, 259934 deletions
diff --git a/Xext/bigreq.c b/Xext/bigreq.c index a939e1699..49355c4a4 100644 --- a/Xext/bigreq.c +++ b/Xext/bigreq.c @@ -43,16 +43,16 @@ from The Open Group. void BigReqExtensionInit(INITARGS); static int -ProcBigReqDispatch (ClientPtr client) +ProcBigReqDispatch(ClientPtr client) { REQUEST(xBigReqEnableReq); xBigReqEnableReply rep; if (client->swapped) { - swaps(&stuff->length); + swaps(&stuff->length); } if (stuff->brReqType != X_BigReqEnable) - return BadRequest; + return BadRequest; REQUEST_SIZE_MATCH(xBigReqEnableReq); client->big_requests = TRUE; memset(&rep, 0, sizeof(xBigReqEnableReply)); @@ -61,10 +61,10 @@ ProcBigReqDispatch (ClientPtr client) rep.sequenceNumber = client->sequence; rep.max_request_size = maxBigRequestSize; if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.max_request_size); + swaps(&rep.sequenceNumber); + swapl(&rep.max_request_size); } - WriteToClient(client, sizeof(xBigReqEnableReply), (char *)&rep); + WriteToClient(client, sizeof(xBigReqEnableReply), (char *) &rep); return Success; } @@ -72,6 +72,6 @@ void BigReqExtensionInit(INITARGS) { AddExtension(XBigReqExtensionName, 0, 0, - ProcBigReqDispatch, ProcBigReqDispatch, - NULL, StandardMinorOpcode); + ProcBigReqDispatch, ProcBigReqDispatch, + NULL, StandardMinorOpcode); } diff --git a/Xext/dpms.c b/Xext/dpms.c index 0c8f18f47..348c87289 100644 --- a/Xext/dpms.c +++ b/Xext/dpms.c @@ -55,11 +55,11 @@ ProcDPMSGetVersion(ClientPtr client) rep.majorVersion = DPMSMajorVersion; rep.minorVersion = DPMSMinorVersion; if (client->swapped) { - swaps(&rep.sequenceNumber); - swaps(&rep.majorVersion); - swaps(&rep.minorVersion); + swaps(&rep.sequenceNumber); + swaps(&rep.majorVersion); + swaps(&rep.minorVersion); } - WriteToClient(client, sizeof(xDPMSGetVersionReply), (char *)&rep); + WriteToClient(client, sizeof(xDPMSGetVersionReply), (char *) &rep); return Success; } @@ -77,9 +77,9 @@ ProcDPMSCapable(ClientPtr client) rep.capable = DPMSCapableFlag; if (client->swapped) { - swaps(&rep.sequenceNumber); + swaps(&rep.sequenceNumber); } - WriteToClient(client, sizeof(xDPMSCapableReply), (char *)&rep); + WriteToClient(client, sizeof(xDPMSCapableReply), (char *) &rep); return Success; } @@ -99,12 +99,12 @@ ProcDPMSGetTimeouts(ClientPtr client) rep.off = DPMSOffTime / MILLI_PER_SECOND; if (client->swapped) { - swaps(&rep.sequenceNumber); - swaps(&rep.standby); - swaps(&rep.suspend); - swaps(&rep.off); + swaps(&rep.sequenceNumber); + swaps(&rep.standby); + swaps(&rep.suspend); + swaps(&rep.off); } - WriteToClient(client, sizeof(xDPMSGetTimeoutsReply), (char *)&rep); + WriteToClient(client, sizeof(xDPMSGetTimeoutsReply), (char *) &rep); return Success; } @@ -115,16 +115,14 @@ ProcDPMSSetTimeouts(ClientPtr client) REQUEST_SIZE_MATCH(xDPMSSetTimeoutsReq); - if ((stuff->off != 0)&&(stuff->off < stuff->suspend)) - { - client->errorValue = stuff->off; - return BadValue; + if ((stuff->off != 0) && (stuff->off < stuff->suspend)) { + client->errorValue = stuff->off; + return BadValue; + } + if ((stuff->suspend != 0) && (stuff->suspend < stuff->standby)) { + client->errorValue = stuff->suspend; + return BadValue; } - if ((stuff->suspend != 0)&&(stuff->suspend < stuff->standby)) - { - client->errorValue = stuff->suspend; - return BadValue; - } DPMSStandbyTime = stuff->standby * MILLI_PER_SECOND; DPMSSuspendTime = stuff->suspend * MILLI_PER_SECOND; @@ -142,9 +140,9 @@ ProcDPMSEnable(ClientPtr client) REQUEST_SIZE_MATCH(xDPMSEnableReq); if (DPMSCapableFlag) { - DPMSEnabled = TRUE; - if (!was_enabled) - SetScreenSaverTimer(); + DPMSEnabled = TRUE; + if (!was_enabled) + SetScreenSaverTimer(); } return Success; @@ -172,14 +170,13 @@ ProcDPMSForceLevel(ClientPtr client) REQUEST_SIZE_MATCH(xDPMSForceLevelReq); if (!DPMSEnabled) - return BadMatch; + return BadMatch; if (stuff->level != DPMSModeOn && stuff->level != DPMSModeStandby && - stuff->level != DPMSModeSuspend && - stuff->level != DPMSModeOff) { - client->errorValue = stuff->level; - return BadValue; + stuff->level != DPMSModeSuspend && stuff->level != DPMSModeOff) { + client->errorValue = stuff->level; + return BadValue; } DPMSSet(client, stuff->level); @@ -202,38 +199,37 @@ ProcDPMSInfo(ClientPtr client) rep.state = DPMSEnabled; if (client->swapped) { - swaps(&rep.sequenceNumber); - swaps(&rep.power_level); + swaps(&rep.sequenceNumber); + swaps(&rep.power_level); } - WriteToClient(client, sizeof(xDPMSInfoReply), (char *)&rep); + WriteToClient(client, sizeof(xDPMSInfoReply), (char *) &rep); return Success; } static int -ProcDPMSDispatch (ClientPtr client) +ProcDPMSDispatch(ClientPtr client) { REQUEST(xReq); - switch (stuff->data) - { + switch (stuff->data) { case X_DPMSGetVersion: - return ProcDPMSGetVersion(client); + return ProcDPMSGetVersion(client); case X_DPMSCapable: - return ProcDPMSCapable(client); + return ProcDPMSCapable(client); case X_DPMSGetTimeouts: - return ProcDPMSGetTimeouts(client); + return ProcDPMSGetTimeouts(client); case X_DPMSSetTimeouts: - return ProcDPMSSetTimeouts(client); + return ProcDPMSSetTimeouts(client); case X_DPMSEnable: - return ProcDPMSEnable(client); + return ProcDPMSEnable(client); case X_DPMSDisable: - return ProcDPMSDisable(client); + return ProcDPMSDisable(client); case X_DPMSForceLevel: - return ProcDPMSForceLevel(client); + return ProcDPMSForceLevel(client); case X_DPMSInfo: - return ProcDPMSInfo(client); + return ProcDPMSInfo(client); default: - return BadRequest; + return BadRequest; } } @@ -332,29 +328,28 @@ SProcDPMSInfo(ClientPtr client) } static int -SProcDPMSDispatch (ClientPtr client) +SProcDPMSDispatch(ClientPtr client) { REQUEST(xReq); - switch (stuff->data) - { + switch (stuff->data) { case X_DPMSGetVersion: - return SProcDPMSGetVersion(client); + return SProcDPMSGetVersion(client); case X_DPMSCapable: - return SProcDPMSCapable(client); + return SProcDPMSCapable(client); case X_DPMSGetTimeouts: - return SProcDPMSGetTimeouts(client); + return SProcDPMSGetTimeouts(client); case X_DPMSSetTimeouts: - return SProcDPMSSetTimeouts(client); + return SProcDPMSSetTimeouts(client); case X_DPMSEnable: - return SProcDPMSEnable(client); + return SProcDPMSEnable(client); case X_DPMSDisable: - return SProcDPMSDisable(client); + return SProcDPMSDisable(client); case X_DPMSForceLevel: - return SProcDPMSForceLevel(client); + return SProcDPMSForceLevel(client); case X_DPMSInfo: - return SProcDPMSInfo(client); + return SProcDPMSInfo(client); default: - return BadRequest; + return BadRequest; } } @@ -362,6 +357,6 @@ void DPMSExtensionInit(INITARGS) { AddExtension(DPMSExtensionName, 0, 0, - ProcDPMSDispatch, SProcDPMSDispatch, - NULL, StandardMinorOpcode); + ProcDPMSDispatch, SProcDPMSDispatch, + NULL, StandardMinorOpcode); } diff --git a/Xext/dpmsproc.h b/Xext/dpmsproc.h index c1df56fdf..7494dfd6f 100644 --- a/Xext/dpmsproc.h +++ b/Xext/dpmsproc.h @@ -9,7 +9,7 @@ #include "dixstruct.h" -int DPMSSet(ClientPtr client, int level); +int DPMSSet(ClientPtr client, int level); Bool DPMSSupported(void); #endif diff --git a/Xext/dpmsstubs.c b/Xext/dpmsstubs.c index f0f54d293..80f13f5df 100644 --- a/Xext/dpmsstubs.c +++ b/Xext/dpmsstubs.c @@ -34,12 +34,14 @@ Equipment Corporation. #define FALSE 0 -Bool DPMSSupported(void) +Bool +DPMSSupported(void) { return FALSE; } -int DPMSSet(ClientPtr client, int level) +int +DPMSSet(ClientPtr client, int level) { return Success; } diff --git a/Xext/geext.c b/Xext/geext.c index a8718ccbd..07028238e 100644 --- a/Xext/geext.c +++ b/Xext/geext.c @@ -35,18 +35,18 @@ DevPrivateKeyRec GEClientPrivateKeyRec; -int RT_GECLIENT = 0; +int RT_GECLIENT = 0; GEExtension GEExtensions[MAXEXTENSIONS]; /* Major available requests */ static const int version_requests[] = { - X_GEQueryVersion, /* before client sends QueryVersion */ - X_GEQueryVersion, /* must be set to last request in version 1 */ + X_GEQueryVersion, /* before client sends QueryVersion */ + X_GEQueryVersion, /* must be set to last request in version 1 */ }; /* Forward declarations */ -static void SGEGenericEvent(xEvent* from, xEvent* to); +static void SGEGenericEvent(xEvent *from, xEvent *to); #define NUM_VERSION_REQUESTS (sizeof (version_requests) / sizeof (version_requests[0])) #define EXT_MASK(ext) ((ext) & 0x7F) @@ -60,6 +60,7 @@ ProcGEQueryVersion(ClientPtr client) { GEClientInfoPtr pGEClient = GEGetClient(client); xGEQueryVersionReply rep; + REQUEST(xGEQueryVersionReq); REQUEST_SIZE_MATCH(xGEQueryVersionReq); @@ -77,22 +78,20 @@ ProcGEQueryVersion(ClientPtr client) pGEClient->major_version = stuff->majorVersion; pGEClient->minor_version = stuff->minorVersion; - if (client->swapped) - { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - swaps(&rep.majorVersion); - swaps(&rep.minorVersion); + if (client->swapped) { + swaps(&rep.sequenceNumber); + swapl(&rep.length); + swaps(&rep.majorVersion); + swaps(&rep.minorVersion); } - WriteToClient(client, sizeof(xGEQueryVersionReply), (char*)&rep); + WriteToClient(client, sizeof(xGEQueryVersionReply), (char *) &rep); return Success; } -int (*ProcGEVector[GENumberRequests])(ClientPtr) = { +int (*ProcGEVector[GENumberRequests]) (ClientPtr) = { /* Version 1.0 */ - ProcGEQueryVersion -}; +ProcGEQueryVersion}; /************************************************************/ /* swapped request handlers */ @@ -106,14 +105,12 @@ SProcGEQueryVersion(ClientPtr client) REQUEST_SIZE_MATCH(xGEQueryVersionReq); swaps(&stuff->majorVersion); swaps(&stuff->minorVersion); - return(*ProcGEVector[stuff->ReqType])(client); + return (*ProcGEVector[stuff->ReqType]) (client); } -int (*SProcGEVector[GENumberRequests])(ClientPtr) = { +int (*SProcGEVector[GENumberRequests]) (ClientPtr) = { /* Version 1.0 */ - SProcGEQueryVersion -}; - +SProcGEQueryVersion}; /************************************************************/ /* callbacks */ @@ -124,6 +121,7 @@ static int ProcGEDispatch(ClientPtr client) { GEClientInfoPtr pGEClient = GEGetClient(client); + REQUEST(xGEReq); if (pGEClient->major_version >= NUM_VERSION_REQUESTS) @@ -131,7 +129,7 @@ ProcGEDispatch(ClientPtr client) if (stuff->ReqType > version_requests[pGEClient->major_version]) return BadRequest; - return (ProcGEVector[stuff->ReqType])(client); + return (ProcGEVector[stuff->ReqType]) (client); } /* dispatch swapped requests */ @@ -141,7 +139,7 @@ SProcGEDispatch(ClientPtr client) REQUEST(xGEReq); if (stuff->ReqType >= GENumberRequests) return BadRequest; - return (*SProcGEVector[stuff->ReqType])(client); + return (*SProcGEVector[stuff->ReqType]) (client); } /** @@ -151,13 +149,11 @@ SProcGEDispatch(ClientPtr client) * used in the furture for versioning support. */ static void -GEClientCallback(CallbackListPtr *list, - pointer closure, - pointer data) +GEClientCallback(CallbackListPtr *list, pointer closure, pointer data) { - NewClientInfoRec *clientinfo = (NewClientInfoRec *) data; - ClientPtr pClient = clientinfo->client; - GEClientInfoPtr pGEClient = GEGetClient(pClient); + NewClientInfoRec *clientinfo = (NewClientInfoRec *) data; + ClientPtr pClient = clientinfo->client; + GEClientInfoPtr pGEClient = GEGetClient(pClient); pGEClient->major_version = 0; pGEClient->minor_version = 0; @@ -165,7 +161,7 @@ GEClientCallback(CallbackListPtr *list, /* Reset extension. Called on server shutdown. */ static void -GEResetProc(ExtensionEntry *extEntry) +GEResetProc(ExtensionEntry * extEntry) { DeleteCallback(&ClientStateCallback, GEClientCallback, 0); EventSwapVector[GenericEvent] = NotImplemented; @@ -179,13 +175,12 @@ GEResetProc(ExtensionEntry *extEntry) * work. */ static void -SGEGenericEvent(xEvent* from, xEvent* to) +SGEGenericEvent(xEvent *from, xEvent *to) { - xGenericEvent* gefrom = (xGenericEvent*)from; - xGenericEvent* geto = (xGenericEvent*)to; + xGenericEvent *gefrom = (xGenericEvent *) from; + xGenericEvent *geto = (xGenericEvent *) to; - if ((gefrom->extension & 0x7f) > MAXEXTENSIONS) - { + if ((gefrom->extension & 0x7f) > MAXEXTENSIONS) { ErrorF("GE: Invalid extension offset for event.\n"); return; } @@ -203,23 +198,23 @@ GEExtensionInit(void) { ExtensionEntry *extEntry; - if (!dixRegisterPrivateKey(&GEClientPrivateKeyRec, PRIVATE_CLIENT, sizeof(GEClientInfoRec))) + if (!dixRegisterPrivateKey + (&GEClientPrivateKeyRec, PRIVATE_CLIENT, sizeof(GEClientInfoRec))) FatalError("GEExtensionInit: GE private request failed.\n"); - if(!AddCallback(&ClientStateCallback, GEClientCallback, 0)) - { + if (!AddCallback(&ClientStateCallback, GEClientCallback, 0)) { FatalError("GEExtensionInit: register client callback failed.\n"); } - if((extEntry = AddExtension(GE_NAME, - 0, GENumberErrors, - ProcGEDispatch, SProcGEDispatch, - GEResetProc, StandardMinorOpcode)) != 0) - { + if ((extEntry = AddExtension(GE_NAME, + 0, GENumberErrors, + ProcGEDispatch, SProcGEDispatch, + GEResetProc, StandardMinorOpcode)) != 0) { memset(GEExtensions, 0, sizeof(GEExtensions)); EventSwapVector[GenericEvent] = (EventSwapPtr) SGEGenericEvent; - } else { + } + else { FatalError("GEInit: AddExtensions failed.\n"); } @@ -238,24 +233,22 @@ GEExtensionInit(void) */ void GERegisterExtension(int extension, - void (*ev_swap)(xGenericEvent* from, xGenericEvent* to)) + void (*ev_swap) (xGenericEvent *from, xGenericEvent *to)) { - if (EXT_MASK(extension) >= MAXEXTENSIONS) + if (EXT_MASK(extension) >= MAXEXTENSIONS) FatalError("GE: extension > MAXEXTENSIONS. This should not happen.\n"); /* extension opcodes are > 128, might as well save some space here */ GEExtensions[EXT_MASK(extension)].evswap = ev_swap; } - /* Sets type and extension field for a generic event. This is just an * auxiliary function, extensions could do it manually too. */ void -GEInitEvent(xGenericEvent* ev, int extension) +GEInitEvent(xGenericEvent *ev, int extension) { ev->type = GenericEvent; ev->extension = extension; ev->length = 0; } - diff --git a/Xext/geext.h b/Xext/geext.h index 8e6dbeb24..d2a15dcb9 100644 --- a/Xext/geext.h +++ b/Xext/geext.h @@ -37,10 +37,9 @@ from the author. /** Struct to keep information about registered extensions */ typedef struct _GEExtension { /** Event swapping routine */ - void (*evswap)(xGenericEvent* from, xGenericEvent* to); + void (*evswap) (xGenericEvent *from, xGenericEvent *to); } GEExtension, *GEExtensionPtr; - /* All registered extensions and their handling functions. */ extern _X_EXPORT GEExtension GEExtensions[MAXEXTENSIONS]; @@ -70,14 +69,15 @@ extern _X_EXPORT GEExtension GEExtensions[MAXEXTENSIONS]; GEEXT(ev) == (ext) && \ GEV(ev)->evtype == (ev_type)) - /* Interface for other extensions */ -extern _X_EXPORT void GERegisterExtension( - int extension, - void (*ev_dispatch)(xGenericEvent* from, xGenericEvent* to)); +extern _X_EXPORT void GERegisterExtension(int extension, + void (*ev_dispatch) (xGenericEvent + *from, + xGenericEvent + *to)); -extern _X_EXPORT void GEInitEvent(xGenericEvent* ev, int extension); +extern _X_EXPORT void GEInitEvent(xGenericEvent *ev, int extension); extern _X_EXPORT void GEExtensionInit(void); -#endif /* _GEEXT_H_ */ +#endif /* _GEEXT_H_ */ diff --git a/Xext/geint.h b/Xext/geint.h index 3e2b8e187..f76d14809 100644 --- a/Xext/geint.h +++ b/Xext/geint.h @@ -38,16 +38,17 @@ #include <X11/extensions/geproto.h> extern _X_EXPORT DevPrivateKeyRec GEClientPrivateKeyRec; + #define GEClientPrivateKey (&GEClientPrivateKeyRec) typedef struct _GEClientInfo { - CARD32 major_version; - CARD32 minor_version; + CARD32 major_version; + CARD32 minor_version; } GEClientInfoRec, *GEClientInfoPtr; #define GEGetClient(pClient) ((GEClientInfoPtr)(dixLookupPrivate(&((pClient)->devPrivates), GEClientPrivateKey))) -extern _X_EXPORT int (*ProcGEVector[/*GENumRequests*/])(ClientPtr); -extern _X_EXPORT int (*SProcGEVector[/*GENumRequests*/])(ClientPtr); +extern _X_EXPORT int (*ProcGEVector[ /*GENumRequests */ ]) (ClientPtr); +extern _X_EXPORT int (*SProcGEVector[ /*GENumRequests */ ]) (ClientPtr); -#endif /* _GEINT_H_ */ +#endif /* _GEINT_H_ */ diff --git a/Xext/panoramiX.c b/Xext/panoramiX.c index fae7c81c9..98d327f26 100644 --- a/Xext/panoramiX.c +++ b/Xext/panoramiX.c @@ -64,24 +64,23 @@ Equipment Corporation. #ifdef GLXPROXY extern VisualPtr glxMatchVisual(ScreenPtr pScreen, - VisualPtr pVisual, - ScreenPtr pMatchScreen); + VisualPtr pVisual, ScreenPtr pMatchScreen); #endif /* * PanoramiX data declarations */ -int PanoramiXPixWidth = 0; -int PanoramiXPixHeight = 0; -int PanoramiXNumScreens = 0; +int PanoramiXPixWidth = 0; +int PanoramiXPixHeight = 0; +int PanoramiXNumScreens = 0; -static RegionRec PanoramiXScreenRegion = {{0, 0, 0, 0}, NULL}; +static RegionRec PanoramiXScreenRegion = { {0, 0, 0, 0}, NULL }; -static int PanoramiXNumDepths; -static DepthPtr PanoramiXDepths; -static int PanoramiXNumVisuals; -static VisualPtr PanoramiXVisuals; +static int PanoramiXNumDepths; +static DepthPtr PanoramiXDepths; +static int PanoramiXNumVisuals; +static VisualPtr PanoramiXVisuals; RESTYPE XRC_DRAWABLE; RESTYPE XRT_WINDOW; @@ -97,9 +96,9 @@ XineramaVisualsEqualProcPtr XineramaVisualsEqualPtr = &VisualsEqual; */ static int panoramiXGeneration; -static int ProcPanoramiXDispatch(ClientPtr client); +static int ProcPanoramiXDispatch(ClientPtr client); -static void PanoramiXResetProc(ExtensionEntry*); +static void PanoramiXResetProc(ExtensionEntry *); /* * External references for functions and data variables @@ -107,22 +106,25 @@ static void PanoramiXResetProc(ExtensionEntry*); #include "panoramiXh.h" -int (* SavedProcVector[256]) (ClientPtr client) = { NULL, }; +int (*SavedProcVector[256]) (ClientPtr client) = { +NULL,}; static DevPrivateKeyRec PanoramiXGCKeyRec; + #define PanoramiXGCKey (&PanoramiXGCKeyRec) static DevPrivateKeyRec PanoramiXScreenKeyRec; + #define PanoramiXScreenKey (&PanoramiXScreenKeyRec) typedef struct { - DDXPointRec clipOrg; - DDXPointRec patOrg; - GCFuncs *wrapFuncs; + DDXPointRec clipOrg; + DDXPointRec patOrg; + GCFuncs *wrapFuncs; } PanoramiXGCRec, *PanoramiXGCPtr; typedef struct { - CreateGCProcPtr CreateGC; - CloseScreenProcPtr CloseScreen; + CreateGCProcPtr CreateGC; + CloseScreenProcPtr CloseScreen; } PanoramiXScreenRec, *PanoramiXScreenPtr; static void XineramaValidateGC(GCPtr, unsigned long, DrawablePtr); @@ -147,18 +149,17 @@ static GCFuncs XineramaGCFuncs = { pGCPriv->wrapFuncs = (pGC)->funcs;\ (pGC)->funcs = &XineramaGCFuncs; - static Bool -XineramaCloseScreen (int i, ScreenPtr pScreen) +XineramaCloseScreen(int i, ScreenPtr pScreen) { PanoramiXScreenPtr pScreenPriv = (PanoramiXScreenPtr) - dixLookupPrivate(&pScreen->devPrivates, PanoramiXScreenKey); + dixLookupPrivate(&pScreen->devPrivates, PanoramiXScreenKey); pScreen->CloseScreen = pScreenPriv->CloseScreen; pScreen->CreateGC = pScreenPriv->CreateGC; if (pScreen->myNum == 0) - RegionUninit(&PanoramiXScreenRegion); + RegionUninit(&PanoramiXScreenRegion); free((pointer) pScreenPriv); @@ -170,21 +171,21 @@ XineramaCreateGC(GCPtr pGC) { ScreenPtr pScreen = pGC->pScreen; PanoramiXScreenPtr pScreenPriv = (PanoramiXScreenPtr) - dixLookupPrivate(&pScreen->devPrivates, PanoramiXScreenKey); + dixLookupPrivate(&pScreen->devPrivates, PanoramiXScreenKey); Bool ret; pScreen->CreateGC = pScreenPriv->CreateGC; - if((ret = (*pScreen->CreateGC)(pGC))) { - PanoramiXGCPtr pGCPriv = (PanoramiXGCPtr) - dixLookupPrivate(&pGC->devPrivates, PanoramiXGCKey); + if ((ret = (*pScreen->CreateGC) (pGC))) { + PanoramiXGCPtr pGCPriv = (PanoramiXGCPtr) + dixLookupPrivate(&pGC->devPrivates, PanoramiXGCKey); - pGCPriv->wrapFuncs = pGC->funcs; + pGCPriv->wrapFuncs = pGC->funcs; pGC->funcs = &XineramaGCFuncs; - pGCPriv->clipOrg.x = pGC->clipOrg.x; - pGCPriv->clipOrg.y = pGC->clipOrg.y; - pGCPriv->patOrg.x = pGC->patOrg.x; - pGCPriv->patOrg.y = pGC->patOrg.y; + pGCPriv->clipOrg.x = pGC->clipOrg.x; + pGCPriv->clipOrg.y = pGC->clipOrg.y; + pGCPriv->patOrg.x = pGC->patOrg.x; + pGCPriv->patOrg.y = pGC->patOrg.y; } pScreen->CreateGC = XineramaCreateGC; @@ -192,139 +193,129 @@ XineramaCreateGC(GCPtr pGC) } static void -XineramaValidateGC( - GCPtr pGC, - unsigned long changes, - DrawablePtr pDraw -){ - Xinerama_GC_FUNC_PROLOGUE (pGC); - - if((pDraw->type == DRAWABLE_WINDOW) && !(((WindowPtr)pDraw)->parent)) { - /* the root window */ - int x_off = pGC->pScreen->x; - int y_off = pGC->pScreen->y; - int new_val; - - new_val = pGCPriv->clipOrg.x - x_off; - if(pGC->clipOrg.x != new_val) { - pGC->clipOrg.x = new_val; - changes |= GCClipXOrigin; - } - new_val = pGCPriv->clipOrg.y - y_off; - if(pGC->clipOrg.y != new_val) { - pGC->clipOrg.y = new_val; - changes |= GCClipYOrigin; - } - new_val = pGCPriv->patOrg.x - x_off; - if(pGC->patOrg.x != new_val) { - pGC->patOrg.x = new_val; - changes |= GCTileStipXOrigin; - } - new_val = pGCPriv->patOrg.y - y_off; - if(pGC->patOrg.y != new_val) { - pGC->patOrg.y = new_val; - changes |= GCTileStipYOrigin; - } - } else { - if(pGC->clipOrg.x != pGCPriv->clipOrg.x) { - pGC->clipOrg.x = pGCPriv->clipOrg.x; - changes |= GCClipXOrigin; - } - if(pGC->clipOrg.y != pGCPriv->clipOrg.y) { - pGC->clipOrg.y = pGCPriv->clipOrg.y; - changes |= GCClipYOrigin; - } - if(pGC->patOrg.x != pGCPriv->patOrg.x) { - pGC->patOrg.x = pGCPriv->patOrg.x; - changes |= GCTileStipXOrigin; - } - if(pGC->patOrg.y != pGCPriv->patOrg.y) { - pGC->patOrg.y = pGCPriv->patOrg.y; - changes |= GCTileStipYOrigin; - } +XineramaValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDraw) +{ + Xinerama_GC_FUNC_PROLOGUE(pGC); + + if ((pDraw->type == DRAWABLE_WINDOW) && !(((WindowPtr) pDraw)->parent)) { + /* the root window */ + int x_off = pGC->pScreen->x; + int y_off = pGC->pScreen->y; + int new_val; + + new_val = pGCPriv->clipOrg.x - x_off; + if (pGC->clipOrg.x != new_val) { + pGC->clipOrg.x = new_val; + changes |= GCClipXOrigin; + } + new_val = pGCPriv->clipOrg.y - y_off; + if (pGC->clipOrg.y != new_val) { + pGC->clipOrg.y = new_val; + changes |= GCClipYOrigin; + } + new_val = pGCPriv->patOrg.x - x_off; + if (pGC->patOrg.x != new_val) { + pGC->patOrg.x = new_val; + changes |= GCTileStipXOrigin; + } + new_val = pGCPriv->patOrg.y - y_off; + if (pGC->patOrg.y != new_val) { + pGC->patOrg.y = new_val; + changes |= GCTileStipYOrigin; + } + } + else { + if (pGC->clipOrg.x != pGCPriv->clipOrg.x) { + pGC->clipOrg.x = pGCPriv->clipOrg.x; + changes |= GCClipXOrigin; + } + if (pGC->clipOrg.y != pGCPriv->clipOrg.y) { + pGC->clipOrg.y = pGCPriv->clipOrg.y; + changes |= GCClipYOrigin; + } + if (pGC->patOrg.x != pGCPriv->patOrg.x) { + pGC->patOrg.x = pGCPriv->patOrg.x; + changes |= GCTileStipXOrigin; + } + if (pGC->patOrg.y != pGCPriv->patOrg.y) { + pGC->patOrg.y = pGCPriv->patOrg.y; + changes |= GCTileStipYOrigin; + } } - - (*pGC->funcs->ValidateGC)(pGC, changes, pDraw); - Xinerama_GC_FUNC_EPILOGUE (pGC); + + (*pGC->funcs->ValidateGC) (pGC, changes, pDraw); + Xinerama_GC_FUNC_EPILOGUE(pGC); } static void XineramaDestroyGC(GCPtr pGC) { - Xinerama_GC_FUNC_PROLOGUE (pGC); - (*pGC->funcs->DestroyGC)(pGC); - Xinerama_GC_FUNC_EPILOGUE (pGC); + Xinerama_GC_FUNC_PROLOGUE(pGC); + (*pGC->funcs->DestroyGC) (pGC); + Xinerama_GC_FUNC_EPILOGUE(pGC); } static void -XineramaChangeGC ( - GCPtr pGC, - unsigned long mask -){ - Xinerama_GC_FUNC_PROLOGUE (pGC); - - if(mask & GCTileStipXOrigin) - pGCPriv->patOrg.x = pGC->patOrg.x; - if(mask & GCTileStipYOrigin) - pGCPriv->patOrg.y = pGC->patOrg.y; - if(mask & GCClipXOrigin) - pGCPriv->clipOrg.x = pGC->clipOrg.x; - if(mask & GCClipYOrigin) - pGCPriv->clipOrg.y = pGC->clipOrg.y; +XineramaChangeGC(GCPtr pGC, unsigned long mask) +{ + Xinerama_GC_FUNC_PROLOGUE(pGC); + + if (mask & GCTileStipXOrigin) + pGCPriv->patOrg.x = pGC->patOrg.x; + if (mask & GCTileStipYOrigin) + pGCPriv->patOrg.y = pGC->patOrg.y; + if (mask & GCClipXOrigin) + pGCPriv->clipOrg.x = pGC->clipOrg.x; + if (mask & GCClipYOrigin) + pGCPriv->clipOrg.y = pGC->clipOrg.y; (*pGC->funcs->ChangeGC) (pGC, mask); - Xinerama_GC_FUNC_EPILOGUE (pGC); + Xinerama_GC_FUNC_EPILOGUE(pGC); } static void -XineramaCopyGC ( - GCPtr pGCSrc, - unsigned long mask, - GCPtr pGCDst -){ +XineramaCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst) +{ PanoramiXGCPtr pSrcPriv = (PanoramiXGCPtr) - dixLookupPrivate(&pGCSrc->devPrivates, PanoramiXGCKey); - Xinerama_GC_FUNC_PROLOGUE (pGCDst); + dixLookupPrivate(&pGCSrc->devPrivates, PanoramiXGCKey); - if(mask & GCTileStipXOrigin) + Xinerama_GC_FUNC_PROLOGUE(pGCDst); + + if (mask & GCTileStipXOrigin) pGCPriv->patOrg.x = pSrcPriv->patOrg.x; - if(mask & GCTileStipYOrigin) + if (mask & GCTileStipYOrigin) pGCPriv->patOrg.y = pSrcPriv->patOrg.y; - if(mask & GCClipXOrigin) + if (mask & GCClipXOrigin) pGCPriv->clipOrg.x = pSrcPriv->clipOrg.x; - if(mask & GCClipYOrigin) + if (mask & GCClipYOrigin) pGCPriv->clipOrg.y = pSrcPriv->clipOrg.y; (*pGCDst->funcs->CopyGC) (pGCSrc, mask, pGCDst); - Xinerama_GC_FUNC_EPILOGUE (pGCDst); + Xinerama_GC_FUNC_EPILOGUE(pGCDst); } static void -XineramaChangeClip ( - GCPtr pGC, - int type, - pointer pvalue, - int nrects -){ - Xinerama_GC_FUNC_PROLOGUE (pGC); +XineramaChangeClip(GCPtr pGC, int type, pointer pvalue, int nrects) +{ + Xinerama_GC_FUNC_PROLOGUE(pGC); (*pGC->funcs->ChangeClip) (pGC, type, pvalue, nrects); - Xinerama_GC_FUNC_EPILOGUE (pGC); + Xinerama_GC_FUNC_EPILOGUE(pGC); } static void XineramaCopyClip(GCPtr pgcDst, GCPtr pgcSrc) { - Xinerama_GC_FUNC_PROLOGUE (pgcDst); - (* pgcDst->funcs->CopyClip)(pgcDst, pgcSrc); - Xinerama_GC_FUNC_EPILOGUE (pgcDst); + Xinerama_GC_FUNC_PROLOGUE(pgcDst); + (*pgcDst->funcs->CopyClip) (pgcDst, pgcSrc); + Xinerama_GC_FUNC_EPILOGUE(pgcDst); } static void XineramaDestroyClip(GCPtr pGC) { - Xinerama_GC_FUNC_PROLOGUE (pGC); - (* pGC->funcs->DestroyClip)(pGC); - Xinerama_GC_FUNC_EPILOGUE (pGC); + Xinerama_GC_FUNC_PROLOGUE(pGC); + (*pGC->funcs->DestroyClip) (pGC); + Xinerama_GC_FUNC_EPILOGUE(pGC); } int @@ -335,16 +326,16 @@ XineramaDeleteResource(pointer data, XID id) } typedef struct { - int screen; - int id; -} PanoramiXSearchData; + int screen; + int id; +} PanoramiXSearchData; -static Bool +static Bool XineramaFindIDByScrnum(pointer resource, XID id, pointer privdata) { - PanoramiXRes *res = (PanoramiXRes*)resource; - PanoramiXSearchData *data = (PanoramiXSearchData*)privdata; - + PanoramiXRes *res = (PanoramiXRes *) resource; + PanoramiXSearchData *data = (PanoramiXSearchData *) privdata; + return res->info[data->screen].id == data->id; } @@ -354,32 +345,32 @@ PanoramiXFindIDByScrnum(RESTYPE type, XID id, int screen) PanoramiXSearchData data; pointer val; - if(!screen) { - dixLookupResourceByType(&val, id, type, serverClient, DixReadAccess); - return val; + if (!screen) { + dixLookupResourceByType(&val, id, type, serverClient, DixReadAccess); + return val; } data.screen = screen; data.id = id; return LookupClientResourceComplex(clients[CLIENT_ID(id)], type, - XineramaFindIDByScrnum, &data); + XineramaFindIDByScrnum, &data); } typedef struct _connect_callback_list { - void (*func)(void); + void (*func) (void); struct _connect_callback_list *next; } XineramaConnectionCallbackList; static XineramaConnectionCallbackList *ConnectionCallbackList = NULL; Bool -XineramaRegisterConnectionBlockCallback(void (*func)(void)) +XineramaRegisterConnectionBlockCallback(void (*func) (void)) { XineramaConnectionCallbackList *newlist; - if(!(newlist = malloc(sizeof(XineramaConnectionCallbackList)))) - return FALSE; + if (!(newlist = malloc(sizeof(XineramaConnectionCallbackList)))) + return FALSE; newlist->next = ConnectionCallbackList; newlist->func = func; @@ -388,44 +379,48 @@ XineramaRegisterConnectionBlockCallback(void (*func)(void)) return TRUE; } -static void XineramaInitData(void) +static void +XineramaInitData(void) { int i, w, h; RegionNull(&PanoramiXScreenRegion); FOR_NSCREENS(i) { - BoxRec TheBox; - RegionRec ScreenRegion; + BoxRec TheBox; + RegionRec ScreenRegion; - ScreenPtr pScreen = screenInfo.screens[i]; + ScreenPtr pScreen = screenInfo.screens[i]; - TheBox.x1 = pScreen->x; - TheBox.x2 = TheBox.x1 + pScreen->width; - TheBox.y1 = pScreen->y; - TheBox.y2 = TheBox.y1 + pScreen->height; + TheBox.x1 = pScreen->x; + TheBox.x2 = TheBox.x1 + pScreen->width; + TheBox.y1 = pScreen->y; + TheBox.y2 = TheBox.y1 + pScreen->height; - RegionInit(&ScreenRegion, &TheBox, 1); - RegionUnion(&PanoramiXScreenRegion, &PanoramiXScreenRegion, - &ScreenRegion); - RegionUninit(&ScreenRegion); + RegionInit(&ScreenRegion, &TheBox, 1); + RegionUnion(&PanoramiXScreenRegion, &PanoramiXScreenRegion, + &ScreenRegion); + RegionUninit(&ScreenRegion); } PanoramiXPixWidth = screenInfo.screens[0]->x + screenInfo.screens[0]->width; - PanoramiXPixHeight = screenInfo.screens[0]->y + screenInfo.screens[0]->height; + PanoramiXPixHeight = + screenInfo.screens[0]->y + screenInfo.screens[0]->height; FOR_NSCREENS_FORWARD_SKIP(i) { - ScreenPtr pScreen = screenInfo.screens[i]; - w = pScreen->x + pScreen->width; - h = pScreen->y + pScreen->height; - - if (PanoramiXPixWidth < w) - PanoramiXPixWidth = w; - if (PanoramiXPixHeight < h) - PanoramiXPixHeight = h; + ScreenPtr pScreen = screenInfo.screens[i]; + + w = pScreen->x + pScreen->width; + h = pScreen->y + pScreen->height; + + if (PanoramiXPixWidth < w) + PanoramiXPixWidth = w; + if (PanoramiXPixHeight < h) + PanoramiXPixHeight = h; } } -void XineramaReinitData(void) +void +XineramaReinitData(void) { RegionUninit(&PanoramiXScreenRegion); XineramaInitData(); @@ -436,103 +431,104 @@ void XineramaReinitData(void) * Called from InitExtensions in main(). * Register PanoramiXeen Extension * Initialize global variables. - */ + */ -void PanoramiXExtensionInit(int argc, char *argv[]) +void +PanoramiXExtensionInit(int argc, char *argv[]) { - int i; - Bool success = FALSE; - ExtensionEntry *extEntry; - ScreenPtr pScreen = screenInfo.screens[0]; - PanoramiXScreenPtr pScreenPriv; + int i; + Bool success = FALSE; + ExtensionEntry *extEntry; + ScreenPtr pScreen = screenInfo.screens[0]; + PanoramiXScreenPtr pScreenPriv; - if (noPanoramiXExtension) - return; + if (noPanoramiXExtension) + return; if (!dixRegisterPrivateKey(&PanoramiXScreenKeyRec, PRIVATE_SCREEN, 0)) { - noPanoramiXExtension = TRUE; - return; + noPanoramiXExtension = TRUE; + return; } - if (!dixRegisterPrivateKey(&PanoramiXGCKeyRec, PRIVATE_GC, sizeof(PanoramiXGCRec))) { - noPanoramiXExtension = TRUE; - return; + if (!dixRegisterPrivateKey + (&PanoramiXGCKeyRec, PRIVATE_GC, sizeof(PanoramiXGCRec))) { + noPanoramiXExtension = TRUE; + return; } PanoramiXNumScreens = screenInfo.numScreens; - if (PanoramiXNumScreens == 1) { /* Only 1 screen */ - noPanoramiXExtension = TRUE; - return; + if (PanoramiXNumScreens == 1) { /* Only 1 screen */ + noPanoramiXExtension = TRUE; + return; } while (panoramiXGeneration != serverGeneration) { - extEntry = AddExtension(PANORAMIX_PROTOCOL_NAME, 0,0, - ProcPanoramiXDispatch, - SProcPanoramiXDispatch, PanoramiXResetProc, - StandardMinorOpcode); - if (!extEntry) - break; - - /* - * First make sure all the basic allocations succeed. If not, - * run in non-PanoramiXeen mode. - */ - - FOR_NSCREENS(i) { - pScreen = screenInfo.screens[i]; - pScreenPriv = malloc(sizeof(PanoramiXScreenRec)); - dixSetPrivate(&pScreen->devPrivates, PanoramiXScreenKey, - pScreenPriv); - if(!pScreenPriv) { - noPanoramiXExtension = TRUE; - return; - } - - pScreenPriv->CreateGC = pScreen->CreateGC; - pScreenPriv->CloseScreen = pScreen->CloseScreen; - - pScreen->CreateGC = XineramaCreateGC; - pScreen->CloseScreen = XineramaCloseScreen; - } - - XRC_DRAWABLE = CreateNewResourceClass(); - XRT_WINDOW = CreateNewResourceType(XineramaDeleteResource, - "XineramaWindow"); - if (XRT_WINDOW) - XRT_WINDOW |= XRC_DRAWABLE; - XRT_PIXMAP = CreateNewResourceType(XineramaDeleteResource, - "XineramaPixmap"); - if (XRT_PIXMAP) - XRT_PIXMAP |= XRC_DRAWABLE; - XRT_GC = CreateNewResourceType(XineramaDeleteResource, - "XineramaGC"); - XRT_COLORMAP = CreateNewResourceType(XineramaDeleteResource, - "XineramaColormap"); - - if (XRT_WINDOW && XRT_PIXMAP && XRT_GC && XRT_COLORMAP) { - panoramiXGeneration = serverGeneration; - success = TRUE; - } - SetResourceTypeErrorValue(XRT_WINDOW, BadWindow); - SetResourceTypeErrorValue(XRT_PIXMAP, BadPixmap); - SetResourceTypeErrorValue(XRT_GC, BadGC); - SetResourceTypeErrorValue(XRT_COLORMAP, BadColor); + extEntry = AddExtension(PANORAMIX_PROTOCOL_NAME, 0, 0, + ProcPanoramiXDispatch, + SProcPanoramiXDispatch, PanoramiXResetProc, + StandardMinorOpcode); + if (!extEntry) + break; + + /* + * First make sure all the basic allocations succeed. If not, + * run in non-PanoramiXeen mode. + */ + + FOR_NSCREENS(i) { + pScreen = screenInfo.screens[i]; + pScreenPriv = malloc(sizeof(PanoramiXScreenRec)); + dixSetPrivate(&pScreen->devPrivates, PanoramiXScreenKey, + pScreenPriv); + if (!pScreenPriv) { + noPanoramiXExtension = TRUE; + return; + } + + pScreenPriv->CreateGC = pScreen->CreateGC; + pScreenPriv->CloseScreen = pScreen->CloseScreen; + + pScreen->CreateGC = XineramaCreateGC; + pScreen->CloseScreen = XineramaCloseScreen; + } + + XRC_DRAWABLE = CreateNewResourceClass(); + XRT_WINDOW = CreateNewResourceType(XineramaDeleteResource, + "XineramaWindow"); + if (XRT_WINDOW) + XRT_WINDOW |= XRC_DRAWABLE; + XRT_PIXMAP = CreateNewResourceType(XineramaDeleteResource, + "XineramaPixmap"); + if (XRT_PIXMAP) + XRT_PIXMAP |= XRC_DRAWABLE; + XRT_GC = CreateNewResourceType(XineramaDeleteResource, "XineramaGC"); + XRT_COLORMAP = CreateNewResourceType(XineramaDeleteResource, + "XineramaColormap"); + + if (XRT_WINDOW && XRT_PIXMAP && XRT_GC && XRT_COLORMAP) { + panoramiXGeneration = serverGeneration; + success = TRUE; + } + SetResourceTypeErrorValue(XRT_WINDOW, BadWindow); + SetResourceTypeErrorValue(XRT_PIXMAP, BadPixmap); + SetResourceTypeErrorValue(XRT_GC, BadGC); + SetResourceTypeErrorValue(XRT_COLORMAP, BadColor); } if (!success) { - noPanoramiXExtension = TRUE; - ErrorF(PANORAMIX_PROTOCOL_NAME " extension failed to initialize\n"); - return; + noPanoramiXExtension = TRUE; + ErrorF(PANORAMIX_PROTOCOL_NAME " extension failed to initialize\n"); + return; } - + XineramaInitData(); /* - * Put our processes into the ProcVector + * Put our processes into the ProcVector */ - for (i = 256; i--; ) - SavedProcVector[i] = ProcVector[i]; + for (i = 256; i--;) + SavedProcVector[i] = ProcVector[i]; ProcVector[X_CreateWindow] = PanoramiXCreateWindow; ProcVector[X_ChangeWindowAttributes] = PanoramiXChangeWindowAttributes; @@ -586,19 +582,20 @@ void PanoramiXExtensionInit(int argc, char *argv[]) ProcVector[X_StoreColors] = PanoramiXStoreColors; ProcVector[X_StoreNamedColor] = PanoramiXStoreNamedColor; - PanoramiXRenderInit (); + PanoramiXRenderInit(); #ifdef XFIXES - PanoramiXFixesInit (); + PanoramiXFixesInit(); #endif #ifdef COMPOSITE - PanoramiXCompositeInit (); + PanoramiXCompositeInit(); #endif } extern Bool CreateConnectionBlock(void); -Bool PanoramiXCreateConnectionBlock(void) +Bool +PanoramiXCreateConnectionBlock(void) { int i, j, length; Bool disableBackingStore = FALSE; @@ -611,40 +608,41 @@ Bool PanoramiXCreateConnectionBlock(void) ScreenPtr pScreen; /* - * Do normal CreateConnectionBlock but faking it for only one screen + * Do normal CreateConnectionBlock but faking it for only one screen */ - if(!PanoramiXNumDepths) { - ErrorF("Xinerama error: No common visuals\n"); - return FALSE; + if (!PanoramiXNumDepths) { + ErrorF("Xinerama error: No common visuals\n"); + return FALSE; } - for(i = 1; i < screenInfo.numScreens; i++) { - pScreen = screenInfo.screens[i]; - if(pScreen->rootDepth != screenInfo.screens[0]->rootDepth) { - ErrorF("Xinerama error: Root window depths differ\n"); - return FALSE; - } - if(pScreen->backingStoreSupport != screenInfo.screens[0]->backingStoreSupport) - disableBackingStore = TRUE; + for (i = 1; i < screenInfo.numScreens; i++) { + pScreen = screenInfo.screens[i]; + if (pScreen->rootDepth != screenInfo.screens[0]->rootDepth) { + ErrorF("Xinerama error: Root window depths differ\n"); + return FALSE; + } + if (pScreen->backingStoreSupport != + screenInfo.screens[0]->backingStoreSupport) + disableBackingStore = TRUE; } if (disableBackingStore) { - for (i = 0; i < screenInfo.numScreens; i++) { - pScreen = screenInfo.screens[i]; - pScreen->backingStoreSupport = NotUseful; - } + for (i = 0; i < screenInfo.numScreens; i++) { + pScreen = screenInfo.screens[i]; + pScreen->backingStoreSupport = NotUseful; + } } i = screenInfo.numScreens; screenInfo.numScreens = 1; if (!CreateConnectionBlock()) { - screenInfo.numScreens = i; - return FALSE; + screenInfo.numScreens = i; + return FALSE; } screenInfo.numScreens = i; - + root = (xWindowRoot *) (ConnectionInfo + connBlockScreenStart); length = connBlockScreenStart + sizeof(xWindowRoot); @@ -652,42 +650,40 @@ Bool PanoramiXCreateConnectionBlock(void) root->nDepths = PanoramiXNumDepths; for (i = 0; i < PanoramiXNumDepths; i++) { - depth = (xDepth *) (ConnectionInfo + length); - depth->depth = PanoramiXDepths[i].depth; - depth->nVisuals = PanoramiXDepths[i].numVids; - length += sizeof(xDepth); - visual = (xVisualType *)(ConnectionInfo + length); - - for (j = 0; j < depth->nVisuals; j++, visual++) { - visual->visualID = PanoramiXDepths[i].vids[j]; - - for (pVisual = PanoramiXVisuals; - pVisual->vid != visual->visualID; - pVisual++) - ; - - visual->class = pVisual->class; - visual->bitsPerRGB = pVisual->bitsPerRGBValue; - visual->colormapEntries = pVisual->ColormapEntries; - visual->redMask = pVisual->redMask; - visual->greenMask = pVisual->greenMask; - visual->blueMask = pVisual->blueMask; - } - - length += (depth->nVisuals * sizeof(xVisualType)); + depth = (xDepth *) (ConnectionInfo + length); + depth->depth = PanoramiXDepths[i].depth; + depth->nVisuals = PanoramiXDepths[i].numVids; + length += sizeof(xDepth); + visual = (xVisualType *) (ConnectionInfo + length); + + for (j = 0; j < depth->nVisuals; j++, visual++) { + visual->visualID = PanoramiXDepths[i].vids[j]; + + for (pVisual = PanoramiXVisuals; + pVisual->vid != visual->visualID; pVisual++); + + visual->class = pVisual->class; + visual->bitsPerRGB = pVisual->bitsPerRGBValue; + visual->colormapEntries = pVisual->ColormapEntries; + visual->redMask = pVisual->redMask; + visual->greenMask = pVisual->greenMask; + visual->blueMask = pVisual->blueMask; + } + + length += (depth->nVisuals * sizeof(xVisualType)); } connSetupPrefix.length = bytes_to_int32(length); for (i = 0; i < PanoramiXNumDepths; i++) - free(PanoramiXDepths[i].vids); + free(PanoramiXDepths[i].vids); free(PanoramiXDepths); PanoramiXDepths = NULL; /* * OK, change some dimensions so it looks as if it were one big screen */ - + old_width = root->pixWidth; old_height = root->pixHeight; @@ -698,13 +694,13 @@ Bool PanoramiXCreateConnectionBlock(void) root->mmWidth *= width_mult; root->mmHeight *= height_mult; - while(ConnectionCallbackList) { - pointer tmp; + while (ConnectionCallbackList) { + pointer tmp; - tmp = (pointer)ConnectionCallbackList; - (*ConnectionCallbackList->func)(); - ConnectionCallbackList = ConnectionCallbackList->next; - free(tmp); + tmp = (pointer) ConnectionCallbackList; + (*ConnectionCallbackList->func) (); + ConnectionCallbackList = ConnectionCallbackList->next; + free(tmp); } return TRUE; @@ -723,14 +719,14 @@ static Bool VisualsEqual(VisualPtr a, ScreenPtr pScreenB, VisualPtr b) { return ((a->class == b->class) && - (a->ColormapEntries == b->ColormapEntries) && - (a->nplanes == b->nplanes) && - (a->redMask == b->redMask) && - (a->greenMask == b->greenMask) && - (a->blueMask == b->blueMask) && - (a->offsetRed == b->offsetRed) && - (a->offsetGreen == b->offsetGreen) && - (a->offsetBlue == b->offsetBlue)); + (a->ColormapEntries == b->ColormapEntries) && + (a->nplanes == b->nplanes) && + (a->redMask == b->redMask) && + (a->greenMask == b->greenMask) && + (a->blueMask == b->blueMask) && + (a->offsetRed == b->offsetRed) && + (a->offsetGreen == b->offsetGreen) && + (a->offsetBlue == b->offsetBlue)); } static void @@ -741,29 +737,29 @@ PanoramiXMaybeAddDepth(DepthPtr pDepth) Bool found = FALSE; FOR_NSCREENS_FORWARD_SKIP(j) { - pScreen = screenInfo.screens[j]; - for (k = 0; k < pScreen->numDepths; k++) { - if (pScreen->allowedDepths[k].depth == pDepth->depth) { - found = TRUE; - break; - } - } + pScreen = screenInfo.screens[j]; + for (k = 0; k < pScreen->numDepths; k++) { + if (pScreen->allowedDepths[k].depth == pDepth->depth) { + found = TRUE; + break; + } + } } if (!found) - return; + return; j = PanoramiXNumDepths; PanoramiXNumDepths++; PanoramiXDepths = realloc(PanoramiXDepths, - PanoramiXNumDepths * sizeof(DepthRec)); + PanoramiXNumDepths * sizeof(DepthRec)); PanoramiXDepths[j].depth = pDepth->depth; PanoramiXDepths[j].numVids = 0; /* XXX suboptimal, should grow these dynamically */ - if(pDepth->numVids) - PanoramiXDepths[j].vids = malloc(sizeof(VisualID) * pDepth->numVids); + if (pDepth->numVids) + PanoramiXDepths[j].vids = malloc(sizeof(VisualID) * pDepth->numVids); else - PanoramiXDepths[j].vids = NULL; + PanoramiXDepths[j].vids = NULL; } static void @@ -774,60 +770,60 @@ PanoramiXMaybeAddVisual(VisualPtr pVisual) Bool found = FALSE; FOR_NSCREENS_FORWARD_SKIP(j) { - pScreen = screenInfo.screens[j]; - found = FALSE; + pScreen = screenInfo.screens[j]; + found = FALSE; - for (k = 0; k < pScreen->numVisuals; k++) { - VisualPtr candidate = &pScreen->visuals[k]; + for (k = 0; k < pScreen->numVisuals; k++) { + VisualPtr candidate = &pScreen->visuals[k]; - if ((*XineramaVisualsEqualPtr)(pVisual, pScreen, candidate) + if ((*XineramaVisualsEqualPtr) (pVisual, pScreen, candidate) #ifdef GLXPROXY - && glxMatchVisual(screenInfo.screens[0], pVisual, pScreen) + && glxMatchVisual(screenInfo.screens[0], pVisual, pScreen) #endif - ) { - found = TRUE; - break; - } - } - - if (!found) - return; + ) { + found = TRUE; + break; + } + } + + if (!found) + return; } /* found a matching visual on all screens, add it to the subset list */ j = PanoramiXNumVisuals; PanoramiXNumVisuals++; PanoramiXVisuals = realloc(PanoramiXVisuals, - PanoramiXNumVisuals * sizeof(VisualRec)); + PanoramiXNumVisuals * sizeof(VisualRec)); memcpy(&PanoramiXVisuals[j], pVisual, sizeof(VisualRec)); for (k = 0; k < PanoramiXNumDepths; k++) { - if (PanoramiXDepths[k].depth == pVisual->nplanes) { - PanoramiXDepths[k].vids[PanoramiXDepths[k].numVids] = pVisual->vid; - PanoramiXDepths[k].numVids++; - break; - } - } + if (PanoramiXDepths[k].depth == pVisual->nplanes) { + PanoramiXDepths[k].vids[PanoramiXDepths[k].numVids] = pVisual->vid; + PanoramiXDepths[k].numVids++; + break; + } + } } extern void PanoramiXConsolidate(void) { - int i; + int i; PanoramiXRes *root, *defmap, *saver; - ScreenPtr pScreen = screenInfo.screens[0]; - DepthPtr pDepth = pScreen->allowedDepths; - VisualPtr pVisual = pScreen->visuals; + ScreenPtr pScreen = screenInfo.screens[0]; + DepthPtr pDepth = pScreen->allowedDepths; + VisualPtr pVisual = pScreen->visuals; PanoramiXNumDepths = 0; PanoramiXNumVisuals = 0; for (i = 0; i < pScreen->numDepths; i++) - PanoramiXMaybeAddDepth(pDepth++); + PanoramiXMaybeAddDepth(pDepth++); for (i = 0; i < pScreen->numVisuals; i++) - PanoramiXMaybeAddVisual(pVisual++); + PanoramiXMaybeAddVisual(pVisual++); root = malloc(sizeof(PanoramiXRes)); root->type = XRT_WINDOW; @@ -837,14 +833,15 @@ PanoramiXConsolidate(void) saver->type = XRT_WINDOW; FOR_NSCREENS(i) { - ScreenPtr pScreen = screenInfo.screens[i]; - root->info[i].id = pScreen->root->drawable.id; - root->u.win.class = InputOutput; + ScreenPtr pScreen = screenInfo.screens[i]; + + root->info[i].id = pScreen->root->drawable.id; + root->u.win.class = InputOutput; root->u.win.root = TRUE; saver->info[i].id = pScreen->screensaver.wid; saver->u.win.class = InputOutput; saver->u.win.root = TRUE; - defmap->info[i].id = pScreen->defColormap; + defmap->info[i].id = pScreen->defColormap; } AddResource(root->info[0].id, XRT_WINDOW, root); @@ -860,169 +857,167 @@ PanoramiXTranslateVisualID(int screen, VisualID orig) int i; for (i = 0; i < PanoramiXNumVisuals; i++) { - if (orig == PanoramiXVisuals[i].vid) { - pVisual = &PanoramiXVisuals[i]; - break; - } + if (orig == PanoramiXVisuals[i].vid) { + pVisual = &PanoramiXVisuals[i]; + break; + } } if (!pVisual) - return 0; + return 0; /* if screen is 0, orig is already the correct visual ID */ if (screen == 0) - return orig; + return orig; /* found the original, now translate it relative to the backend screen */ for (i = 0; i < pOtherScreen->numVisuals; i++) { - VisualPtr pOtherVisual = &pOtherScreen->visuals[i]; + VisualPtr pOtherVisual = &pOtherScreen->visuals[i]; - if ((*XineramaVisualsEqualPtr)(pVisual, pOtherScreen, pOtherVisual)) - return pOtherVisual->vid; + if ((*XineramaVisualsEqualPtr) (pVisual, pOtherScreen, pOtherVisual)) + return pOtherVisual->vid; } return 0; } - /* * PanoramiXResetProc() * Exit, deallocating as needed. */ -static void PanoramiXResetProc(ExtensionEntry* extEntry) +static void +PanoramiXResetProc(ExtensionEntry * extEntry) { - int i; + int i; - PanoramiXRenderReset (); + PanoramiXRenderReset(); #ifdef XFIXES - PanoramiXFixesReset (); + PanoramiXFixesReset(); #endif screenInfo.numScreens = PanoramiXNumScreens; - for (i = 256; i--; ) - ProcVector[i] = SavedProcVector[i]; + for (i = 256; i--;) + ProcVector[i] = SavedProcVector[i]; } - int -ProcPanoramiXQueryVersion (ClientPtr client) +ProcPanoramiXQueryVersion(ClientPtr client) { /* REQUEST(xPanoramiXQueryVersionReq); */ - xPanoramiXQueryVersionReply rep; + xPanoramiXQueryVersionReply rep; - REQUEST_SIZE_MATCH (xPanoramiXQueryVersionReq); + REQUEST_SIZE_MATCH(xPanoramiXQueryVersionReq); rep.type = X_Reply; rep.length = 0; rep.sequenceNumber = client->sequence; rep.majorVersion = SERVER_PANORAMIX_MAJOR_VERSION; rep.minorVersion = SERVER_PANORAMIX_MINOR_VERSION; - if (client->swapped) { + if (client->swapped) { swaps(&rep.sequenceNumber); swapl(&rep.length); swaps(&rep.majorVersion); swaps(&rep.minorVersion); } - WriteToClient(client, sizeof (xPanoramiXQueryVersionReply), (char *)&rep); + WriteToClient(client, sizeof(xPanoramiXQueryVersionReply), (char *) &rep); return Success; } int ProcPanoramiXGetState(ClientPtr client) { - REQUEST(xPanoramiXGetStateReq); - WindowPtr pWin; - xPanoramiXGetStateReply rep; - int rc; - - REQUEST_SIZE_MATCH(xPanoramiXGetStateReq); - rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); - if (rc != Success) - return rc; - - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - rep.state = !noPanoramiXExtension; - rep.window = stuff->window; - if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - swapl(&rep.window); - } - WriteToClient (client, sizeof (xPanoramiXGetStateReply), (char *) &rep); - return Success; + REQUEST(xPanoramiXGetStateReq); + WindowPtr pWin; + xPanoramiXGetStateReply rep; + int rc; + + REQUEST_SIZE_MATCH(xPanoramiXGetStateReq); + rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); + if (rc != Success) + return rc; + + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.state = !noPanoramiXExtension; + rep.window = stuff->window; + if (client->swapped) { + swaps(&rep.sequenceNumber); + swapl(&rep.length); + swapl(&rep.window); + } + WriteToClient(client, sizeof(xPanoramiXGetStateReply), (char *) &rep); + return Success; } -int +int ProcPanoramiXGetScreenCount(ClientPtr client) { - REQUEST(xPanoramiXGetScreenCountReq); - WindowPtr pWin; - xPanoramiXGetScreenCountReply rep; - int rc; - - REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq); - rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); - if (rc != Success) - return rc; - - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - rep.ScreenCount = PanoramiXNumScreens; - rep.window = stuff->window; - if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - swapl(&rep.window); - } - WriteToClient (client, sizeof (xPanoramiXGetScreenCountReply), (char *) &rep); - return Success; + REQUEST(xPanoramiXGetScreenCountReq); + WindowPtr pWin; + xPanoramiXGetScreenCountReply rep; + int rc; + + REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq); + rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); + if (rc != Success) + return rc; + + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.ScreenCount = PanoramiXNumScreens; + rep.window = stuff->window; + if (client->swapped) { + swaps(&rep.sequenceNumber); + swapl(&rep.length); + swapl(&rep.window); + } + WriteToClient(client, sizeof(xPanoramiXGetScreenCountReply), (char *) &rep); + return Success; } -int +int ProcPanoramiXGetScreenSize(ClientPtr client) { - REQUEST(xPanoramiXGetScreenSizeReq); - WindowPtr pWin; - xPanoramiXGetScreenSizeReply rep; - int rc; - - if (stuff->screen >= PanoramiXNumScreens) - return BadMatch; - - REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq); - rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); - if (rc != Success) - return rc; - - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - /* screen dimensions */ - rep.width = screenInfo.screens[stuff->screen]->width; - rep.height = screenInfo.screens[stuff->screen]->height; - rep.window = stuff->window; - rep.screen = stuff->screen; - if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - swapl(&rep.width); - swapl(&rep.height); - swapl(&rep.window); - swapl(&rep.screen); - } - WriteToClient (client, sizeof (xPanoramiXGetScreenSizeReply), (char *) &rep); - return Success; -} + REQUEST(xPanoramiXGetScreenSizeReq); + WindowPtr pWin; + xPanoramiXGetScreenSizeReply rep; + int rc; + if (stuff->screen >= PanoramiXNumScreens) + return BadMatch; + + REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq); + rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); + if (rc != Success) + return rc; + + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + /* screen dimensions */ + rep.width = screenInfo.screens[stuff->screen]->width; + rep.height = screenInfo.screens[stuff->screen]->height; + rep.window = stuff->window; + rep.screen = stuff->screen; + if (client->swapped) { + swaps(&rep.sequenceNumber); + swapl(&rep.length); + swapl(&rep.width); + swapl(&rep.height); + swapl(&rep.window); + swapl(&rep.screen); + } + WriteToClient(client, sizeof(xPanoramiXGetScreenSizeReply), (char *) &rep); + return Success; +} int ProcXineramaIsActive(ClientPtr client) { /* REQUEST(xXineramaIsActiveReq); */ - xXineramaIsActiveReply rep; + xXineramaIsActiveReply rep; REQUEST_SIZE_MATCH(xXineramaIsActiveReq); @@ -1031,28 +1026,27 @@ ProcXineramaIsActive(ClientPtr client) rep.sequenceNumber = client->sequence; #if 1 { - /* The following hack fools clients into thinking that Xinerama - * is disabled even though it is not. */ - rep.state = !noPanoramiXExtension && !PanoramiXExtensionDisabledHack; + /* The following hack fools clients into thinking that Xinerama + * is disabled even though it is not. */ + rep.state = !noPanoramiXExtension && !PanoramiXExtensionDisabledHack; } #else rep.state = !noPanoramiXExtension; #endif if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - swapl(&rep.state); - } - WriteToClient (client, sizeof (xXineramaIsActiveReply), (char *) &rep); + swaps(&rep.sequenceNumber); + swapl(&rep.length); + swapl(&rep.state); + } + WriteToClient(client, sizeof(xXineramaIsActiveReply), (char *) &rep); return Success; } - int ProcXineramaQueryScreens(ClientPtr client) { /* REQUEST(xXineramaQueryScreensReq); */ - xXineramaQueryScreensReply rep; + xXineramaQueryScreensReply rep; REQUEST_SIZE_MATCH(xXineramaQueryScreensReq); @@ -1061,58 +1055,56 @@ ProcXineramaQueryScreens(ClientPtr client) rep.number = (noPanoramiXExtension) ? 0 : PanoramiXNumScreens; rep.length = bytes_to_int32(rep.number * sz_XineramaScreenInfo); if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - swapl(&rep.number); - } - WriteToClient (client, sizeof (xXineramaQueryScreensReply), (char *) &rep); - - if(!noPanoramiXExtension) { - xXineramaScreenInfo scratch; - int i; - - FOR_NSCREENS(i) { - scratch.x_org = screenInfo.screens[i]->x; - scratch.y_org = screenInfo.screens[i]->y; - scratch.width = screenInfo.screens[i]->width; - scratch.height = screenInfo.screens[i]->height; - - if(client->swapped) { - swaps(&scratch.x_org); - swaps(&scratch.y_org); - swaps(&scratch.width); - swaps(&scratch.height); - } - WriteToClient (client, sz_XineramaScreenInfo, (char *) &scratch); - } + swaps(&rep.sequenceNumber); + swapl(&rep.length); + swapl(&rep.number); + } + WriteToClient(client, sizeof(xXineramaQueryScreensReply), (char *) &rep); + + if (!noPanoramiXExtension) { + xXineramaScreenInfo scratch; + int i; + + FOR_NSCREENS(i) { + scratch.x_org = screenInfo.screens[i]->x; + scratch.y_org = screenInfo.screens[i]->y; + scratch.width = screenInfo.screens[i]->width; + scratch.height = screenInfo.screens[i]->height; + + if (client->swapped) { + swaps(&scratch.x_org); + swaps(&scratch.y_org); + swaps(&scratch.width); + swaps(&scratch.height); + } + WriteToClient(client, sz_XineramaScreenInfo, (char *) &scratch); + } } return Success; } - static int -ProcPanoramiXDispatch (ClientPtr client) -{ REQUEST(xReq); - switch (stuff->data) - { - case X_PanoramiXQueryVersion: - return ProcPanoramiXQueryVersion(client); - case X_PanoramiXGetState: - return ProcPanoramiXGetState(client); - case X_PanoramiXGetScreenCount: - return ProcPanoramiXGetScreenCount(client); - case X_PanoramiXGetScreenSize: - return ProcPanoramiXGetScreenSize(client); - case X_XineramaIsActive: - return ProcXineramaIsActive(client); - case X_XineramaQueryScreens: - return ProcXineramaQueryScreens(client); +ProcPanoramiXDispatch(ClientPtr client) +{ + REQUEST(xReq); + switch (stuff->data) { + case X_PanoramiXQueryVersion: + return ProcPanoramiXQueryVersion(client); + case X_PanoramiXGetState: + return ProcPanoramiXGetState(client); + case X_PanoramiXGetScreenCount: + return ProcPanoramiXGetScreenCount(client); + case X_PanoramiXGetScreenSize: + return ProcPanoramiXGetScreenSize(client); + case X_XineramaIsActive: + return ProcXineramaIsActive(client); + case X_XineramaQueryScreens: + return ProcXineramaQueryScreens(client); } return BadRequest; } - #if X_BYTE_ORDER == X_LITTLE_ENDIAN #define SHIFT_L(v,s) (v) << (s) #define SHIFT_R(v,s) (v) >> (s) @@ -1124,34 +1116,31 @@ ProcPanoramiXDispatch (ClientPtr client) static void CopyBits(char *dst, int shiftL, char *src, int bytes) { - /* Just get it to work. Worry about speed later */ + /* Just get it to work. Worry about speed later */ int shiftR = 8 - shiftL; - while(bytes--) { - *dst |= SHIFT_L(*src, shiftL); - *(dst + 1) |= SHIFT_R(*src, shiftR); - dst++; src++; - } + while (bytes--) { + *dst |= SHIFT_L(*src, shiftL); + *(dst + 1) |= SHIFT_R(*src, shiftR); + dst++; + src++; + } } - /* Caution. This doesn't support 2 and 4 bpp formats. We expect 1 bpp and planar data to be already cleared when presented to this function */ void -XineramaGetImageData( - DrawablePtr *pDrawables, - int left, - int top, - int width, - int height, - unsigned int format, - unsigned long planemask, - char *data, - int pitch, - Bool isRoot -){ +XineramaGetImageData(DrawablePtr *pDrawables, + int left, + int top, + int width, + int height, + unsigned int format, + unsigned long planemask, + char *data, int pitch, Bool isRoot) +{ RegionRec SrcRegion, ScreenRegion, GrabRegion; BoxRec SrcBox, *pbox; int x, y, w, h, i, j, nbox, size, sizeNeeded, ScratchPitch, inOut, depth; @@ -1163,129 +1152,136 @@ XineramaGetImageData( /* find box in logical screen space */ SrcBox.x1 = left; SrcBox.y1 = top; - if(!isRoot) { - SrcBox.x1 += pDraw->x + screenInfo.screens[0]->x; - SrcBox.y1 += pDraw->y + screenInfo.screens[0]->y; + if (!isRoot) { + SrcBox.x1 += pDraw->x + screenInfo.screens[0]->x; + SrcBox.y1 += pDraw->y + screenInfo.screens[0]->y; } SrcBox.x2 = SrcBox.x1 + width; SrcBox.y2 = SrcBox.y1 + height; - + RegionInit(&SrcRegion, &SrcBox, 1); RegionNull(&GrabRegion); depth = (format == XYPixmap) ? 1 : pDraw->depth; FOR_NSCREENS(i) { - BoxRec TheBox; - ScreenPtr pScreen; - pDraw = pDrawables[i]; - pScreen = pDraw->pScreen; - - TheBox.x1 = pScreen->x; - TheBox.x2 = TheBox.x1 + pScreen->width; - TheBox.y1 = pScreen->y; - TheBox.y2 = TheBox.y1 + pScreen->height; - - RegionInit(&ScreenRegion, &TheBox, 1); - inOut = RegionContainsRect(&ScreenRegion, &SrcBox); - if(inOut == rgnPART) - RegionIntersect(&GrabRegion, &SrcRegion, &ScreenRegion); - RegionUninit(&ScreenRegion); - - if(inOut == rgnIN) { - (*pScreen->GetImage)(pDraw, - SrcBox.x1 - pDraw->x - screenInfo.screens[i]->x, - SrcBox.y1 - pDraw->y - screenInfo.screens[i]->y, - width, height, format, planemask, data); - break; - } else if (inOut == rgnOUT) - continue; - - nbox = RegionNumRects(&GrabRegion); - - if(nbox) { - pbox = RegionRects(&GrabRegion); - - while(nbox--) { - w = pbox->x2 - pbox->x1; - h = pbox->y2 - pbox->y1; - ScratchPitch = PixmapBytePad(w, depth); - sizeNeeded = ScratchPitch * h; - - if(sizeNeeded > size) { - char *tmpdata = ScratchMem; - ScratchMem = realloc(ScratchMem, sizeNeeded); - if(ScratchMem) - size = sizeNeeded; - else { - ScratchMem = tmpdata; - break; - } - } - - x = pbox->x1 - pDraw->x - screenInfo.screens[i]->x; - y = pbox->y1 - pDraw->y - screenInfo.screens[i]->y; - - (*pScreen->GetImage)(pDraw, x, y, w, h, - format, planemask, ScratchMem); - - /* copy the memory over */ - - if(depth == 1) { - int k, shift, leftover, index, index2; - - x = pbox->x1 - SrcBox.x1; - y = pbox->y1 - SrcBox.y1; - shift = x & 7; - x >>= 3; - leftover = w & 7; - w >>= 3; - - /* clean up the edge */ - if(leftover) { - int mask = (1 << leftover) - 1; - for(j = h, k = w; j--; k += ScratchPitch) - ScratchMem[k] &= mask; - } - - for(j = 0, index = (pitch * y) + x, index2 = 0; j < h; - j++, index += pitch, index2 += ScratchPitch) - { - if(w) { - if(!shift) - memcpy(data + index, ScratchMem + index2, w); - else - CopyBits(data + index, shift, - ScratchMem + index2, w); - } - - if(leftover) { - data[index + w] |= - SHIFT_L(ScratchMem[index2 + w], shift); - if((shift + leftover) > 8) - data[index + w + 1] |= - SHIFT_R(ScratchMem[index2 + w],(8 - shift)); - } - } - } else { - j = BitsPerPixel(depth) >> 3; - x = (pbox->x1 - SrcBox.x1) * j; - y = pbox->y1 - SrcBox.y1; - w *= j; - - for(j = 0; j < h; j++) { - memcpy(data + (pitch * (y + j)) + x, - ScratchMem + (ScratchPitch * j), w); - } - } - pbox++; - } - - RegionSubtract(&SrcRegion, &SrcRegion, &GrabRegion); - if(!RegionNotEmpty(&SrcRegion)) - break; - } - + BoxRec TheBox; + ScreenPtr pScreen; + + pDraw = pDrawables[i]; + pScreen = pDraw->pScreen; + + TheBox.x1 = pScreen->x; + TheBox.x2 = TheBox.x1 + pScreen->width; + TheBox.y1 = pScreen->y; + TheBox.y2 = TheBox.y1 + pScreen->height; + + RegionInit(&ScreenRegion, &TheBox, 1); + inOut = RegionContainsRect(&ScreenRegion, &SrcBox); + if (inOut == rgnPART) + RegionIntersect(&GrabRegion, &SrcRegion, &ScreenRegion); + RegionUninit(&ScreenRegion); + + if (inOut == rgnIN) { + (*pScreen->GetImage) (pDraw, + SrcBox.x1 - pDraw->x - + screenInfo.screens[i]->x, + SrcBox.y1 - pDraw->y - + screenInfo.screens[i]->y, width, height, + format, planemask, data); + break; + } + else if (inOut == rgnOUT) + continue; + + nbox = RegionNumRects(&GrabRegion); + + if (nbox) { + pbox = RegionRects(&GrabRegion); + + while (nbox--) { + w = pbox->x2 - pbox->x1; + h = pbox->y2 - pbox->y1; + ScratchPitch = PixmapBytePad(w, depth); + sizeNeeded = ScratchPitch * h; + + if (sizeNeeded > size) { + char *tmpdata = ScratchMem; + + ScratchMem = realloc(ScratchMem, sizeNeeded); + if (ScratchMem) + size = sizeNeeded; + else { + ScratchMem = tmpdata; + break; + } + } + + x = pbox->x1 - pDraw->x - screenInfo.screens[i]->x; + y = pbox->y1 - pDraw->y - screenInfo.screens[i]->y; + + (*pScreen->GetImage) (pDraw, x, y, w, h, + format, planemask, ScratchMem); + + /* copy the memory over */ + + if (depth == 1) { + int k, shift, leftover, index, index2; + + x = pbox->x1 - SrcBox.x1; + y = pbox->y1 - SrcBox.y1; + shift = x & 7; + x >>= 3; + leftover = w & 7; + w >>= 3; + + /* clean up the edge */ + if (leftover) { + int mask = (1 << leftover) - 1; + + for (j = h, k = w; j--; k += ScratchPitch) + ScratchMem[k] &= mask; + } + + for (j = 0, index = (pitch * y) + x, index2 = 0; j < h; + j++, index += pitch, index2 += ScratchPitch) { + if (w) { + if (!shift) + memcpy(data + index, ScratchMem + index2, w); + else + CopyBits(data + index, shift, + ScratchMem + index2, w); + } + + if (leftover) { + data[index + w] |= + SHIFT_L(ScratchMem[index2 + w], shift); + if ((shift + leftover) > 8) + data[index + w + 1] |= + SHIFT_R(ScratchMem[index2 + w], + (8 - shift)); + } + } + } + else { + j = BitsPerPixel(depth) >> 3; + x = (pbox->x1 - SrcBox.x1) * j; + y = pbox->y1 - SrcBox.y1; + w *= j; + + for (j = 0; j < h; j++) { + memcpy(data + (pitch * (y + j)) + x, + ScratchMem + (ScratchPitch * j), w); + } + } + pbox++; + } + + RegionSubtract(&SrcRegion, &SrcRegion, &GrabRegion); + if (!RegionNotEmpty(&SrcRegion)) + break; + } + } free(ScratchMem); diff --git a/Xext/panoramiX.h b/Xext/panoramiX.h index 71651e558..6578dfa17 100644 --- a/Xext/panoramiX.h +++ b/Xext/panoramiX.h @@ -26,7 +26,6 @@ Equipment Corporation. ******************************************************************/ - /* THIS IS NOT AN X PROJECT TEAM SPECIFICATION */ /* @@ -47,25 +46,25 @@ Equipment Corporation. #include "dixstruct.h" typedef struct _PanoramiXInfo { - XID id ; + XID id; } PanoramiXInfo; typedef struct { PanoramiXInfo info[MAXSCREENS]; RESTYPE type; union { - struct { - char visibility; - char class; - char root; - } win; - struct { - Bool shared; - } pix; - struct { - Bool root; - } pict; - char raw_data[4]; + struct { + char visibility; + char class; + char root; + } win; + struct { + Bool shared; + } pix; + struct { + Bool root; + } pict; + char raw_data[4]; } u; } PanoramiXRes; @@ -77,4 +76,4 @@ typedef struct { #define IS_SHARED_PIXMAP(r) (((r)->type == XRT_PIXMAP) && (r)->u.pix.shared) #define IS_ROOT_DRAWABLE(d) (((d)->type == XRT_WINDOW) && (d)->u.win.root) -#endif /* _PANORAMIX_H_ */ +#endif /* _PANORAMIX_H_ */ diff --git a/Xext/panoramiXSwap.c b/Xext/panoramiXSwap.c index 79277021a..b6ff6f918 100644 --- a/Xext/panoramiXSwap.c +++ b/Xext/panoramiXSwap.c @@ -48,89 +48,86 @@ Equipment Corporation. #include "panoramiXh.h" static int -SProcPanoramiXQueryVersion (ClientPtr client) +SProcPanoramiXQueryVersion(ClientPtr client) { - REQUEST(xPanoramiXQueryVersionReq); + REQUEST(xPanoramiXQueryVersionReq); - swaps(&stuff->length); - REQUEST_SIZE_MATCH (xPanoramiXQueryVersionReq); - return ProcPanoramiXQueryVersion(client); + swaps(&stuff->length); + REQUEST_SIZE_MATCH(xPanoramiXQueryVersionReq); + return ProcPanoramiXQueryVersion(client); } static int SProcPanoramiXGetState(ClientPtr client) { - REQUEST(xPanoramiXGetStateReq); + REQUEST(xPanoramiXGetStateReq); - swaps(&stuff->length); - REQUEST_SIZE_MATCH(xPanoramiXGetStateReq); - swapl(&stuff->window); - return ProcPanoramiXGetState(client); + swaps(&stuff->length); + REQUEST_SIZE_MATCH(xPanoramiXGetStateReq); + swapl(&stuff->window); + return ProcPanoramiXGetState(client); } -static int +static int SProcPanoramiXGetScreenCount(ClientPtr client) { - REQUEST(xPanoramiXGetScreenCountReq); + REQUEST(xPanoramiXGetScreenCountReq); - swaps(&stuff->length); - REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq); - swapl(&stuff->window); - return ProcPanoramiXGetScreenCount(client); + swaps(&stuff->length); + REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq); + swapl(&stuff->window); + return ProcPanoramiXGetScreenCount(client); } -static int +static int SProcPanoramiXGetScreenSize(ClientPtr client) { - REQUEST(xPanoramiXGetScreenSizeReq); + REQUEST(xPanoramiXGetScreenSizeReq); - swaps(&stuff->length); - REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq); - swapl(&stuff->window); - swapl(&stuff->screen); - return ProcPanoramiXGetScreenSize(client); + swaps(&stuff->length); + REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq); + swapl(&stuff->window); + swapl(&stuff->screen); + return ProcPanoramiXGetScreenSize(client); } - -static int +static int SProcXineramaIsActive(ClientPtr client) { - REQUEST(xXineramaIsActiveReq); + REQUEST(xXineramaIsActiveReq); - swaps(&stuff->length); - REQUEST_SIZE_MATCH(xXineramaIsActiveReq); - return ProcXineramaIsActive(client); + swaps(&stuff->length); + REQUEST_SIZE_MATCH(xXineramaIsActiveReq); + return ProcXineramaIsActive(client); } - -static int +static int SProcXineramaQueryScreens(ClientPtr client) { - REQUEST(xXineramaQueryScreensReq); + REQUEST(xXineramaQueryScreensReq); - swaps(&stuff->length); - REQUEST_SIZE_MATCH(xXineramaQueryScreensReq); - return ProcXineramaQueryScreens(client); + swaps(&stuff->length); + REQUEST_SIZE_MATCH(xXineramaQueryScreensReq); + return ProcXineramaQueryScreens(client); } - int -SProcPanoramiXDispatch (ClientPtr client) -{ REQUEST(xReq); - switch (stuff->data) - { - case X_PanoramiXQueryVersion: - return SProcPanoramiXQueryVersion(client); - case X_PanoramiXGetState: - return SProcPanoramiXGetState(client); - case X_PanoramiXGetScreenCount: - return SProcPanoramiXGetScreenCount(client); - case X_PanoramiXGetScreenSize: - return SProcPanoramiXGetScreenSize(client); - case X_XineramaIsActive: - return SProcXineramaIsActive(client); - case X_XineramaQueryScreens: - return SProcXineramaQueryScreens(client); +SProcPanoramiXDispatch(ClientPtr client) +{ + REQUEST(xReq); + switch (stuff->data) { + case X_PanoramiXQueryVersion: + return SProcPanoramiXQueryVersion(client); + case X_PanoramiXGetState: + return SProcPanoramiXGetState(client); + case X_PanoramiXGetScreenCount: + return SProcPanoramiXGetScreenCount(client); + case X_PanoramiXGetScreenSize: + return SProcPanoramiXGetScreenSize(client); + case X_XineramaIsActive: + return SProcXineramaIsActive(client); + case X_XineramaQueryScreens: + return SProcXineramaQueryScreens(client); } return BadRequest; } diff --git a/Xext/panoramiXh.h b/Xext/panoramiXh.h index 31b8f90b6..2762a59ac 100644 --- a/Xext/panoramiXh.h +++ b/Xext/panoramiXh.h @@ -16,7 +16,7 @@ extern int PanoramiXUnmapSubwindows(ClientPtr client); extern int PanoramiXConfigureWindow(ClientPtr client); extern int PanoramiXCirculateWindow(ClientPtr client); extern int PanoramiXGetGeometry(ClientPtr client); -extern int PanoramiXTranslateCoords(ClientPtr client); +extern int PanoramiXTranslateCoords(ClientPtr client); extern int PanoramiXCreatePixmap(ClientPtr client); extern int PanoramiXFreePixmap(ClientPtr client); extern int PanoramiXChangeGC(ClientPtr client); @@ -40,7 +40,7 @@ extern int PanoramiXPolyFillRectangle(ClientPtr client); extern int PanoramiXPutImage(ClientPtr client); extern int PanoramiXGetImage(ClientPtr client); extern int PanoramiXPolyText8(ClientPtr client); -extern int PanoramiXPolyText16(ClientPtr client); +extern int PanoramiXPolyText16(ClientPtr client); extern int PanoramiXImageText8(ClientPtr client); extern int PanoramiXImageText16(ClientPtr client); extern int PanoramiXCreateColormap(ClientPtr client); @@ -57,11 +57,11 @@ extern int PanoramiXAllocColorPlanes(ClientPtr client); #define PROC_EXTERN(pfunc) extern int pfunc(ClientPtr) -PROC_EXTERN(ProcPanoramiXQueryVersion); -PROC_EXTERN(ProcPanoramiXGetState); -PROC_EXTERN(ProcPanoramiXGetScreenCount); -PROC_EXTERN(ProcPanoramiXGetScreenSize); - +PROC_EXTERN(ProcPanoramiXQueryVersion); +PROC_EXTERN(ProcPanoramiXGetState); +PROC_EXTERN(ProcPanoramiXGetScreenCount); +PROC_EXTERN(ProcPanoramiXGetScreenSize); + PROC_EXTERN(ProcXineramaQueryScreens); PROC_EXTERN(ProcXineramaIsActive); @@ -70,4 +70,4 @@ extern int SProcPanoramiXDispatch(ClientPtr client); extern int connBlockScreenStart; extern xConnSetupPrefix connSetupPrefix; -extern int (* SavedProcVector[256]) (ClientPtr client); +extern int (*SavedProcVector[256]) (ClientPtr client); diff --git a/Xext/panoramiXprocs.c b/Xext/panoramiXprocs.c index 9ea461173..6a91e35d0 100644 --- a/Xext/panoramiXprocs.c +++ b/Xext/panoramiXprocs.c @@ -25,7 +25,6 @@ Equipment Corporation. /* Massively rewritten by Mark Vojkovich <markv@valinux.com> */ - #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> #endif @@ -52,12 +51,14 @@ Equipment Corporation. #define INPUTONLY_LEGAL_MASK (CWWinGravity | CWEventMask | \ CWDontPropagate | CWOverrideRedirect | CWCursor ) -int PanoramiXCreateWindow(ClientPtr client) +int +PanoramiXCreateWindow(ClientPtr client) { PanoramiXRes *parent, *newWin; PanoramiXRes *backPix = NULL; PanoramiXRes *bordPix = NULL; - PanoramiXRes *cmap = NULL; + PanoramiXRes *cmap = NULL; + REQUEST(xCreateWindowReq); int pback_offset = 0, pbord_offset = 0, cmap_offset = 0; int result, len, j; @@ -66,54 +67,55 @@ int PanoramiXCreateWindow(ClientPtr client) Bool parentIsRoot; REQUEST_AT_LEAST_SIZE(xCreateWindowReq); - + len = client->req_len - bytes_to_int32(sizeof(xCreateWindowReq)); if (Ones(stuff->mask) != len) return BadLength; - result = dixLookupResourceByType((pointer *)&parent, stuff->parent, - XRT_WINDOW, client, DixWriteAccess); + result = dixLookupResourceByType((pointer *) &parent, stuff->parent, + XRT_WINDOW, client, DixWriteAccess); if (result != Success) return result; - if(stuff->class == CopyFromParent) - stuff->class = parent->u.win.class; + if (stuff->class == CopyFromParent) + stuff->class = parent->u.win.class; - if((stuff->class == InputOnly) && (stuff->mask & (~INPUTONLY_LEGAL_MASK))) + if ((stuff->class == InputOnly) && (stuff->mask & (~INPUTONLY_LEGAL_MASK))) return BadMatch; - if ((Mask)stuff->mask & CWBackPixmap) { - pback_offset = Ones((Mask)stuff->mask & (CWBackPixmap - 1)); - tmp = *((CARD32 *) &stuff[1] + pback_offset); - if ((tmp != None) && (tmp != ParentRelative)) { - result = dixLookupResourceByType((pointer *)&backPix, tmp, - XRT_PIXMAP, client, DixReadAccess); - if (result != Success) - return result; - } - } - if ((Mask)stuff->mask & CWBorderPixmap) { - pbord_offset = Ones((Mask)stuff->mask & (CWBorderPixmap - 1)); - tmp = *((CARD32 *) &stuff[1] + pbord_offset); - if (tmp != CopyFromParent) { - result = dixLookupResourceByType((pointer *)&bordPix, tmp, - XRT_PIXMAP, client, DixReadAccess); - if (result != Success) - return result; - } - } - if ((Mask)stuff->mask & CWColormap) { - cmap_offset = Ones((Mask)stuff->mask & (CWColormap - 1)); - tmp = *((CARD32 *) &stuff[1] + cmap_offset); - if ((tmp != CopyFromParent) && (tmp != None)) { - result = dixLookupResourceByType((pointer *)&cmap, tmp, - XRT_COLORMAP, client, DixReadAccess); - if (result != Success) - return result; - } - } - - if(!(newWin = malloc(sizeof(PanoramiXRes)))) + if ((Mask) stuff->mask & CWBackPixmap) { + pback_offset = Ones((Mask) stuff->mask & (CWBackPixmap - 1)); + tmp = *((CARD32 *) &stuff[1] + pback_offset); + if ((tmp != None) && (tmp != ParentRelative)) { + result = dixLookupResourceByType((pointer *) &backPix, tmp, + XRT_PIXMAP, client, DixReadAccess); + if (result != Success) + return result; + } + } + if ((Mask) stuff->mask & CWBorderPixmap) { + pbord_offset = Ones((Mask) stuff->mask & (CWBorderPixmap - 1)); + tmp = *((CARD32 *) &stuff[1] + pbord_offset); + if (tmp != CopyFromParent) { + result = dixLookupResourceByType((pointer *) &bordPix, tmp, + XRT_PIXMAP, client, DixReadAccess); + if (result != Success) + return result; + } + } + if ((Mask) stuff->mask & CWColormap) { + cmap_offset = Ones((Mask) stuff->mask & (CWColormap - 1)); + tmp = *((CARD32 *) &stuff[1] + cmap_offset); + if ((tmp != CopyFromParent) && (tmp != None)) { + result = dixLookupResourceByType((pointer *) &cmap, tmp, + XRT_COLORMAP, client, + DixReadAccess); + if (result != Success) + return result; + } + } + + if (!(newWin = malloc(sizeof(PanoramiXRes)))) return BadAlloc; newWin->type = XRT_WINDOW; @@ -123,326 +125,346 @@ int PanoramiXCreateWindow(ClientPtr client) panoramix_setup_ids(newWin, client, stuff->wid); if (stuff->class == InputOnly) - stuff->visual = CopyFromParent; + stuff->visual = CopyFromParent; orig_visual = stuff->visual; orig_x = stuff->x; orig_y = stuff->y; - parentIsRoot = (stuff->parent == screenInfo.screens[0]->root->drawable.id) || - (stuff->parent == screenInfo.screens[0]->screensaver.wid); + parentIsRoot = (stuff->parent == screenInfo.screens[0]->root->drawable.id) + || (stuff->parent == screenInfo.screens[0]->screensaver.wid); FOR_NSCREENS_BACKWARD(j) { stuff->wid = newWin->info[j].id; stuff->parent = parent->info[j].id; - if (parentIsRoot) { - stuff->x = orig_x - screenInfo.screens[j]->x; - stuff->y = orig_y - screenInfo.screens[j]->y; - } - if (backPix) - *((CARD32 *) &stuff[1] + pback_offset) = backPix->info[j].id; - if (bordPix) - *((CARD32 *) &stuff[1] + pbord_offset) = bordPix->info[j].id; - if (cmap) - *((CARD32 *) &stuff[1] + cmap_offset) = cmap->info[j].id; - if ( orig_visual != CopyFromParent ) - stuff->visual = PanoramiXTranslateVisualID(j, orig_visual); - result = (*SavedProcVector[X_CreateWindow])(client); - if(result != Success) break; + if (parentIsRoot) { + stuff->x = orig_x - screenInfo.screens[j]->x; + stuff->y = orig_y - screenInfo.screens[j]->y; + } + if (backPix) + *((CARD32 *) &stuff[1] + pback_offset) = backPix->info[j].id; + if (bordPix) + *((CARD32 *) &stuff[1] + pbord_offset) = bordPix->info[j].id; + if (cmap) + *((CARD32 *) &stuff[1] + cmap_offset) = cmap->info[j].id; + if (orig_visual != CopyFromParent) + stuff->visual = PanoramiXTranslateVisualID(j, orig_visual); + result = (*SavedProcVector[X_CreateWindow]) (client); + if (result != Success) + break; } if (result == Success) AddResource(newWin->info[0].id, XRT_WINDOW, newWin); - else + else free(newWin); return result; } - -int PanoramiXChangeWindowAttributes(ClientPtr client) +int +PanoramiXChangeWindowAttributes(ClientPtr client) { PanoramiXRes *win; PanoramiXRes *backPix = NULL; PanoramiXRes *bordPix = NULL; - PanoramiXRes *cmap = NULL; + PanoramiXRes *cmap = NULL; + REQUEST(xChangeWindowAttributesReq); int pback_offset = 0, pbord_offset = 0, cmap_offset = 0; int result, len, j; XID tmp; REQUEST_AT_LEAST_SIZE(xChangeWindowAttributesReq); - + len = client->req_len - bytes_to_int32(sizeof(xChangeWindowAttributesReq)); if (Ones(stuff->valueMask) != len) return BadLength; - result = dixLookupResourceByType((pointer *)&win, stuff->window, - XRT_WINDOW, client, DixWriteAccess); + result = dixLookupResourceByType((pointer *) &win, stuff->window, + XRT_WINDOW, client, DixWriteAccess); if (result != Success) return result; - if((win->u.win.class == InputOnly) && - (stuff->valueMask & (~INPUTONLY_LEGAL_MASK))) + if ((win->u.win.class == InputOnly) && + (stuff->valueMask & (~INPUTONLY_LEGAL_MASK))) return BadMatch; - if ((Mask)stuff->valueMask & CWBackPixmap) { - pback_offset = Ones((Mask)stuff->valueMask & (CWBackPixmap - 1)); - tmp = *((CARD32 *) &stuff[1] + pback_offset); - if ((tmp != None) && (tmp != ParentRelative)) { - result = dixLookupResourceByType((pointer *)&backPix, tmp, - XRT_PIXMAP, client, DixReadAccess); - if (result != Success) - return result; - } - } - if ((Mask)stuff->valueMask & CWBorderPixmap) { - pbord_offset = Ones((Mask)stuff->valueMask & (CWBorderPixmap - 1)); - tmp = *((CARD32 *) &stuff[1] + pbord_offset); - if (tmp != CopyFromParent) { - result = dixLookupResourceByType((pointer *)&bordPix, tmp, - XRT_PIXMAP, client, DixReadAccess); - if (result != Success) - return result; - } - } - if ((Mask)stuff->valueMask & CWColormap) { - cmap_offset = Ones((Mask)stuff->valueMask & (CWColormap - 1)); - tmp = *((CARD32 *) &stuff[1] + cmap_offset); - if ((tmp != CopyFromParent) && (tmp != None)) { - result = dixLookupResourceByType((pointer *)&cmap, tmp, - XRT_COLORMAP, client, DixReadAccess); - if (result != Success) - return result; - } + if ((Mask) stuff->valueMask & CWBackPixmap) { + pback_offset = Ones((Mask) stuff->valueMask & (CWBackPixmap - 1)); + tmp = *((CARD32 *) &stuff[1] + pback_offset); + if ((tmp != None) && (tmp != ParentRelative)) { + result = dixLookupResourceByType((pointer *) &backPix, tmp, + XRT_PIXMAP, client, DixReadAccess); + if (result != Success) + return result; + } + } + if ((Mask) stuff->valueMask & CWBorderPixmap) { + pbord_offset = Ones((Mask) stuff->valueMask & (CWBorderPixmap - 1)); + tmp = *((CARD32 *) &stuff[1] + pbord_offset); + if (tmp != CopyFromParent) { + result = dixLookupResourceByType((pointer *) &bordPix, tmp, + XRT_PIXMAP, client, DixReadAccess); + if (result != Success) + return result; + } + } + if ((Mask) stuff->valueMask & CWColormap) { + cmap_offset = Ones((Mask) stuff->valueMask & (CWColormap - 1)); + tmp = *((CARD32 *) &stuff[1] + cmap_offset); + if ((tmp != CopyFromParent) && (tmp != None)) { + result = dixLookupResourceByType((pointer *) &cmap, tmp, + XRT_COLORMAP, client, + DixReadAccess); + if (result != Success) + return result; + } } FOR_NSCREENS_BACKWARD(j) { stuff->window = win->info[j].id; - if (backPix) - *((CARD32 *) &stuff[1] + pback_offset) = backPix->info[j].id; - if (bordPix) - *((CARD32 *) &stuff[1] + pbord_offset) = bordPix->info[j].id; - if (cmap) - *((CARD32 *) &stuff[1] + cmap_offset) = cmap->info[j].id; - result = (*SavedProcVector[X_ChangeWindowAttributes])(client); + if (backPix) + *((CARD32 *) &stuff[1] + pback_offset) = backPix->info[j].id; + if (bordPix) + *((CARD32 *) &stuff[1] + pbord_offset) = bordPix->info[j].id; + if (cmap) + *((CARD32 *) &stuff[1] + cmap_offset) = cmap->info[j].id; + result = (*SavedProcVector[X_ChangeWindowAttributes]) (client); } return result; } - -int PanoramiXDestroyWindow(ClientPtr client) +int +PanoramiXDestroyWindow(ClientPtr client) { PanoramiXRes *win; - int result, j; + int result, j; + REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); - result = dixLookupResourceByType((pointer *)&win, stuff->id, XRT_WINDOW, - client, DixDestroyAccess); + result = dixLookupResourceByType((pointer *) &win, stuff->id, XRT_WINDOW, + client, DixDestroyAccess); if (result != Success) - return result; + return result; FOR_NSCREENS_BACKWARD(j) { - stuff->id = win->info[j].id; - result = (*SavedProcVector[X_DestroyWindow])(client); - if(result != Success) break; + stuff->id = win->info[j].id; + result = (*SavedProcVector[X_DestroyWindow]) (client); + if (result != Success) + break; } /* Since ProcDestroyWindow is using FreeResource, it will free - our resource for us on the last pass through the loop above */ - + our resource for us on the last pass through the loop above */ + return result; } - -int PanoramiXDestroySubwindows(ClientPtr client) +int +PanoramiXDestroySubwindows(ClientPtr client) { PanoramiXRes *win; - int result, j; + int result, j; + REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); - result = dixLookupResourceByType((pointer *)&win, stuff->id, XRT_WINDOW, - client, DixDestroyAccess); + result = dixLookupResourceByType((pointer *) &win, stuff->id, XRT_WINDOW, + client, DixDestroyAccess); if (result != Success) - return result; + return result; FOR_NSCREENS_BACKWARD(j) { - stuff->id = win->info[j].id; - result = (*SavedProcVector[X_DestroySubwindows])(client); - if(result != Success) break; + stuff->id = win->info[j].id; + result = (*SavedProcVector[X_DestroySubwindows]) (client); + if (result != Success) + break; } /* DestroySubwindows is using FreeResource which will free - our resources for us on the last pass through the loop above */ + our resources for us on the last pass through the loop above */ return result; } - -int PanoramiXChangeSaveSet(ClientPtr client) +int +PanoramiXChangeSaveSet(ClientPtr client) { PanoramiXRes *win; - int result, j; + int result, j; + REQUEST(xChangeSaveSetReq); REQUEST_SIZE_MATCH(xChangeSaveSetReq); - result = dixLookupResourceByType((pointer *)&win, stuff->window, - XRT_WINDOW, client, DixReadAccess); + result = dixLookupResourceByType((pointer *) &win, stuff->window, + XRT_WINDOW, client, DixReadAccess); if (result != Success) - return result; + return result; FOR_NSCREENS_BACKWARD(j) { - stuff->window = win->info[j].id; - result = (*SavedProcVector[X_ChangeSaveSet])(client); - if(result != Success) break; + stuff->window = win->info[j].id; + result = (*SavedProcVector[X_ChangeSaveSet]) (client); + if (result != Success) + break; } return result; } - -int PanoramiXReparentWindow(ClientPtr client) +int +PanoramiXReparentWindow(ClientPtr client) { PanoramiXRes *win, *parent; - int result, j; - int x, y; - Bool parentIsRoot; + int result, j; + int x, y; + Bool parentIsRoot; + REQUEST(xReparentWindowReq); REQUEST_SIZE_MATCH(xReparentWindowReq); - result = dixLookupResourceByType((pointer *)&win, stuff->window, - XRT_WINDOW, client, DixWriteAccess); + result = dixLookupResourceByType((pointer *) &win, stuff->window, + XRT_WINDOW, client, DixWriteAccess); if (result != Success) - return result; + return result; - result = dixLookupResourceByType((pointer *)&parent, stuff->parent, - XRT_WINDOW, client, DixWriteAccess); + result = dixLookupResourceByType((pointer *) &parent, stuff->parent, + XRT_WINDOW, client, DixWriteAccess); if (result != Success) - return result; + return result; x = stuff->x; y = stuff->y; - parentIsRoot = (stuff->parent == screenInfo.screens[0]->root->drawable.id) || - (stuff->parent == screenInfo.screens[0]->screensaver.wid); + parentIsRoot = (stuff->parent == screenInfo.screens[0]->root->drawable.id) + || (stuff->parent == screenInfo.screens[0]->screensaver.wid); FOR_NSCREENS_BACKWARD(j) { - stuff->window = win->info[j].id; - stuff->parent = parent->info[j].id; - if(parentIsRoot) { - stuff->x = x - screenInfo.screens[j]->x; - stuff->y = y - screenInfo.screens[j]->y; - } - result = (*SavedProcVector[X_ReparentWindow])(client); - if(result != Success) break; + stuff->window = win->info[j].id; + stuff->parent = parent->info[j].id; + if (parentIsRoot) { + stuff->x = x - screenInfo.screens[j]->x; + stuff->y = y - screenInfo.screens[j]->y; + } + result = (*SavedProcVector[X_ReparentWindow]) (client); + if (result != Success) + break; } return result; } - -int PanoramiXMapWindow(ClientPtr client) +int +PanoramiXMapWindow(ClientPtr client) { PanoramiXRes *win; - int result, j; + int result, j; + REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); - result = dixLookupResourceByType((pointer *)&win, stuff->id, - XRT_WINDOW, client, DixReadAccess); + result = dixLookupResourceByType((pointer *) &win, stuff->id, + XRT_WINDOW, client, DixReadAccess); if (result != Success) - return result; + return result; FOR_NSCREENS_FORWARD(j) { - stuff->id = win->info[j].id; - result = (*SavedProcVector[X_MapWindow])(client); - if(result != Success) break; + stuff->id = win->info[j].id; + result = (*SavedProcVector[X_MapWindow]) (client); + if (result != Success) + break; } return result; } - -int PanoramiXMapSubwindows(ClientPtr client) +int +PanoramiXMapSubwindows(ClientPtr client) { PanoramiXRes *win; - int result, j; + int result, j; + REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); - result = dixLookupResourceByType((pointer *)&win, stuff->id, - XRT_WINDOW, client, DixReadAccess); + result = dixLookupResourceByType((pointer *) &win, stuff->id, + XRT_WINDOW, client, DixReadAccess); if (result != Success) - return result; + return result; FOR_NSCREENS_FORWARD(j) { - stuff->id = win->info[j].id; - result = (*SavedProcVector[X_MapSubwindows])(client); - if(result != Success) break; + stuff->id = win->info[j].id; + result = (*SavedProcVector[X_MapSubwindows]) (client); + if (result != Success) + break; } return result; } - -int PanoramiXUnmapWindow(ClientPtr client) +int +PanoramiXUnmapWindow(ClientPtr client) { PanoramiXRes *win; - int result, j; + int result, j; + REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); - result = dixLookupResourceByType((pointer *)&win, stuff->id, - XRT_WINDOW, client, DixReadAccess); + result = dixLookupResourceByType((pointer *) &win, stuff->id, + XRT_WINDOW, client, DixReadAccess); if (result != Success) - return result; + return result; FOR_NSCREENS_FORWARD(j) { - stuff->id = win->info[j].id; - result = (*SavedProcVector[X_UnmapWindow])(client); - if(result != Success) break; + stuff->id = win->info[j].id; + result = (*SavedProcVector[X_UnmapWindow]) (client); + if (result != Success) + break; } return result; } - -int PanoramiXUnmapSubwindows(ClientPtr client) +int +PanoramiXUnmapSubwindows(ClientPtr client) { PanoramiXRes *win; - int result, j; + int result, j; + REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); - result = dixLookupResourceByType((pointer *)&win, stuff->id, - XRT_WINDOW, client, DixReadAccess); + result = dixLookupResourceByType((pointer *) &win, stuff->id, + XRT_WINDOW, client, DixReadAccess); if (result != Success) - return result; + return result; FOR_NSCREENS_FORWARD(j) { - stuff->id = win->info[j].id; - result = (*SavedProcVector[X_UnmapSubwindows])(client); - if(result != Success) break; + stuff->id = win->info[j].id; + result = (*SavedProcVector[X_UnmapSubwindows]) (client); + if (result != Success) + break; } return result; } - -int PanoramiXConfigureWindow(ClientPtr client) +int +PanoramiXConfigureWindow(ClientPtr client) { PanoramiXRes *win; PanoramiXRes *sib = NULL; - WindowPtr pWin; - int result, j, len, sib_offset = 0, x = 0, y = 0; - int x_offset = -1; - int y_offset = -1; + WindowPtr pWin; + int result, j, len, sib_offset = 0, x = 0, y = 0; + int x_offset = -1; + int y_offset = -1; + REQUEST(xConfigureWindowReq); REQUEST_AT_LEAST_SIZE(xConfigureWindowReq); @@ -452,92 +474,97 @@ int PanoramiXConfigureWindow(ClientPtr client) return BadLength; /* because we need the parent */ - result = dixLookupResourceByType((pointer *)&pWin, stuff->window, - RT_WINDOW, client, DixWriteAccess); + result = dixLookupResourceByType((pointer *) &pWin, stuff->window, + RT_WINDOW, client, DixWriteAccess); if (result != Success) - return result; + return result; - result = dixLookupResourceByType((pointer *)&win, stuff->window, - XRT_WINDOW, client, DixWriteAccess); + result = dixLookupResourceByType((pointer *) &win, stuff->window, + XRT_WINDOW, client, DixWriteAccess); if (result != Success) - return result; + return result; + + if ((Mask) stuff->mask & CWSibling) { + XID tmp; - if ((Mask)stuff->mask & CWSibling) { - XID tmp; - sib_offset = Ones((Mask)stuff->mask & (CWSibling - 1)); - if ((tmp = *((CARD32 *) &stuff[1] + sib_offset))) { - result = dixLookupResourceByType((pointer *)&sib, tmp, XRT_WINDOW, - client, DixReadAccess); - if (result != Success) - return result; - } + sib_offset = Ones((Mask) stuff->mask & (CWSibling - 1)); + if ((tmp = *((CARD32 *) &stuff[1] + sib_offset))) { + result = dixLookupResourceByType((pointer *) &sib, tmp, XRT_WINDOW, + client, DixReadAccess); + if (result != Success) + return result; + } } - if(pWin->parent && ((pWin->parent == screenInfo.screens[0]->root) || - (pWin->parent->drawable.id == screenInfo.screens[0]->screensaver.wid))) - { - if ((Mask)stuff->mask & CWX) { - x_offset = 0; - x = *((CARD32 *)&stuff[1]); - } - if ((Mask)stuff->mask & CWY) { - y_offset = (x_offset == -1) ? 0 : 1; - y = *((CARD32 *) &stuff[1] + y_offset); - } + if (pWin->parent && ((pWin->parent == screenInfo.screens[0]->root) || + (pWin->parent->drawable.id == + screenInfo.screens[0]->screensaver.wid))) { + if ((Mask) stuff->mask & CWX) { + x_offset = 0; + x = *((CARD32 *) &stuff[1]); + } + if ((Mask) stuff->mask & CWY) { + y_offset = (x_offset == -1) ? 0 : 1; + y = *((CARD32 *) &stuff[1] + y_offset); + } } /* have to go forward or you get expose events before - ConfigureNotify events */ + ConfigureNotify events */ FOR_NSCREENS_FORWARD(j) { - stuff->window = win->info[j].id; - if(sib) - *((CARD32 *) &stuff[1] + sib_offset) = sib->info[j].id; - if(x_offset >= 0) - *((CARD32 *) &stuff[1] + x_offset) = x - screenInfo.screens[j]->x; - if(y_offset >= 0) - *((CARD32 *) &stuff[1] + y_offset) = y - screenInfo.screens[j]->y; - result = (*SavedProcVector[X_ConfigureWindow])(client); - if(result != Success) break; + stuff->window = win->info[j].id; + if (sib) + *((CARD32 *) &stuff[1] + sib_offset) = sib->info[j].id; + if (x_offset >= 0) + *((CARD32 *) &stuff[1] + x_offset) = x - screenInfo.screens[j]->x; + if (y_offset >= 0) + *((CARD32 *) &stuff[1] + y_offset) = y - screenInfo.screens[j]->y; + result = (*SavedProcVector[X_ConfigureWindow]) (client); + if (result != Success) + break; } return result; } - -int PanoramiXCirculateWindow(ClientPtr client) +int +PanoramiXCirculateWindow(ClientPtr client) { PanoramiXRes *win; - int result, j; + int result, j; + REQUEST(xCirculateWindowReq); REQUEST_SIZE_MATCH(xCirculateWindowReq); - result = dixLookupResourceByType((pointer *)&win, stuff->window, - XRT_WINDOW, client, DixWriteAccess); + result = dixLookupResourceByType((pointer *) &win, stuff->window, + XRT_WINDOW, client, DixWriteAccess); if (result != Success) - return result; + return result; FOR_NSCREENS_FORWARD(j) { - stuff->window = win->info[j].id; - result = (*SavedProcVector[X_CirculateWindow])(client); - if(result != Success) break; + stuff->window = win->info[j].id; + result = (*SavedProcVector[X_CirculateWindow]) (client); + if (result != Success) + break; } return result; } - -int PanoramiXGetGeometry(ClientPtr client) +int +PanoramiXGetGeometry(ClientPtr client) { - xGetGeometryReply rep; + xGetGeometryReply rep; DrawablePtr pDraw; int rc; + REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); rc = dixLookupDrawable(&pDraw, stuff->id, client, M_ANY, DixGetAttrAccess); if (rc != Success) - return rc; + return rc; rep.type = X_Reply; rep.length = 0; @@ -549,33 +576,35 @@ int PanoramiXGetGeometry(ClientPtr client) rep.x = rep.y = rep.borderWidth = 0; if (stuff->id == rep.root) { - xWindowRoot *root = (xWindowRoot *) - (ConnectionInfo + connBlockScreenStart); - - rep.width = root->pixWidth; - rep.height = root->pixHeight; - } else - if (WindowDrawable(pDraw->type)) - { - WindowPtr pWin = (WindowPtr)pDraw; - rep.x = pWin->origin.x - wBorderWidth (pWin); - rep.y = pWin->origin.y - wBorderWidth (pWin); - if((pWin->parent == screenInfo.screens[0]->root) || - (pWin->parent->drawable.id == screenInfo.screens[0]->screensaver.wid)) - { - rep.x += screenInfo.screens[0]->x; - rep.y += screenInfo.screens[0]->y; - } - rep.borderWidth = pWin->borderWidth; + xWindowRoot *root = (xWindowRoot *) + (ConnectionInfo + connBlockScreenStart); + + rep.width = root->pixWidth; + rep.height = root->pixHeight; + } + else if (WindowDrawable(pDraw->type)) { + WindowPtr pWin = (WindowPtr) pDraw; + + rep.x = pWin->origin.x - wBorderWidth(pWin); + rep.y = pWin->origin.y - wBorderWidth(pWin); + if ((pWin->parent == screenInfo.screens[0]->root) || + (pWin->parent->drawable.id == + screenInfo.screens[0]->screensaver.wid)) { + rep.x += screenInfo.screens[0]->x; + rep.y += screenInfo.screens[0]->y; + } + rep.borderWidth = pWin->borderWidth; } WriteReplyToClient(client, sizeof(xGetGeometryReply), &rep); return Success; } -int PanoramiXTranslateCoords(ClientPtr client) +int +PanoramiXTranslateCoords(ClientPtr client) { INT16 x, y; + REQUEST(xTranslateCoordsReq); int rc; WindowPtr pWin, pDst; @@ -594,172 +623,177 @@ int PanoramiXTranslateCoords(ClientPtr client) rep.sameScreen = xTrue; rep.child = None; - if((pWin == screenInfo.screens[0]->root) || - (pWin->drawable.id == screenInfo.screens[0]->screensaver.wid)) - { - x = stuff->srcX - screenInfo.screens[0]->x; - y = stuff->srcY - screenInfo.screens[0]->y; - } else { - x = pWin->drawable.x + stuff->srcX; - y = pWin->drawable.y + stuff->srcY; + if ((pWin == screenInfo.screens[0]->root) || + (pWin->drawable.id == screenInfo.screens[0]->screensaver.wid)) { + x = stuff->srcX - screenInfo.screens[0]->x; + y = stuff->srcY - screenInfo.screens[0]->y; + } + else { + x = pWin->drawable.x + stuff->srcX; + y = pWin->drawable.y + stuff->srcY; } pWin = pDst->firstChild; while (pWin) { - BoxRec box; - if ((pWin->mapped) && - (x >= pWin->drawable.x - wBorderWidth (pWin)) && - (x < pWin->drawable.x + (int)pWin->drawable.width + - wBorderWidth (pWin)) && - (y >= pWin->drawable.y - wBorderWidth (pWin)) && - (y < pWin->drawable.y + (int)pWin->drawable.height + - wBorderWidth (pWin)) - /* When a window is shaped, a further check - * is made to see if the point is inside - * borderSize - */ - && (!wBoundingShape(pWin) || - RegionContainsPoint(wBoundingShape(pWin), - x - pWin->drawable.x, - y - pWin->drawable.y, &box)) - ) - { - rep.child = pWin->drawable.id; - pWin = (WindowPtr) NULL; - } - else - pWin = pWin->nextSib; + BoxRec box; + + if ((pWin->mapped) && + (x >= pWin->drawable.x - wBorderWidth(pWin)) && + (x < pWin->drawable.x + (int) pWin->drawable.width + + wBorderWidth(pWin)) && + (y >= pWin->drawable.y - wBorderWidth(pWin)) && + (y < pWin->drawable.y + (int) pWin->drawable.height + + wBorderWidth(pWin)) + /* When a window is shaped, a further check + * is made to see if the point is inside + * borderSize + */ + && (!wBoundingShape(pWin) || + RegionContainsPoint(wBoundingShape(pWin), + x - pWin->drawable.x, + y - pWin->drawable.y, &box)) + ) { + rep.child = pWin->drawable.id; + pWin = (WindowPtr) NULL; + } + else + pWin = pWin->nextSib; } rep.dstX = x - pDst->drawable.x; rep.dstY = y - pDst->drawable.y; - if((pDst == screenInfo.screens[0]->root) || - (pDst->drawable.id == screenInfo.screens[0]->screensaver.wid)) - { - rep.dstX += screenInfo.screens[0]->x; - rep.dstY += screenInfo.screens[0]->y; + if ((pDst == screenInfo.screens[0]->root) || + (pDst->drawable.id == screenInfo.screens[0]->screensaver.wid)) { + rep.dstX += screenInfo.screens[0]->x; + rep.dstY += screenInfo.screens[0]->y; } WriteReplyToClient(client, sizeof(xTranslateCoordsReply), &rep); return Success; } -int PanoramiXCreatePixmap(ClientPtr client) +int +PanoramiXCreatePixmap(ClientPtr client) { PanoramiXRes *refDraw, *newPix; int result, j; + REQUEST(xCreatePixmapReq); REQUEST_SIZE_MATCH(xCreatePixmapReq); client->errorValue = stuff->pid; - result = dixLookupResourceByClass((pointer *)&refDraw, stuff->drawable, - XRC_DRAWABLE, client, DixReadAccess); + result = dixLookupResourceByClass((pointer *) &refDraw, stuff->drawable, + XRC_DRAWABLE, client, DixReadAccess); if (result != Success) - return (result == BadValue) ? BadDrawable : result; + return (result == BadValue) ? BadDrawable : result; - if(!(newPix = malloc(sizeof(PanoramiXRes)))) - return BadAlloc; + if (!(newPix = malloc(sizeof(PanoramiXRes)))) + return BadAlloc; newPix->type = XRT_PIXMAP; newPix->u.pix.shared = FALSE; panoramix_setup_ids(newPix, client, stuff->pid); - + FOR_NSCREENS_BACKWARD(j) { - stuff->pid = newPix->info[j].id; - stuff->drawable = refDraw->info[j].id; - result = (*SavedProcVector[X_CreatePixmap])(client); - if(result != Success) break; + stuff->pid = newPix->info[j].id; + stuff->drawable = refDraw->info[j].id; + result = (*SavedProcVector[X_CreatePixmap]) (client); + if (result != Success) + break; } if (result == Success) - AddResource(newPix->info[0].id, XRT_PIXMAP, newPix); - else - free(newPix); + AddResource(newPix->info[0].id, XRT_PIXMAP, newPix); + else + free(newPix); return result; } - -int PanoramiXFreePixmap(ClientPtr client) +int +PanoramiXFreePixmap(ClientPtr client) { PanoramiXRes *pix; - int result, j; + int result, j; + REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); client->errorValue = stuff->id; - result = dixLookupResourceByType((pointer *)&pix, stuff->id, XRT_PIXMAP, - client, DixDestroyAccess); + result = dixLookupResourceByType((pointer *) &pix, stuff->id, XRT_PIXMAP, + client, DixDestroyAccess); if (result != Success) - return result; + return result; FOR_NSCREENS_BACKWARD(j) { - stuff->id = pix->info[j].id; - result = (*SavedProcVector[X_FreePixmap])(client); - if(result != Success) break; + stuff->id = pix->info[j].id; + result = (*SavedProcVector[X_FreePixmap]) (client); + if (result != Success) + break; } /* Since ProcFreePixmap is using FreeResource, it will free - our resource for us on the last pass through the loop above */ - + our resource for us on the last pass through the loop above */ + return result; } - -int PanoramiXCreateGC(ClientPtr client) +int +PanoramiXCreateGC(ClientPtr client) { PanoramiXRes *refDraw; PanoramiXRes *newGC; PanoramiXRes *stip = NULL; PanoramiXRes *tile = NULL; PanoramiXRes *clip = NULL; + REQUEST(xCreateGCReq); int tile_offset = 0, stip_offset = 0, clip_offset = 0; int result, len, j; XID tmp; REQUEST_AT_LEAST_SIZE(xCreateGCReq); - + client->errorValue = stuff->gc; len = client->req_len - bytes_to_int32(sizeof(xCreateGCReq)); if (Ones(stuff->mask) != len) return BadLength; - result = dixLookupResourceByClass((pointer *)&refDraw, stuff->drawable, - XRC_DRAWABLE, client, DixReadAccess); - if (result != Success) - return (result == BadValue) ? BadDrawable : result; - - if ((Mask)stuff->mask & GCTile) { - tile_offset = Ones((Mask)stuff->mask & (GCTile - 1)); - if ((tmp = *((CARD32 *) &stuff[1] + tile_offset))) { - result = dixLookupResourceByType((pointer *)&tile, tmp, XRT_PIXMAP, - client, DixReadAccess); - if (result != Success) - return result; - } - } - if ((Mask)stuff->mask & GCStipple) { - stip_offset = Ones((Mask)stuff->mask & (GCStipple - 1)); - if ((tmp = *((CARD32 *) &stuff[1] + stip_offset))) { - result = dixLookupResourceByType((pointer *)&stip, tmp, XRT_PIXMAP, - client, DixReadAccess); - if (result != Success) - return result; - } - } - if ((Mask)stuff->mask & GCClipMask) { - clip_offset = Ones((Mask)stuff->mask & (GCClipMask - 1)); - if ((tmp = *((CARD32 *) &stuff[1] + clip_offset))) { - result = dixLookupResourceByType((pointer *)&clip, tmp, XRT_PIXMAP, - client, DixReadAccess); - if (result != Success) - return result; - } - } - - if(!(newGC = malloc(sizeof(PanoramiXRes)))) + result = dixLookupResourceByClass((pointer *) &refDraw, stuff->drawable, + XRC_DRAWABLE, client, DixReadAccess); + if (result != Success) + return (result == BadValue) ? BadDrawable : result; + + if ((Mask) stuff->mask & GCTile) { + tile_offset = Ones((Mask) stuff->mask & (GCTile - 1)); + if ((tmp = *((CARD32 *) &stuff[1] + tile_offset))) { + result = dixLookupResourceByType((pointer *) &tile, tmp, XRT_PIXMAP, + client, DixReadAccess); + if (result != Success) + return result; + } + } + if ((Mask) stuff->mask & GCStipple) { + stip_offset = Ones((Mask) stuff->mask & (GCStipple - 1)); + if ((tmp = *((CARD32 *) &stuff[1] + stip_offset))) { + result = dixLookupResourceByType((pointer *) &stip, tmp, XRT_PIXMAP, + client, DixReadAccess); + if (result != Success) + return result; + } + } + if ((Mask) stuff->mask & GCClipMask) { + clip_offset = Ones((Mask) stuff->mask & (GCClipMask - 1)); + if ((tmp = *((CARD32 *) &stuff[1] + clip_offset))) { + result = dixLookupResourceByType((pointer *) &clip, tmp, XRT_PIXMAP, + client, DixReadAccess); + if (result != Success) + return result; + } + } + + if (!(newGC = malloc(sizeof(PanoramiXRes)))) return BadAlloc; newGC->type = XRT_GC; @@ -768,223 +802,235 @@ int PanoramiXCreateGC(ClientPtr client) FOR_NSCREENS_BACKWARD(j) { stuff->gc = newGC->info[j].id; stuff->drawable = refDraw->info[j].id; - if (tile) - *((CARD32 *) &stuff[1] + tile_offset) = tile->info[j].id; - if (stip) - *((CARD32 *) &stuff[1] + stip_offset) = stip->info[j].id; - if (clip) - *((CARD32 *) &stuff[1] + clip_offset) = clip->info[j].id; - result = (*SavedProcVector[X_CreateGC])(client); - if(result != Success) break; + if (tile) + *((CARD32 *) &stuff[1] + tile_offset) = tile->info[j].id; + if (stip) + *((CARD32 *) &stuff[1] + stip_offset) = stip->info[j].id; + if (clip) + *((CARD32 *) &stuff[1] + clip_offset) = clip->info[j].id; + result = (*SavedProcVector[X_CreateGC]) (client); + if (result != Success) + break; } if (result == Success) AddResource(newGC->info[0].id, XRT_GC, newGC); - else + else free(newGC); return result; } -int PanoramiXChangeGC(ClientPtr client) +int +PanoramiXChangeGC(ClientPtr client) { PanoramiXRes *gc; PanoramiXRes *stip = NULL; PanoramiXRes *tile = NULL; PanoramiXRes *clip = NULL; + REQUEST(xChangeGCReq); int tile_offset = 0, stip_offset = 0, clip_offset = 0; int result, len, j; XID tmp; REQUEST_AT_LEAST_SIZE(xChangeGCReq); - + len = client->req_len - bytes_to_int32(sizeof(xChangeGCReq)); if (Ones(stuff->mask) != len) return BadLength; - result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, - client, DixReadAccess); + result = dixLookupResourceByType((pointer *) &gc, stuff->gc, XRT_GC, + client, DixReadAccess); if (result != Success) - return result; + return result; - if ((Mask)stuff->mask & GCTile) { - tile_offset = Ones((Mask)stuff->mask & (GCTile - 1)); - if ((tmp = *((CARD32 *) &stuff[1] + tile_offset))) { - result = dixLookupResourceByType((pointer *)&tile, tmp, XRT_PIXMAP, - client, DixReadAccess); - if (result != Success) - return result; - } + if ((Mask) stuff->mask & GCTile) { + tile_offset = Ones((Mask) stuff->mask & (GCTile - 1)); + if ((tmp = *((CARD32 *) &stuff[1] + tile_offset))) { + result = dixLookupResourceByType((pointer *) &tile, tmp, XRT_PIXMAP, + client, DixReadAccess); + if (result != Success) + return result; + } } - if ((Mask)stuff->mask & GCStipple) { - stip_offset = Ones((Mask)stuff->mask & (GCStipple - 1)); - if ((tmp = *((CARD32 *) &stuff[1] + stip_offset))) { - result = dixLookupResourceByType((pointer *)&stip, tmp, XRT_PIXMAP, - client, DixReadAccess); - if (result != Success) - return result; - } + if ((Mask) stuff->mask & GCStipple) { + stip_offset = Ones((Mask) stuff->mask & (GCStipple - 1)); + if ((tmp = *((CARD32 *) &stuff[1] + stip_offset))) { + result = dixLookupResourceByType((pointer *) &stip, tmp, XRT_PIXMAP, + client, DixReadAccess); + if (result != Success) + return result; + } } - if ((Mask)stuff->mask & GCClipMask) { - clip_offset = Ones((Mask)stuff->mask & (GCClipMask - 1)); - if ((tmp = *((CARD32 *) &stuff[1] + clip_offset))) { - result = dixLookupResourceByType((pointer *)&clip, tmp, XRT_PIXMAP, - client, DixReadAccess); - if (result != Success) - return result; - } + if ((Mask) stuff->mask & GCClipMask) { + clip_offset = Ones((Mask) stuff->mask & (GCClipMask - 1)); + if ((tmp = *((CARD32 *) &stuff[1] + clip_offset))) { + result = dixLookupResourceByType((pointer *) &clip, tmp, XRT_PIXMAP, + client, DixReadAccess); + if (result != Success) + return result; + } } - FOR_NSCREENS_BACKWARD(j) { stuff->gc = gc->info[j].id; - if (tile) - *((CARD32 *) &stuff[1] + tile_offset) = tile->info[j].id; - if (stip) - *((CARD32 *) &stuff[1] + stip_offset) = stip->info[j].id; - if (clip) - *((CARD32 *) &stuff[1] + clip_offset) = clip->info[j].id; - result = (*SavedProcVector[X_ChangeGC])(client); - if(result != Success) break; + if (tile) + *((CARD32 *) &stuff[1] + tile_offset) = tile->info[j].id; + if (stip) + *((CARD32 *) &stuff[1] + stip_offset) = stip->info[j].id; + if (clip) + *((CARD32 *) &stuff[1] + clip_offset) = clip->info[j].id; + result = (*SavedProcVector[X_ChangeGC]) (client); + if (result != Success) + break; } return result; } - -int PanoramiXCopyGC(ClientPtr client) +int +PanoramiXCopyGC(ClientPtr client) { PanoramiXRes *srcGC, *dstGC; - int result, j; + int result, j; + REQUEST(xCopyGCReq); REQUEST_SIZE_MATCH(xCopyGCReq); - result = dixLookupResourceByType((pointer *)&srcGC, stuff->srcGC, XRT_GC, - client, DixReadAccess); + result = dixLookupResourceByType((pointer *) &srcGC, stuff->srcGC, XRT_GC, + client, DixReadAccess); if (result != Success) - return result; + return result; - result = dixLookupResourceByType((pointer *)&dstGC, stuff->dstGC, XRT_GC, - client, DixWriteAccess); + result = dixLookupResourceByType((pointer *) &dstGC, stuff->dstGC, XRT_GC, + client, DixWriteAccess); if (result != Success) - return result; + return result; FOR_NSCREENS(j) { - stuff->srcGC = srcGC->info[j].id; - stuff->dstGC = dstGC->info[j].id; - result = (*SavedProcVector[X_CopyGC])(client); - if(result != Success) break; + stuff->srcGC = srcGC->info[j].id; + stuff->dstGC = dstGC->info[j].id; + result = (*SavedProcVector[X_CopyGC]) (client); + if (result != Success) + break; } return result; } - -int PanoramiXSetDashes(ClientPtr client) +int +PanoramiXSetDashes(ClientPtr client) { PanoramiXRes *gc; - int result, j; + int result, j; + REQUEST(xSetDashesReq); REQUEST_FIXED_SIZE(xSetDashesReq, stuff->nDashes); - result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, - client, DixWriteAccess); + result = dixLookupResourceByType((pointer *) &gc, stuff->gc, XRT_GC, + client, DixWriteAccess); if (result != Success) - return result; + return result; FOR_NSCREENS_BACKWARD(j) { - stuff->gc = gc->info[j].id; - result = (*SavedProcVector[X_SetDashes])(client); - if(result != Success) break; + stuff->gc = gc->info[j].id; + result = (*SavedProcVector[X_SetDashes]) (client); + if (result != Success) + break; } return result; } - -int PanoramiXSetClipRectangles(ClientPtr client) +int +PanoramiXSetClipRectangles(ClientPtr client) { PanoramiXRes *gc; - int result, j; + int result, j; + REQUEST(xSetClipRectanglesReq); REQUEST_AT_LEAST_SIZE(xSetClipRectanglesReq); - result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, - client, DixWriteAccess); + result = dixLookupResourceByType((pointer *) &gc, stuff->gc, XRT_GC, + client, DixWriteAccess); if (result != Success) - return result; + return result; FOR_NSCREENS_BACKWARD(j) { - stuff->gc = gc->info[j].id; - result = (*SavedProcVector[X_SetClipRectangles])(client); - if(result != Success) break; + stuff->gc = gc->info[j].id; + result = (*SavedProcVector[X_SetClipRectangles]) (client); + if (result != Success) + break; } return result; } - -int PanoramiXFreeGC(ClientPtr client) +int +PanoramiXFreeGC(ClientPtr client) { PanoramiXRes *gc; - int result, j; + int result, j; + REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); - result = dixLookupResourceByType((pointer *)&gc, stuff->id, XRT_GC, - client, DixDestroyAccess); + result = dixLookupResourceByType((pointer *) &gc, stuff->id, XRT_GC, + client, DixDestroyAccess); if (result != Success) - return result; + return result; FOR_NSCREENS_BACKWARD(j) { - stuff->id = gc->info[j].id; - result = (*SavedProcVector[X_FreeGC])(client); - if(result != Success) break; + stuff->id = gc->info[j].id; + result = (*SavedProcVector[X_FreeGC]) (client); + if (result != Success) + break; } /* Since ProcFreeGC is using FreeResource, it will free - our resource for us on the last pass through the loop above */ - + our resource for us on the last pass through the loop above */ + return result; } - -int PanoramiXClearToBackground(ClientPtr client) +int +PanoramiXClearToBackground(ClientPtr client) { PanoramiXRes *win; - int result, j, x, y; - Bool isRoot; + int result, j, x, y; + Bool isRoot; + REQUEST(xClearAreaReq); REQUEST_SIZE_MATCH(xClearAreaReq); - result = dixLookupResourceByType((pointer *)&win, stuff->window, - XRT_WINDOW, client, DixWriteAccess); + result = dixLookupResourceByType((pointer *) &win, stuff->window, + XRT_WINDOW, client, DixWriteAccess); if (result != Success) - return result; + return result; x = stuff->x; y = stuff->y; isRoot = win->u.win.root; FOR_NSCREENS_BACKWARD(j) { - stuff->window = win->info[j].id; - if(isRoot) { - stuff->x = x - screenInfo.screens[j]->x; - stuff->y = y - screenInfo.screens[j]->y; - } - result = (*SavedProcVector[X_ClearArea])(client); - if(result != Success) break; - } - + stuff->window = win->info[j].id; + if (isRoot) { + stuff->x = x - screenInfo.screens[j]->x; + stuff->y = y - screenInfo.screens[j]->y; + } + result = (*SavedProcVector[X_ClearArea]) (client); + if (result != Success) + break; + } + return result; } - /* For Window to Pixmap copies you're screwed since each screen's pixmap will look like what it sees on its screen. Unless the @@ -995,821 +1041,882 @@ int PanoramiXClearToBackground(ClientPtr client) have to fix this later. (MArk). */ -int PanoramiXCopyArea(ClientPtr client) +int +PanoramiXCopyArea(ClientPtr client) { - int j, result, srcx, srcy, dstx, dsty; - PanoramiXRes *gc, *src, *dst; - Bool srcIsRoot = FALSE; - Bool dstIsRoot = FALSE; - Bool srcShared, dstShared; + int j, result, srcx, srcy, dstx, dsty; + PanoramiXRes *gc, *src, *dst; + Bool srcIsRoot = FALSE; + Bool dstIsRoot = FALSE; + Bool srcShared, dstShared; + REQUEST(xCopyAreaReq); REQUEST_SIZE_MATCH(xCopyAreaReq); - result = dixLookupResourceByClass((pointer *)&src, stuff->srcDrawable, - XRC_DRAWABLE, client, DixReadAccess); + result = dixLookupResourceByClass((pointer *) &src, stuff->srcDrawable, + XRC_DRAWABLE, client, DixReadAccess); if (result != Success) - return (result == BadValue) ? BadDrawable : result; + return (result == BadValue) ? BadDrawable : result; srcShared = IS_SHARED_PIXMAP(src); - result = dixLookupResourceByClass((pointer *)&dst, stuff->dstDrawable, - XRC_DRAWABLE, client, DixWriteAccess); + result = dixLookupResourceByClass((pointer *) &dst, stuff->dstDrawable, + XRC_DRAWABLE, client, DixWriteAccess); if (result != Success) - return (result == BadValue) ? BadDrawable : result; + return (result == BadValue) ? BadDrawable : result; dstShared = IS_SHARED_PIXMAP(dst); - if(dstShared && srcShared) - return (* SavedProcVector[X_CopyArea])(client); + if (dstShared && srcShared) + return (*SavedProcVector[X_CopyArea]) (client); - result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, - client, DixReadAccess); + result = dixLookupResourceByType((pointer *) &gc, stuff->gc, XRT_GC, + client, DixReadAccess); if (result != Success) - return result; - - if((dst->type == XRT_WINDOW) && dst->u.win.root) - dstIsRoot = TRUE; - if((src->type == XRT_WINDOW) && src->u.win.root) - srcIsRoot = TRUE; + return result; - srcx = stuff->srcX; srcy = stuff->srcY; - dstx = stuff->dstX; dsty = stuff->dstY; - if((dst->type == XRT_PIXMAP) && (src->type == XRT_WINDOW)) { - DrawablePtr drawables[MAXSCREENS]; - DrawablePtr pDst; - GCPtr pGC; + if ((dst->type == XRT_WINDOW) && dst->u.win.root) + dstIsRoot = TRUE; + if ((src->type == XRT_WINDOW) && src->u.win.root) + srcIsRoot = TRUE; + + srcx = stuff->srcX; + srcy = stuff->srcY; + dstx = stuff->dstX; + dsty = stuff->dstY; + if ((dst->type == XRT_PIXMAP) && (src->type == XRT_WINDOW)) { + DrawablePtr drawables[MAXSCREENS]; + DrawablePtr pDst; + GCPtr pGC; char *data; - int pitch, rc; - - FOR_NSCREENS(j) { - rc = dixLookupDrawable(drawables+j, src->info[j].id, client, 0, - DixGetAttrAccess); - if (rc != Success) - return rc; - } - - pitch = PixmapBytePad(stuff->width, drawables[0]->depth); - if(!(data = calloc(1, stuff->height * pitch))) - return BadAlloc; - - XineramaGetImageData(drawables, srcx, srcy, - stuff->width, stuff->height, ZPixmap, ~0, data, pitch, - srcIsRoot); - - FOR_NSCREENS_BACKWARD(j) { - stuff->gc = gc->info[j].id; - VALIDATE_DRAWABLE_AND_GC(dst->info[j].id, pDst, DixWriteAccess); - if(drawables[0]->depth != pDst->depth) { - client->errorValue = stuff->dstDrawable; - free(data); - return BadMatch; - } - - (*pGC->ops->PutImage) (pDst, pGC, pDst->depth, dstx, dsty, - stuff->width, stuff->height, - 0, ZPixmap, data); - - if(dstShared) break; - } - - free(data); - } else { - DrawablePtr pDst = NULL, pSrc = NULL; - GCPtr pGC = NULL; - RegionRec totalReg; - int rc; - - RegionNull(&totalReg); - FOR_NSCREENS_BACKWARD(j) { - RegionPtr pRgn; - stuff->dstDrawable = dst->info[j].id; - stuff->srcDrawable = src->info[j].id; - stuff->gc = gc->info[j].id; - if (srcIsRoot) { - stuff->srcX = srcx - screenInfo.screens[j]->x; - stuff->srcY = srcy - screenInfo.screens[j]->y; - } - if (dstIsRoot) { - stuff->dstX = dstx - screenInfo.screens[j]->x; - stuff->dstY = dsty - screenInfo.screens[j]->y; - } - - VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pDst, DixWriteAccess); - - if (stuff->dstDrawable != stuff->srcDrawable) { - rc = dixLookupDrawable(&pSrc, stuff->srcDrawable, client, 0, - DixReadAccess); - if (rc != Success) - return rc; - - if ((pDst->pScreen != pSrc->pScreen) || - (pDst->depth != pSrc->depth)) { - client->errorValue = stuff->dstDrawable; - return BadMatch; - } - } else - pSrc = pDst; - - pRgn = (*pGC->ops->CopyArea)(pSrc, pDst, pGC, - stuff->srcX, stuff->srcY, - stuff->width, stuff->height, - stuff->dstX, stuff->dstY); - if(pGC->graphicsExposures && pRgn) { - if(srcIsRoot) { - RegionTranslate(pRgn, - screenInfo.screens[j]->x, screenInfo.screens[j]->y); - } - RegionAppend(&totalReg, pRgn); - RegionDestroy(pRgn); - } - - if(dstShared) - break; - } - - if(pGC->graphicsExposures) { - Bool overlap; - RegionValidate(&totalReg, &overlap); - (*pDst->pScreen->SendGraphicsExpose)( - client, &totalReg, stuff->dstDrawable, X_CopyArea, 0); - RegionUninit(&totalReg); - } + int pitch, rc; + + FOR_NSCREENS(j) { + rc = dixLookupDrawable(drawables + j, src->info[j].id, client, 0, + DixGetAttrAccess); + if (rc != Success) + return rc; + } + + pitch = PixmapBytePad(stuff->width, drawables[0]->depth); + if (!(data = calloc(1, stuff->height * pitch))) + return BadAlloc; + + XineramaGetImageData(drawables, srcx, srcy, + stuff->width, stuff->height, ZPixmap, ~0, data, + pitch, srcIsRoot); + + FOR_NSCREENS_BACKWARD(j) { + stuff->gc = gc->info[j].id; + VALIDATE_DRAWABLE_AND_GC(dst->info[j].id, pDst, DixWriteAccess); + if (drawables[0]->depth != pDst->depth) { + client->errorValue = stuff->dstDrawable; + free(data); + return BadMatch; + } + + (*pGC->ops->PutImage) (pDst, pGC, pDst->depth, dstx, dsty, + stuff->width, stuff->height, + 0, ZPixmap, data); + + if (dstShared) + break; + } + + free(data); + } + else { + DrawablePtr pDst = NULL, pSrc = NULL; + GCPtr pGC = NULL; + RegionRec totalReg; + int rc; + + RegionNull(&totalReg); + FOR_NSCREENS_BACKWARD(j) { + RegionPtr pRgn; + + stuff->dstDrawable = dst->info[j].id; + stuff->srcDrawable = src->info[j].id; + stuff->gc = gc->info[j].id; + if (srcIsRoot) { + stuff->srcX = srcx - screenInfo.screens[j]->x; + stuff->srcY = srcy - screenInfo.screens[j]->y; + } + if (dstIsRoot) { + stuff->dstX = dstx - screenInfo.screens[j]->x; + stuff->dstY = dsty - screenInfo.screens[j]->y; + } + + VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pDst, DixWriteAccess); + + if (stuff->dstDrawable != stuff->srcDrawable) { + rc = dixLookupDrawable(&pSrc, stuff->srcDrawable, client, 0, + DixReadAccess); + if (rc != Success) + return rc; + + if ((pDst->pScreen != pSrc->pScreen) || + (pDst->depth != pSrc->depth)) { + client->errorValue = stuff->dstDrawable; + return BadMatch; + } + } + else + pSrc = pDst; + + pRgn = (*pGC->ops->CopyArea) (pSrc, pDst, pGC, + stuff->srcX, stuff->srcY, + stuff->width, stuff->height, + stuff->dstX, stuff->dstY); + if (pGC->graphicsExposures && pRgn) { + if (srcIsRoot) { + RegionTranslate(pRgn, + screenInfo.screens[j]->x, + screenInfo.screens[j]->y); + } + RegionAppend(&totalReg, pRgn); + RegionDestroy(pRgn); + } + + if (dstShared) + break; + } + + if (pGC->graphicsExposures) { + Bool overlap; + + RegionValidate(&totalReg, &overlap); + (*pDst->pScreen->SendGraphicsExpose) (client, &totalReg, + stuff->dstDrawable, + X_CopyArea, 0); + RegionUninit(&totalReg); + } } return Success; } - -int PanoramiXCopyPlane(ClientPtr client) +int +PanoramiXCopyPlane(ClientPtr client) { - int j, srcx, srcy, dstx, dsty, rc; - PanoramiXRes *gc, *src, *dst; - Bool srcIsRoot = FALSE; - Bool dstIsRoot = FALSE; - Bool srcShared, dstShared; - DrawablePtr psrcDraw, pdstDraw = NULL; - GCPtr pGC = NULL; - RegionRec totalReg; + int j, srcx, srcy, dstx, dsty, rc; + PanoramiXRes *gc, *src, *dst; + Bool srcIsRoot = FALSE; + Bool dstIsRoot = FALSE; + Bool srcShared, dstShared; + DrawablePtr psrcDraw, pdstDraw = NULL; + GCPtr pGC = NULL; + RegionRec totalReg; + REQUEST(xCopyPlaneReq); REQUEST_SIZE_MATCH(xCopyPlaneReq); - rc = dixLookupResourceByClass((pointer *)&src, stuff->srcDrawable, - XRC_DRAWABLE, client, DixReadAccess); + rc = dixLookupResourceByClass((pointer *) &src, stuff->srcDrawable, + XRC_DRAWABLE, client, DixReadAccess); if (rc != Success) - return (rc == BadValue) ? BadDrawable : rc; + return (rc == BadValue) ? BadDrawable : rc; srcShared = IS_SHARED_PIXMAP(src); - rc = dixLookupResourceByClass((pointer *)&dst, stuff->dstDrawable, - XRC_DRAWABLE, client, DixWriteAccess); + rc = dixLookupResourceByClass((pointer *) &dst, stuff->dstDrawable, + XRC_DRAWABLE, client, DixWriteAccess); if (rc != Success) - return (rc == BadValue) ? BadDrawable : rc; + return (rc == BadValue) ? BadDrawable : rc; dstShared = IS_SHARED_PIXMAP(dst); - if(dstShared && srcShared) - return (* SavedProcVector[X_CopyPlane])(client); + if (dstShared && srcShared) + return (*SavedProcVector[X_CopyPlane]) (client); - rc = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, - client, DixReadAccess); + rc = dixLookupResourceByType((pointer *) &gc, stuff->gc, XRT_GC, + client, DixReadAccess); if (rc != Success) - return rc; + return rc; - if((dst->type == XRT_WINDOW) && dst->u.win.root) - dstIsRoot = TRUE; - if((src->type == XRT_WINDOW) && src->u.win.root) - srcIsRoot = TRUE; + if ((dst->type == XRT_WINDOW) && dst->u.win.root) + dstIsRoot = TRUE; + if ((src->type == XRT_WINDOW) && src->u.win.root) + srcIsRoot = TRUE; + + srcx = stuff->srcX; + srcy = stuff->srcY; + dstx = stuff->dstX; + dsty = stuff->dstY; - srcx = stuff->srcX; srcy = stuff->srcY; - dstx = stuff->dstX; dsty = stuff->dstY; - RegionNull(&totalReg); FOR_NSCREENS_BACKWARD(j) { - RegionPtr pRgn; - stuff->dstDrawable = dst->info[j].id; - stuff->srcDrawable = src->info[j].id; - stuff->gc = gc->info[j].id; - if (srcIsRoot) { - stuff->srcX = srcx - screenInfo.screens[j]->x; - stuff->srcY = srcy - screenInfo.screens[j]->y; - } - if (dstIsRoot) { - stuff->dstX = dstx - screenInfo.screens[j]->x; - stuff->dstY = dsty - screenInfo.screens[j]->y; - } - - VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pdstDraw, DixWriteAccess); - if (stuff->dstDrawable != stuff->srcDrawable) { - rc = dixLookupDrawable(&psrcDraw, stuff->srcDrawable, client, 0, - DixReadAccess); - if (rc != Success) - return rc; + RegionPtr pRgn; + + stuff->dstDrawable = dst->info[j].id; + stuff->srcDrawable = src->info[j].id; + stuff->gc = gc->info[j].id; + if (srcIsRoot) { + stuff->srcX = srcx - screenInfo.screens[j]->x; + stuff->srcY = srcy - screenInfo.screens[j]->y; + } + if (dstIsRoot) { + stuff->dstX = dstx - screenInfo.screens[j]->x; + stuff->dstY = dsty - screenInfo.screens[j]->y; + } + + VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pdstDraw, DixWriteAccess); + if (stuff->dstDrawable != stuff->srcDrawable) { + rc = dixLookupDrawable(&psrcDraw, stuff->srcDrawable, client, 0, + DixReadAccess); + if (rc != Success) + return rc; if (pdstDraw->pScreen != psrcDraw->pScreen) { - client->errorValue = stuff->dstDrawable; - return BadMatch; - } - } else - psrcDraw = pdstDraw; - - if(stuff->bitPlane == 0 || (stuff->bitPlane & (stuff->bitPlane - 1)) || - (stuff->bitPlane > (1L << (psrcDraw->depth - 1)))) { - client->errorValue = stuff->bitPlane; - return BadValue; - } - - pRgn = (*pGC->ops->CopyPlane)(psrcDraw, pdstDraw, pGC, - stuff->srcX, stuff->srcY, - stuff->width, stuff->height, - stuff->dstX, stuff->dstY, stuff->bitPlane); - if(pGC->graphicsExposures && pRgn) { - RegionAppend(&totalReg, pRgn); - RegionDestroy(pRgn); - } - - if(dstShared) - break; - } - - if(pGC->graphicsExposures) { - Bool overlap; - RegionValidate(&totalReg, &overlap); - (*pdstDraw->pScreen->SendGraphicsExpose)( - client, &totalReg, stuff->dstDrawable, X_CopyPlane, 0); - RegionUninit(&totalReg); + client->errorValue = stuff->dstDrawable; + return BadMatch; + } + } + else + psrcDraw = pdstDraw; + + if (stuff->bitPlane == 0 || (stuff->bitPlane & (stuff->bitPlane - 1)) || + (stuff->bitPlane > (1L << (psrcDraw->depth - 1)))) { + client->errorValue = stuff->bitPlane; + return BadValue; + } + + pRgn = (*pGC->ops->CopyPlane) (psrcDraw, pdstDraw, pGC, + stuff->srcX, stuff->srcY, + stuff->width, stuff->height, + stuff->dstX, stuff->dstY, + stuff->bitPlane); + if (pGC->graphicsExposures && pRgn) { + RegionAppend(&totalReg, pRgn); + RegionDestroy(pRgn); + } + + if (dstShared) + break; + } + + if (pGC->graphicsExposures) { + Bool overlap; + + RegionValidate(&totalReg, &overlap); + (*pdstDraw->pScreen->SendGraphicsExpose) (client, &totalReg, + stuff->dstDrawable, + X_CopyPlane, 0); + RegionUninit(&totalReg); } return Success; } - -int PanoramiXPolyPoint(ClientPtr client) +int +PanoramiXPolyPoint(ClientPtr client) { PanoramiXRes *gc, *draw; - int result, npoint, j; - xPoint *origPts; - Bool isRoot; + int result, npoint, j; + xPoint *origPts; + Bool isRoot; + REQUEST(xPolyPointReq); REQUEST_AT_LEAST_SIZE(xPolyPointReq); - result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, - XRC_DRAWABLE, client, DixWriteAccess); + result = dixLookupResourceByClass((pointer *) &draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); if (result != Success) - return (result == BadValue) ? BadDrawable : result; + return (result == BadValue) ? BadDrawable : result; - if(IS_SHARED_PIXMAP(draw)) - return (*SavedProcVector[X_PolyPoint])(client); + if (IS_SHARED_PIXMAP(draw)) + return (*SavedProcVector[X_PolyPoint]) (client); - result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, - client, DixReadAccess); + result = dixLookupResourceByType((pointer *) &gc, stuff->gc, XRT_GC, + client, DixReadAccess); if (result != Success) - return result; + return result; isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; npoint = bytes_to_int32((client->req_len << 2) - sizeof(xPolyPointReq)); if (npoint > 0) { origPts = malloc(npoint * sizeof(xPoint)); memcpy((char *) origPts, (char *) &stuff[1], npoint * sizeof(xPoint)); - FOR_NSCREENS_FORWARD(j){ + FOR_NSCREENS_FORWARD(j) { - if(j) memcpy(&stuff[1], origPts, npoint * sizeof(xPoint)); + if (j) + memcpy(&stuff[1], origPts, npoint * sizeof(xPoint)); if (isRoot) { int x_off = screenInfo.screens[j]->x; int y_off = screenInfo.screens[j]->y; - if(x_off || y_off) { - xPoint *pnts = (xPoint*)&stuff[1]; - int i = (stuff->coordMode==CoordModePrevious) ? 1 : npoint; + if (x_off || y_off) { + xPoint *pnts = (xPoint *) & stuff[1]; + int i = + (stuff->coordMode == CoordModePrevious) ? 1 : npoint; - while(i--) { - pnts->x -= x_off; - pnts->y -= y_off; - pnts++; + while (i--) { + pnts->x -= x_off; + pnts->y -= y_off; + pnts++; } - } + } } - stuff->drawable = draw->info[j].id; - stuff->gc = gc->info[j].id; - result = (* SavedProcVector[X_PolyPoint])(client); - if(result != Success) break; + stuff->drawable = draw->info[j].id; + stuff->gc = gc->info[j].id; + result = (*SavedProcVector[X_PolyPoint]) (client); + if (result != Success) + break; } free(origPts); return result; - } else - return Success; + } + else + return Success; } - -int PanoramiXPolyLine(ClientPtr client) +int +PanoramiXPolyLine(ClientPtr client) { PanoramiXRes *gc, *draw; - int result, npoint, j; - xPoint *origPts; - Bool isRoot; + int result, npoint, j; + xPoint *origPts; + Bool isRoot; + REQUEST(xPolyLineReq); REQUEST_AT_LEAST_SIZE(xPolyLineReq); - result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, - XRC_DRAWABLE, client, DixWriteAccess); + result = dixLookupResourceByClass((pointer *) &draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); if (result != Success) - return (result == BadValue) ? BadDrawable : result; + return (result == BadValue) ? BadDrawable : result; - if(IS_SHARED_PIXMAP(draw)) - return (*SavedProcVector[X_PolyLine])(client); + if (IS_SHARED_PIXMAP(draw)) + return (*SavedProcVector[X_PolyLine]) (client); - result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, - client, DixReadAccess); + result = dixLookupResourceByType((pointer *) &gc, stuff->gc, XRT_GC, + client, DixReadAccess); if (result != Success) - return result; + return result; isRoot = IS_ROOT_DRAWABLE(draw); npoint = bytes_to_int32((client->req_len << 2) - sizeof(xPolyLineReq)); - if (npoint > 0){ + if (npoint > 0) { origPts = malloc(npoint * sizeof(xPoint)); memcpy((char *) origPts, (char *) &stuff[1], npoint * sizeof(xPoint)); - FOR_NSCREENS_FORWARD(j){ + FOR_NSCREENS_FORWARD(j) { - if(j) memcpy(&stuff[1], origPts, npoint * sizeof(xPoint)); + if (j) + memcpy(&stuff[1], origPts, npoint * sizeof(xPoint)); if (isRoot) { int x_off = screenInfo.screens[j]->x; int y_off = screenInfo.screens[j]->y; - if(x_off || y_off) { - xPoint *pnts = (xPoint*)&stuff[1]; - int i = (stuff->coordMode==CoordModePrevious) ? 1 : npoint; + if (x_off || y_off) { + xPoint *pnts = (xPoint *) & stuff[1]; + int i = + (stuff->coordMode == CoordModePrevious) ? 1 : npoint; - while(i--) { - pnts->x -= x_off; - pnts->y -= y_off; - pnts++; - } - } + while (i--) { + pnts->x -= x_off; + pnts->y -= y_off; + pnts++; + } + } } - stuff->drawable = draw->info[j].id; - stuff->gc = gc->info[j].id; - result = (* SavedProcVector[X_PolyLine])(client); - if(result != Success) break; + stuff->drawable = draw->info[j].id; + stuff->gc = gc->info[j].id; + result = (*SavedProcVector[X_PolyLine]) (client); + if (result != Success) + break; } free(origPts); return result; - } else - return Success; + } + else + return Success; } - -int PanoramiXPolySegment(ClientPtr client) +int +PanoramiXPolySegment(ClientPtr client) { - int result, nsegs, i, j; + int result, nsegs, i, j; PanoramiXRes *gc, *draw; - xSegment *origSegs; - Bool isRoot; + xSegment *origSegs; + Bool isRoot; + REQUEST(xPolySegmentReq); REQUEST_AT_LEAST_SIZE(xPolySegmentReq); - result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, - XRC_DRAWABLE, client, DixWriteAccess); + result = dixLookupResourceByClass((pointer *) &draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); if (result != Success) - return (result == BadValue) ? BadDrawable : result; + return (result == BadValue) ? BadDrawable : result; - if(IS_SHARED_PIXMAP(draw)) - return (*SavedProcVector[X_PolySegment])(client); + if (IS_SHARED_PIXMAP(draw)) + return (*SavedProcVector[X_PolySegment]) (client); - result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, - client, DixReadAccess); + result = dixLookupResourceByType((pointer *) &gc, stuff->gc, XRT_GC, + client, DixReadAccess); if (result != Success) - return result; + return result; isRoot = IS_ROOT_DRAWABLE(draw); nsegs = (client->req_len << 2) - sizeof(xPolySegmentReq); - if(nsegs & 4) return BadLength; + if (nsegs & 4) + return BadLength; nsegs >>= 3; if (nsegs > 0) { - origSegs = malloc(nsegs * sizeof(xSegment)); + origSegs = malloc(nsegs * sizeof(xSegment)); memcpy((char *) origSegs, (char *) &stuff[1], nsegs * sizeof(xSegment)); - FOR_NSCREENS_FORWARD(j){ + FOR_NSCREENS_FORWARD(j) { - if(j) memcpy(&stuff[1], origSegs, nsegs * sizeof(xSegment)); + if (j) + memcpy(&stuff[1], origSegs, nsegs * sizeof(xSegment)); if (isRoot) { int x_off = screenInfo.screens[j]->x; int y_off = screenInfo.screens[j]->y; - if(x_off || y_off) { - xSegment *segs = (xSegment*)&stuff[1]; + if (x_off || y_off) { + xSegment *segs = (xSegment *) & stuff[1]; - for (i = nsegs; i--; segs++) { - segs->x1 -= x_off; - segs->x2 -= x_off; - segs->y1 -= y_off; - segs->y2 -= y_off; - } - } + for (i = nsegs; i--; segs++) { + segs->x1 -= x_off; + segs->x2 -= x_off; + segs->y1 -= y_off; + segs->y2 -= y_off; + } + } } - stuff->drawable = draw->info[j].id; - stuff->gc = gc->info[j].id; - result = (* SavedProcVector[X_PolySegment])(client); - if(result != Success) break; - } - free(origSegs); - return result; - } else - return Success; + stuff->drawable = draw->info[j].id; + stuff->gc = gc->info[j].id; + result = (*SavedProcVector[X_PolySegment]) (client); + if (result != Success) + break; + } + free(origSegs); + return result; + } + else + return Success; } - -int PanoramiXPolyRectangle(ClientPtr client) +int +PanoramiXPolyRectangle(ClientPtr client) { - int result, nrects, i, j; + int result, nrects, i, j; PanoramiXRes *gc, *draw; - Bool isRoot; - xRectangle *origRecs; + Bool isRoot; + xRectangle *origRecs; + REQUEST(xPolyRectangleReq); REQUEST_AT_LEAST_SIZE(xPolyRectangleReq); - result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, - XRC_DRAWABLE, client, DixWriteAccess); + result = dixLookupResourceByClass((pointer *) &draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); if (result != Success) - return (result == BadValue) ? BadDrawable : result; + return (result == BadValue) ? BadDrawable : result; - if(IS_SHARED_PIXMAP(draw)) - return (*SavedProcVector[X_PolyRectangle])(client); + if (IS_SHARED_PIXMAP(draw)) + return (*SavedProcVector[X_PolyRectangle]) (client); - result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, - client, DixReadAccess); + result = dixLookupResourceByType((pointer *) &gc, stuff->gc, XRT_GC, + client, DixReadAccess); if (result != Success) - return result; + return result; isRoot = IS_ROOT_DRAWABLE(draw); nrects = (client->req_len << 2) - sizeof(xPolyRectangleReq); - if(nrects & 4) return BadLength; + if (nrects & 4) + return BadLength; nrects >>= 3; - if (nrects > 0){ - origRecs = malloc(nrects * sizeof(xRectangle)); - memcpy((char *)origRecs,(char *)&stuff[1],nrects * sizeof(xRectangle)); - FOR_NSCREENS_FORWARD(j){ - - if(j) memcpy(&stuff[1], origRecs, nrects * sizeof(xRectangle)); - - if (isRoot) { - int x_off = screenInfo.screens[j]->x; - int y_off = screenInfo.screens[j]->y; - - - if(x_off || y_off) { - xRectangle *rects = (xRectangle *) &stuff[1]; - - for (i = nrects; i--; rects++) { - rects->x -= x_off; - rects->y -= y_off; - } - } - } - - stuff->drawable = draw->info[j].id; - stuff->gc = gc->info[j].id; - result = (* SavedProcVector[X_PolyRectangle])(client); - if(result != Success) break; - } - free(origRecs); - return result; - } else - return Success; -} + if (nrects > 0) { + origRecs = malloc(nrects * sizeof(xRectangle)); + memcpy((char *) origRecs, (char *) &stuff[1], + nrects * sizeof(xRectangle)); + FOR_NSCREENS_FORWARD(j) { + + if (j) + memcpy(&stuff[1], origRecs, nrects * sizeof(xRectangle)); + + if (isRoot) { + int x_off = screenInfo.screens[j]->x; + int y_off = screenInfo.screens[j]->y; + if (x_off || y_off) { + xRectangle *rects = (xRectangle *) &stuff[1]; + + for (i = nrects; i--; rects++) { + rects->x -= x_off; + rects->y -= y_off; + } + } + } + + stuff->drawable = draw->info[j].id; + stuff->gc = gc->info[j].id; + result = (*SavedProcVector[X_PolyRectangle]) (client); + if (result != Success) + break; + } + free(origRecs); + return result; + } + else + return Success; +} -int PanoramiXPolyArc(ClientPtr client) +int +PanoramiXPolyArc(ClientPtr client) { - int result, narcs, i, j; + int result, narcs, i, j; PanoramiXRes *gc, *draw; - Bool isRoot; - xArc *origArcs; + Bool isRoot; + xArc *origArcs; + REQUEST(xPolyArcReq); REQUEST_AT_LEAST_SIZE(xPolyArcReq); - result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, - XRC_DRAWABLE, client, DixWriteAccess); + result = dixLookupResourceByClass((pointer *) &draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); if (result != Success) - return (result == BadValue) ? BadDrawable : result; + return (result == BadValue) ? BadDrawable : result; - if(IS_SHARED_PIXMAP(draw)) - return (*SavedProcVector[X_PolyArc])(client); + if (IS_SHARED_PIXMAP(draw)) + return (*SavedProcVector[X_PolyArc]) (client); - result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, - client, DixReadAccess); + result = dixLookupResourceByType((pointer *) &gc, stuff->gc, XRT_GC, + client, DixReadAccess); if (result != Success) - return result; + return result; isRoot = IS_ROOT_DRAWABLE(draw); narcs = (client->req_len << 2) - sizeof(xPolyArcReq); - if(narcs % sizeof(xArc)) return BadLength; + if (narcs % sizeof(xArc)) + return BadLength; narcs /= sizeof(xArc); - if (narcs > 0){ - origArcs = malloc(narcs * sizeof(xArc)); - memcpy((char *) origArcs, (char *) &stuff[1], narcs * sizeof(xArc)); - FOR_NSCREENS_FORWARD(j){ - - if(j) memcpy(&stuff[1], origArcs, narcs * sizeof(xArc)); - - if (isRoot) { - int x_off = screenInfo.screens[j]->x; - int y_off = screenInfo.screens[j]->y; - - if(x_off || y_off) { - xArc *arcs = (xArc *) &stuff[1]; - - for (i = narcs; i--; arcs++) { - arcs->x -= x_off; - arcs->y -= y_off; - } - } + if (narcs > 0) { + origArcs = malloc(narcs * sizeof(xArc)); + memcpy((char *) origArcs, (char *) &stuff[1], narcs * sizeof(xArc)); + FOR_NSCREENS_FORWARD(j) { + + if (j) + memcpy(&stuff[1], origArcs, narcs * sizeof(xArc)); + + if (isRoot) { + int x_off = screenInfo.screens[j]->x; + int y_off = screenInfo.screens[j]->y; + + if (x_off || y_off) { + xArc *arcs = (xArc *) & stuff[1]; + + for (i = narcs; i--; arcs++) { + arcs->x -= x_off; + arcs->y -= y_off; + } + } } - stuff->drawable = draw->info[j].id; - stuff->gc = gc->info[j].id; - result = (* SavedProcVector[X_PolyArc])(client); - if(result != Success) break; + stuff->drawable = draw->info[j].id; + stuff->gc = gc->info[j].id; + result = (*SavedProcVector[X_PolyArc]) (client); + if (result != Success) + break; } - free(origArcs); - return result; - } else - return Success; + free(origArcs); + return result; + } + else + return Success; } - -int PanoramiXFillPoly(ClientPtr client) +int +PanoramiXFillPoly(ClientPtr client) { - int result, count, j; + int result, count, j; PanoramiXRes *gc, *draw; - Bool isRoot; - DDXPointPtr locPts; + Bool isRoot; + DDXPointPtr locPts; + REQUEST(xFillPolyReq); REQUEST_AT_LEAST_SIZE(xFillPolyReq); - result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, - XRC_DRAWABLE, client, DixWriteAccess); + result = dixLookupResourceByClass((pointer *) &draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); if (result != Success) - return (result == BadValue) ? BadDrawable : result; + return (result == BadValue) ? BadDrawable : result; - if(IS_SHARED_PIXMAP(draw)) - return (*SavedProcVector[X_FillPoly])(client); + if (IS_SHARED_PIXMAP(draw)) + return (*SavedProcVector[X_FillPoly]) (client); - result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, - client, DixReadAccess); + result = dixLookupResourceByType((pointer *) &gc, stuff->gc, XRT_GC, + client, DixReadAccess); if (result != Success) - return result; + return result; isRoot = IS_ROOT_DRAWABLE(draw); count = bytes_to_int32((client->req_len << 2) - sizeof(xFillPolyReq)); - if (count > 0){ - locPts = malloc(count * sizeof(DDXPointRec)); - memcpy((char *)locPts, (char *)&stuff[1], count * sizeof(DDXPointRec)); - FOR_NSCREENS_FORWARD(j){ - - if(j) memcpy(&stuff[1], locPts, count * sizeof(DDXPointRec)); - - if (isRoot) { - int x_off = screenInfo.screens[j]->x; - int y_off = screenInfo.screens[j]->y; - - if(x_off || y_off) { - DDXPointPtr pnts = (DDXPointPtr)&stuff[1]; - int i = (stuff->coordMode==CoordModePrevious) ? 1 : count; - - while(i--) { - pnts->x -= x_off; - pnts->y -= y_off; - pnts++; - } - } - } - - stuff->drawable = draw->info[j].id; - stuff->gc = gc->info[j].id; - result = (* SavedProcVector[X_FillPoly])(client); - if(result != Success) break; - } - free(locPts); - return result; - } else - return Success; -} + if (count > 0) { + locPts = malloc(count * sizeof(DDXPointRec)); + memcpy((char *) locPts, (char *) &stuff[1], + count * sizeof(DDXPointRec)); + FOR_NSCREENS_FORWARD(j) { + + if (j) + memcpy(&stuff[1], locPts, count * sizeof(DDXPointRec)); + + if (isRoot) { + int x_off = screenInfo.screens[j]->x; + int y_off = screenInfo.screens[j]->y; + if (x_off || y_off) { + DDXPointPtr pnts = (DDXPointPtr) & stuff[1]; + int i = (stuff->coordMode == CoordModePrevious) ? 1 : count; -int PanoramiXPolyFillRectangle(ClientPtr client) + while (i--) { + pnts->x -= x_off; + pnts->y -= y_off; + pnts++; + } + } + } + + stuff->drawable = draw->info[j].id; + stuff->gc = gc->info[j].id; + result = (*SavedProcVector[X_FillPoly]) (client); + if (result != Success) + break; + } + free(locPts); + return result; + } + else + return Success; +} + +int +PanoramiXPolyFillRectangle(ClientPtr client) { - int result, things, i, j; + int result, things, i, j; PanoramiXRes *gc, *draw; - Bool isRoot; - xRectangle *origRects; + Bool isRoot; + xRectangle *origRects; + REQUEST(xPolyFillRectangleReq); REQUEST_AT_LEAST_SIZE(xPolyFillRectangleReq); - result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, - XRC_DRAWABLE, client, DixWriteAccess); + result = dixLookupResourceByClass((pointer *) &draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); if (result != Success) - return (result == BadValue) ? BadDrawable : result; + return (result == BadValue) ? BadDrawable : result; - if(IS_SHARED_PIXMAP(draw)) - return (*SavedProcVector[X_PolyFillRectangle])(client); + if (IS_SHARED_PIXMAP(draw)) + return (*SavedProcVector[X_PolyFillRectangle]) (client); - result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, - client, DixReadAccess); + result = dixLookupResourceByType((pointer *) &gc, stuff->gc, XRT_GC, + client, DixReadAccess); if (result != Success) - return result; + return result; isRoot = IS_ROOT_DRAWABLE(draw); things = (client->req_len << 2) - sizeof(xPolyFillRectangleReq); - if(things & 4) return BadLength; + if (things & 4) + return BadLength; things >>= 3; - if (things > 0){ - origRects = malloc(things * sizeof(xRectangle)); - memcpy((char*)origRects,(char*)&stuff[1], things * sizeof(xRectangle)); - FOR_NSCREENS_FORWARD(j){ - - if(j) memcpy(&stuff[1], origRects, things * sizeof(xRectangle)); - - if (isRoot) { - int x_off = screenInfo.screens[j]->x; - int y_off = screenInfo.screens[j]->y; - - if(x_off || y_off) { - xRectangle *rects = (xRectangle *) &stuff[1]; - - for (i = things; i--; rects++) { - rects->x -= x_off; - rects->y -= y_off; - } - } - } - - stuff->drawable = draw->info[j].id; - stuff->gc = gc->info[j].id; - result = (* SavedProcVector[X_PolyFillRectangle])(client); - if(result != Success) break; - } - free(origRects); - return result; - } else - return Success; -} + if (things > 0) { + origRects = malloc(things * sizeof(xRectangle)); + memcpy((char *) origRects, (char *) &stuff[1], + things * sizeof(xRectangle)); + FOR_NSCREENS_FORWARD(j) { + + if (j) + memcpy(&stuff[1], origRects, things * sizeof(xRectangle)); + + if (isRoot) { + int x_off = screenInfo.screens[j]->x; + int y_off = screenInfo.screens[j]->y; + + if (x_off || y_off) { + xRectangle *rects = (xRectangle *) &stuff[1]; + + for (i = things; i--; rects++) { + rects->x -= x_off; + rects->y -= y_off; + } + } + } + stuff->drawable = draw->info[j].id; + stuff->gc = gc->info[j].id; + result = (*SavedProcVector[X_PolyFillRectangle]) (client); + if (result != Success) + break; + } + free(origRects); + return result; + } + else + return Success; +} -int PanoramiXPolyFillArc(ClientPtr client) +int +PanoramiXPolyFillArc(ClientPtr client) { PanoramiXRes *gc, *draw; - Bool isRoot; - int result, narcs, i, j; - xArc *origArcs; + Bool isRoot; + int result, narcs, i, j; + xArc *origArcs; + REQUEST(xPolyFillArcReq); REQUEST_AT_LEAST_SIZE(xPolyFillArcReq); - result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, - XRC_DRAWABLE, client, DixWriteAccess); + result = dixLookupResourceByClass((pointer *) &draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); if (result != Success) - return (result == BadValue) ? BadDrawable : result; + return (result == BadValue) ? BadDrawable : result; - if(IS_SHARED_PIXMAP(draw)) - return (*SavedProcVector[X_PolyFillArc])(client); + if (IS_SHARED_PIXMAP(draw)) + return (*SavedProcVector[X_PolyFillArc]) (client); - result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, - client, DixReadAccess); + result = dixLookupResourceByType((pointer *) &gc, stuff->gc, XRT_GC, + client, DixReadAccess); if (result != Success) - return result; + return result; isRoot = IS_ROOT_DRAWABLE(draw); narcs = (client->req_len << 2) - sizeof(xPolyFillArcReq); - if (narcs % sizeof(xArc)) return BadLength; + if (narcs % sizeof(xArc)) + return BadLength; narcs /= sizeof(xArc); if (narcs > 0) { - origArcs = malloc(narcs * sizeof(xArc)); - memcpy((char *) origArcs, (char *)&stuff[1], narcs * sizeof(xArc)); - FOR_NSCREENS_FORWARD(j){ - - if(j) memcpy(&stuff[1], origArcs, narcs * sizeof(xArc)); - - if (isRoot) { - int x_off = screenInfo.screens[j]->x; - int y_off = screenInfo.screens[j]->y; - - if(x_off || y_off) { - xArc *arcs = (xArc *) &stuff[1]; - - for (i = narcs; i--; arcs++) { - arcs->x -= x_off; - arcs->y -= y_off; - } - } - } - - stuff->drawable = draw->info[j].id; - stuff->gc = gc->info[j].id; - result = (* SavedProcVector[X_PolyFillArc])(client); - if(result != Success) break; - } - free(origArcs); - return result; - } else - return Success; -} + origArcs = malloc(narcs * sizeof(xArc)); + memcpy((char *) origArcs, (char *) &stuff[1], narcs * sizeof(xArc)); + FOR_NSCREENS_FORWARD(j) { + + if (j) + memcpy(&stuff[1], origArcs, narcs * sizeof(xArc)); + if (isRoot) { + int x_off = screenInfo.screens[j]->x; + int y_off = screenInfo.screens[j]->y; -int PanoramiXPutImage(ClientPtr client) + if (x_off || y_off) { + xArc *arcs = (xArc *) & stuff[1]; + + for (i = narcs; i--; arcs++) { + arcs->x -= x_off; + arcs->y -= y_off; + } + } + } + + stuff->drawable = draw->info[j].id; + stuff->gc = gc->info[j].id; + result = (*SavedProcVector[X_PolyFillArc]) (client); + if (result != Success) + break; + } + free(origArcs); + return result; + } + else + return Success; +} + +int +PanoramiXPutImage(ClientPtr client) { PanoramiXRes *gc, *draw; - Bool isRoot; - int j, result, orig_x, orig_y; + Bool isRoot; + int j, result, orig_x, orig_y; + REQUEST(xPutImageReq); REQUEST_AT_LEAST_SIZE(xPutImageReq); - result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, - XRC_DRAWABLE, client, DixWriteAccess); + result = dixLookupResourceByClass((pointer *) &draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); if (result != Success) - return (result == BadValue) ? BadDrawable : result; + return (result == BadValue) ? BadDrawable : result; - if(IS_SHARED_PIXMAP(draw)) - return (*SavedProcVector[X_PutImage])(client); + if (IS_SHARED_PIXMAP(draw)) + return (*SavedProcVector[X_PutImage]) (client); - result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, - client, DixReadAccess); + result = dixLookupResourceByType((pointer *) &gc, stuff->gc, XRT_GC, + client, DixReadAccess); if (result != Success) - return result; + return result; isRoot = IS_ROOT_DRAWABLE(draw); orig_x = stuff->dstX; orig_y = stuff->dstY; - FOR_NSCREENS_BACKWARD(j){ - if (isRoot) { - stuff->dstX = orig_x - screenInfo.screens[j]->x; - stuff->dstY = orig_y - screenInfo.screens[j]->y; - } - stuff->drawable = draw->info[j].id; - stuff->gc = gc->info[j].id; - result = (* SavedProcVector[X_PutImage])(client); - if(result != Success) break; + FOR_NSCREENS_BACKWARD(j) { + if (isRoot) { + stuff->dstX = orig_x - screenInfo.screens[j]->x; + stuff->dstY = orig_y - screenInfo.screens[j]->y; + } + stuff->drawable = draw->info[j].id; + stuff->gc = gc->info[j].id; + result = (*SavedProcVector[X_PutImage]) (client); + if (result != Success) + break; } return result; } - -int PanoramiXGetImage(ClientPtr client) +int +PanoramiXGetImage(ClientPtr client) { - DrawablePtr drawables[MAXSCREENS]; - DrawablePtr pDraw; - PanoramiXRes *draw; - xGetImageReply xgi; - Bool isRoot; - char *pBuf; - int i, x, y, w, h, format, rc; - Mask plane = 0, planemask; - int linesDone, nlines, linesPerBuf; - long widthBytesLine, length; + DrawablePtr drawables[MAXSCREENS]; + DrawablePtr pDraw; + PanoramiXRes *draw; + xGetImageReply xgi; + Bool isRoot; + char *pBuf; + int i, x, y, w, h, format, rc; + Mask plane = 0, planemask; + int linesDone, nlines, linesPerBuf; + long widthBytesLine, length; REQUEST(xGetImageReq); REQUEST_SIZE_MATCH(xGetImageReq); if ((stuff->format != XYPixmap) && (stuff->format != ZPixmap)) { - client->errorValue = stuff->format; + client->errorValue = stuff->format; return BadValue; } - rc = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, - XRC_DRAWABLE, client, DixWriteAccess); + rc = dixLookupResourceByClass((pointer *) &draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); if (rc != Success) - return (rc == BadValue) ? BadDrawable : rc; + return (rc == BadValue) ? BadDrawable : rc; - if(draw->type == XRT_PIXMAP) - return (*SavedProcVector[X_GetImage])(client); + if (draw->type == XRT_PIXMAP) + return (*SavedProcVector[X_GetImage]) (client); - rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, - DixReadAccess); + rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, DixReadAccess); if (rc != Success) - return rc; + return rc; - if(!((WindowPtr)pDraw)->realized) - return BadMatch; + if (!((WindowPtr) pDraw)->realized) + return BadMatch; x = stuff->x; y = stuff->y; @@ -1820,367 +1927,377 @@ int PanoramiXGetImage(ClientPtr client) isRoot = IS_ROOT_DRAWABLE(draw); - if(isRoot) { - if( /* check for being onscreen */ - x < 0 || x + w > PanoramiXPixWidth || - y < 0 || y + h > PanoramiXPixHeight ) - return BadMatch; - } else { - if( /* check for being onscreen */ - screenInfo.screens[0]->x + pDraw->x + x < 0 || - screenInfo.screens[0]->x + pDraw->x + x + w > PanoramiXPixWidth || - screenInfo.screens[0]->y + pDraw->y + y < 0 || - screenInfo.screens[0]->y + pDraw->y + y + h > PanoramiXPixHeight || - /* check for being inside of border */ - x < - wBorderWidth((WindowPtr)pDraw) || - x + w > wBorderWidth((WindowPtr)pDraw) + (int)pDraw->width || - y < -wBorderWidth((WindowPtr)pDraw) || - y + h > wBorderWidth ((WindowPtr)pDraw) + (int)pDraw->height) - return BadMatch; + if (isRoot) { + if ( /* check for being onscreen */ + x < 0 || x + w > PanoramiXPixWidth || + y < 0 || y + h > PanoramiXPixHeight) + return BadMatch; + } + else { + if ( /* check for being onscreen */ + screenInfo.screens[0]->x + pDraw->x + x < 0 || + screenInfo.screens[0]->x + pDraw->x + x + w > PanoramiXPixWidth + || screenInfo.screens[0]->y + pDraw->y + y < 0 || + screenInfo.screens[0]->y + pDraw->y + y + h > PanoramiXPixHeight + || + /* check for being inside of border */ + x < -wBorderWidth((WindowPtr) pDraw) || + x + w > wBorderWidth((WindowPtr) pDraw) + (int) pDraw->width || + y < -wBorderWidth((WindowPtr) pDraw) || + y + h > wBorderWidth((WindowPtr) pDraw) + (int) pDraw->height) + return BadMatch; } drawables[0] = pDraw; FOR_NSCREENS_FORWARD_SKIP(i) { - rc = dixLookupDrawable(drawables+i, draw->info[i].id, client, 0, - DixGetAttrAccess); - if (rc != Success) - return rc; + rc = dixLookupDrawable(drawables + i, draw->info[i].id, client, 0, + DixGetAttrAccess); + if (rc != Success) + return rc; } - xgi.visual = wVisual (((WindowPtr) pDraw)); + xgi.visual = wVisual(((WindowPtr) pDraw)); xgi.type = X_Reply; xgi.sequenceNumber = client->sequence; xgi.depth = pDraw->depth; - if(format == ZPixmap) { - widthBytesLine = PixmapBytePad(w, pDraw->depth); - length = widthBytesLine * h; - + if (format == ZPixmap) { + widthBytesLine = PixmapBytePad(w, pDraw->depth); + length = widthBytesLine * h; - } else { - widthBytesLine = BitmapBytePad(w); - plane = ((Mask)1) << (pDraw->depth - 1); - /* only planes asked for */ - length = widthBytesLine * h * - Ones(planemask & (plane | (plane - 1))); + } + else { + widthBytesLine = BitmapBytePad(w); + plane = ((Mask) 1) << (pDraw->depth - 1); + /* only planes asked for */ + length = widthBytesLine * h * Ones(planemask & (plane | (plane - 1))); } xgi.length = bytes_to_int32(length); if (widthBytesLine == 0 || h == 0) - linesPerBuf = 0; + linesPerBuf = 0; else if (widthBytesLine >= XINERAMA_IMAGE_BUFSIZE) - linesPerBuf = 1; + linesPerBuf = 1; else { - linesPerBuf = XINERAMA_IMAGE_BUFSIZE / widthBytesLine; - if (linesPerBuf > h) - linesPerBuf = h; + linesPerBuf = XINERAMA_IMAGE_BUFSIZE / widthBytesLine; + if (linesPerBuf > h) + linesPerBuf = h; } length = linesPerBuf * widthBytesLine; - if(!(pBuf = malloc(length))) - return BadAlloc; + if (!(pBuf = malloc(length))) + return BadAlloc; - WriteReplyToClient(client, sizeof (xGetImageReply), &xgi); + WriteReplyToClient(client, sizeof(xGetImageReply), &xgi); if (linesPerBuf == 0) { - /* nothing to do */ + /* nothing to do */ } else if (format == ZPixmap) { linesDone = 0; while (h - linesDone > 0) { - nlines = min(linesPerBuf, h - linesDone); + nlines = min(linesPerBuf, h - linesDone); - if(pDraw->depth == 1) - memset(pBuf, 0, nlines * widthBytesLine); + if (pDraw->depth == 1) + memset(pBuf, 0, nlines * widthBytesLine); - XineramaGetImageData(drawables, x, y + linesDone, w, nlines, - format, planemask, pBuf, widthBytesLine, isRoot); + XineramaGetImageData(drawables, x, y + linesDone, w, nlines, + format, planemask, pBuf, widthBytesLine, + isRoot); - (void)WriteToClient(client, - (int)(nlines * widthBytesLine), - pBuf); - linesDone += nlines; + (void) WriteToClient(client, (int) (nlines * widthBytesLine), pBuf); + linesDone += nlines; } - } else { /* XYPixmap */ + } + else { /* XYPixmap */ for (; plane; plane >>= 1) { - if (planemask & plane) { - linesDone = 0; - while (h - linesDone > 0) { - nlines = min(linesPerBuf, h - linesDone); + if (planemask & plane) { + linesDone = 0; + while (h - linesDone > 0) { + nlines = min(linesPerBuf, h - linesDone); - memset(pBuf, 0, nlines * widthBytesLine); + memset(pBuf, 0, nlines * widthBytesLine); - XineramaGetImageData(drawables, x, y + linesDone, w, - nlines, format, plane, pBuf, - widthBytesLine, isRoot); + XineramaGetImageData(drawables, x, y + linesDone, w, + nlines, format, plane, pBuf, + widthBytesLine, isRoot); - (void)WriteToClient(client, - (int)(nlines * widthBytesLine), - pBuf); + (void) WriteToClient(client, + (int) (nlines * widthBytesLine), pBuf); - linesDone += nlines; - } + linesDone += nlines; + } } - } + } } free(pBuf); return Success; } - /* The text stuff should be rewritten so that duplication happens at the GlyphBlt level. That is, loading the font and getting the glyphs should only happen once */ -int +int PanoramiXPolyText8(ClientPtr client) { PanoramiXRes *gc, *draw; - Bool isRoot; - int result, j; - int orig_x, orig_y; + Bool isRoot; + int result, j; + int orig_x, orig_y; + REQUEST(xPolyTextReq); REQUEST_AT_LEAST_SIZE(xPolyTextReq); - result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, - XRC_DRAWABLE, client, DixWriteAccess); + result = dixLookupResourceByClass((pointer *) &draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); if (result != Success) - return (result == BadValue) ? BadDrawable : result; + return (result == BadValue) ? BadDrawable : result; - if(IS_SHARED_PIXMAP(draw)) - return (*SavedProcVector[X_PolyText8])(client); + if (IS_SHARED_PIXMAP(draw)) + return (*SavedProcVector[X_PolyText8]) (client); - result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, - client, DixReadAccess); + result = dixLookupResourceByType((pointer *) &gc, stuff->gc, XRT_GC, + client, DixReadAccess); if (result != Success) - return result; + return result; isRoot = IS_ROOT_DRAWABLE(draw); orig_x = stuff->x; orig_y = stuff->y; - FOR_NSCREENS_BACKWARD(j){ - stuff->drawable = draw->info[j].id; - stuff->gc = gc->info[j].id; - if (isRoot) { - stuff->x = orig_x - screenInfo.screens[j]->x; - stuff->y = orig_y - screenInfo.screens[j]->y; - } - result = (*SavedProcVector[X_PolyText8])(client); - if(result != Success) break; + FOR_NSCREENS_BACKWARD(j) { + stuff->drawable = draw->info[j].id; + stuff->gc = gc->info[j].id; + if (isRoot) { + stuff->x = orig_x - screenInfo.screens[j]->x; + stuff->y = orig_y - screenInfo.screens[j]->y; + } + result = (*SavedProcVector[X_PolyText8]) (client); + if (result != Success) + break; } return result; } -int +int PanoramiXPolyText16(ClientPtr client) { PanoramiXRes *gc, *draw; - Bool isRoot; - int result, j; - int orig_x, orig_y; + Bool isRoot; + int result, j; + int orig_x, orig_y; + REQUEST(xPolyTextReq); REQUEST_AT_LEAST_SIZE(xPolyTextReq); - result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, - XRC_DRAWABLE, client, DixWriteAccess); + result = dixLookupResourceByClass((pointer *) &draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); if (result != Success) - return (result == BadValue) ? BadDrawable : result; + return (result == BadValue) ? BadDrawable : result; - if(IS_SHARED_PIXMAP(draw)) - return (*SavedProcVector[X_PolyText16])(client); + if (IS_SHARED_PIXMAP(draw)) + return (*SavedProcVector[X_PolyText16]) (client); - result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, - client, DixReadAccess); + result = dixLookupResourceByType((pointer *) &gc, stuff->gc, XRT_GC, + client, DixReadAccess); if (result != Success) - return result; + return result; isRoot = IS_ROOT_DRAWABLE(draw); orig_x = stuff->x; orig_y = stuff->y; - FOR_NSCREENS_BACKWARD(j){ - stuff->drawable = draw->info[j].id; - stuff->gc = gc->info[j].id; - if (isRoot) { - stuff->x = orig_x - screenInfo.screens[j]->x; - stuff->y = orig_y - screenInfo.screens[j]->y; - } - result = (*SavedProcVector[X_PolyText16])(client); - if(result != Success) break; + FOR_NSCREENS_BACKWARD(j) { + stuff->drawable = draw->info[j].id; + stuff->gc = gc->info[j].id; + if (isRoot) { + stuff->x = orig_x - screenInfo.screens[j]->x; + stuff->y = orig_y - screenInfo.screens[j]->y; + } + result = (*SavedProcVector[X_PolyText16]) (client); + if (result != Success) + break; } return result; } - -int PanoramiXImageText8(ClientPtr client) +int +PanoramiXImageText8(ClientPtr client) { - int result, j; + int result, j; PanoramiXRes *gc, *draw; - Bool isRoot; - int orig_x, orig_y; + Bool isRoot; + int orig_x, orig_y; + REQUEST(xImageTextReq); REQUEST_FIXED_SIZE(xImageTextReq, stuff->nChars); - result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, - XRC_DRAWABLE, client, DixWriteAccess); + result = dixLookupResourceByClass((pointer *) &draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); if (result != Success) - return (result == BadValue) ? BadDrawable : result; + return (result == BadValue) ? BadDrawable : result; - if(IS_SHARED_PIXMAP(draw)) - return (*SavedProcVector[X_ImageText8])(client); + if (IS_SHARED_PIXMAP(draw)) + return (*SavedProcVector[X_ImageText8]) (client); - result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, - client, DixReadAccess); + result = dixLookupResourceByType((pointer *) &gc, stuff->gc, XRT_GC, + client, DixReadAccess); if (result != Success) - return result; + return result; isRoot = IS_ROOT_DRAWABLE(draw); orig_x = stuff->x; orig_y = stuff->y; - FOR_NSCREENS_BACKWARD(j){ - stuff->drawable = draw->info[j].id; - stuff->gc = gc->info[j].id; - if (isRoot) { - stuff->x = orig_x - screenInfo.screens[j]->x; - stuff->y = orig_y - screenInfo.screens[j]->y; - } - result = (*SavedProcVector[X_ImageText8])(client); - if(result != Success) break; + FOR_NSCREENS_BACKWARD(j) { + stuff->drawable = draw->info[j].id; + stuff->gc = gc->info[j].id; + if (isRoot) { + stuff->x = orig_x - screenInfo.screens[j]->x; + stuff->y = orig_y - screenInfo.screens[j]->y; + } + result = (*SavedProcVector[X_ImageText8]) (client); + if (result != Success) + break; } return result; } - -int PanoramiXImageText16(ClientPtr client) +int +PanoramiXImageText16(ClientPtr client) { - int result, j; + int result, j; PanoramiXRes *gc, *draw; - Bool isRoot; - int orig_x, orig_y; + Bool isRoot; + int orig_x, orig_y; + REQUEST(xImageTextReq); REQUEST_FIXED_SIZE(xImageTextReq, stuff->nChars << 1); - result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, - XRC_DRAWABLE, client, DixWriteAccess); + result = dixLookupResourceByClass((pointer *) &draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); if (result != Success) - return (result == BadValue) ? BadDrawable : result; + return (result == BadValue) ? BadDrawable : result; - if(IS_SHARED_PIXMAP(draw)) - return (*SavedProcVector[X_ImageText16])(client); + if (IS_SHARED_PIXMAP(draw)) + return (*SavedProcVector[X_ImageText16]) (client); - result = dixLookupResourceByType((pointer *)&gc, stuff->gc, XRT_GC, - client, DixReadAccess); + result = dixLookupResourceByType((pointer *) &gc, stuff->gc, XRT_GC, + client, DixReadAccess); if (result != Success) - return result; + return result; isRoot = IS_ROOT_DRAWABLE(draw); orig_x = stuff->x; orig_y = stuff->y; - FOR_NSCREENS_BACKWARD(j){ - stuff->drawable = draw->info[j].id; - stuff->gc = gc->info[j].id; - if (isRoot) { - stuff->x = orig_x - screenInfo.screens[j]->x; - stuff->y = orig_y - screenInfo.screens[j]->y; - } - result = (*SavedProcVector[X_ImageText16])(client); - if(result != Success) break; + FOR_NSCREENS_BACKWARD(j) { + stuff->drawable = draw->info[j].id; + stuff->gc = gc->info[j].id; + if (isRoot) { + stuff->x = orig_x - screenInfo.screens[j]->x; + stuff->y = orig_y - screenInfo.screens[j]->y; + } + result = (*SavedProcVector[X_ImageText16]) (client); + if (result != Success) + break; } return result; } - - -int PanoramiXCreateColormap(ClientPtr client) +int +PanoramiXCreateColormap(ClientPtr client) { - PanoramiXRes *win, *newCmap; - int result, j, orig_visual; + PanoramiXRes *win, *newCmap; + int result, j, orig_visual; + REQUEST(xCreateColormapReq); REQUEST_SIZE_MATCH(xCreateColormapReq); - result = dixLookupResourceByType((pointer *)&win, stuff->window, - XRT_WINDOW, client, DixReadAccess); + result = dixLookupResourceByType((pointer *) &win, stuff->window, + XRT_WINDOW, client, DixReadAccess); if (result != Success) - return result; + return result; - if(!(newCmap = malloc(sizeof(PanoramiXRes)))) + if (!(newCmap = malloc(sizeof(PanoramiXRes)))) return BadAlloc; newCmap->type = XRT_COLORMAP; panoramix_setup_ids(newCmap, client, stuff->mid); orig_visual = stuff->visual; - FOR_NSCREENS_BACKWARD(j){ - stuff->mid = newCmap->info[j].id; - stuff->window = win->info[j].id; - stuff->visual = PanoramiXTranslateVisualID(j, orig_visual); - result = (* SavedProcVector[X_CreateColormap])(client); - if(result != Success) break; - } - + FOR_NSCREENS_BACKWARD(j) { + stuff->mid = newCmap->info[j].id; + stuff->window = win->info[j].id; + stuff->visual = PanoramiXTranslateVisualID(j, orig_visual); + result = (*SavedProcVector[X_CreateColormap]) (client); + if (result != Success) + break; + } + if (result == Success) AddResource(newCmap->info[0].id, XRT_COLORMAP, newCmap); - else + else free(newCmap); return result; } - -int PanoramiXFreeColormap(ClientPtr client) +int +PanoramiXFreeColormap(ClientPtr client) { PanoramiXRes *cmap; - int result, j; + int result, j; + REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); client->errorValue = stuff->id; - result = dixLookupResourceByType((pointer *)&cmap, stuff->id, XRT_COLORMAP, - client, DixDestroyAccess); + result = dixLookupResourceByType((pointer *) &cmap, stuff->id, XRT_COLORMAP, + client, DixDestroyAccess); if (result != Success) return result; FOR_NSCREENS_BACKWARD(j) { stuff->id = cmap->info[j].id; - result = (* SavedProcVector[X_FreeColormap])(client); - if(result != Success) break; + result = (*SavedProcVector[X_FreeColormap]) (client); + if (result != Success) + break; } /* Since ProcFreeColormap is using FreeResource, it will free - our resource for us on the last pass through the loop above */ + our resource for us on the last pass through the loop above */ return result; } - int PanoramiXCopyColormapAndFree(ClientPtr client) { PanoramiXRes *cmap, *newCmap; - int result, j; + int result, j; + REQUEST(xCopyColormapAndFreeReq); REQUEST_SIZE_MATCH(xCopyColormapAndFreeReq); client->errorValue = stuff->srcCmap; - result = dixLookupResourceByType((pointer *)&cmap, stuff->srcCmap, - XRT_COLORMAP, client, - DixReadAccess | DixWriteAccess); + result = dixLookupResourceByType((pointer *) &cmap, stuff->srcCmap, + XRT_COLORMAP, client, + DixReadAccess | DixWriteAccess); if (result != Success) return result; - if(!(newCmap = malloc(sizeof(PanoramiXRes)))) + if (!(newCmap = malloc(sizeof(PanoramiXRes)))) return BadAlloc; newCmap->type = XRT_COLORMAP; @@ -2188,231 +2305,246 @@ PanoramiXCopyColormapAndFree(ClientPtr client) FOR_NSCREENS_BACKWARD(j) { stuff->srcCmap = cmap->info[j].id; - stuff->mid = newCmap->info[j].id; - result = (* SavedProcVector[X_CopyColormapAndFree])(client); - if(result != Success) break; + stuff->mid = newCmap->info[j].id; + result = (*SavedProcVector[X_CopyColormapAndFree]) (client); + if (result != Success) + break; } if (result == Success) AddResource(newCmap->info[0].id, XRT_COLORMAP, newCmap); - else + else free(newCmap); return result; } - -int PanoramiXInstallColormap(ClientPtr client) +int +PanoramiXInstallColormap(ClientPtr client) { REQUEST(xResourceReq); - int result, j; + int result, j; PanoramiXRes *cmap; REQUEST_SIZE_MATCH(xResourceReq); client->errorValue = stuff->id; - result = dixLookupResourceByType((pointer *)&cmap, stuff->id, XRT_COLORMAP, - client, DixReadAccess); + result = dixLookupResourceByType((pointer *) &cmap, stuff->id, XRT_COLORMAP, + client, DixReadAccess); if (result != Success) return result; - FOR_NSCREENS_BACKWARD(j){ - stuff->id = cmap->info[j].id; - result = (* SavedProcVector[X_InstallColormap])(client); - if(result != Success) break; + FOR_NSCREENS_BACKWARD(j) { + stuff->id = cmap->info[j].id; + result = (*SavedProcVector[X_InstallColormap]) (client); + if (result != Success) + break; } return result; } - -int PanoramiXUninstallColormap(ClientPtr client) +int +PanoramiXUninstallColormap(ClientPtr client) { REQUEST(xResourceReq); - int result, j; + int result, j; PanoramiXRes *cmap; REQUEST_SIZE_MATCH(xResourceReq); - + client->errorValue = stuff->id; - result = dixLookupResourceByType((pointer *)&cmap, stuff->id, XRT_COLORMAP, - client, DixReadAccess); + result = dixLookupResourceByType((pointer *) &cmap, stuff->id, XRT_COLORMAP, + client, DixReadAccess); if (result != Success) return result; FOR_NSCREENS_BACKWARD(j) { - stuff->id = cmap->info[j].id; - result = (* SavedProcVector[X_UninstallColormap])(client); - if(result != Success) break; + stuff->id = cmap->info[j].id; + result = (*SavedProcVector[X_UninstallColormap]) (client); + if (result != Success) + break; } return result; } - -int PanoramiXAllocColor(ClientPtr client) +int +PanoramiXAllocColor(ClientPtr client) { - int result, j; + int result, j; PanoramiXRes *cmap; + REQUEST(xAllocColorReq); REQUEST_SIZE_MATCH(xAllocColorReq); client->errorValue = stuff->cmap; - result = dixLookupResourceByType((pointer *)&cmap, stuff->cmap, - XRT_COLORMAP, client, DixWriteAccess); + result = dixLookupResourceByType((pointer *) &cmap, stuff->cmap, + XRT_COLORMAP, client, DixWriteAccess); if (result != Success) return result; - FOR_NSCREENS_BACKWARD(j){ - stuff->cmap = cmap->info[j].id; - result = (* SavedProcVector[X_AllocColor])(client); - if(result != Success) break; + FOR_NSCREENS_BACKWARD(j) { + stuff->cmap = cmap->info[j].id; + result = (*SavedProcVector[X_AllocColor]) (client); + if (result != Success) + break; } return result; } - -int PanoramiXAllocNamedColor(ClientPtr client) +int +PanoramiXAllocNamedColor(ClientPtr client) { - int result, j; - PanoramiXRes *cmap; + int result, j; + PanoramiXRes *cmap; + REQUEST(xAllocNamedColorReq); REQUEST_FIXED_SIZE(xAllocNamedColorReq, stuff->nbytes); client->errorValue = stuff->cmap; - result = dixLookupResourceByType((pointer *)&cmap, stuff->cmap, - XRT_COLORMAP, client, DixWriteAccess); + result = dixLookupResourceByType((pointer *) &cmap, stuff->cmap, + XRT_COLORMAP, client, DixWriteAccess); if (result != Success) return result; - FOR_NSCREENS_BACKWARD(j){ + FOR_NSCREENS_BACKWARD(j) { stuff->cmap = cmap->info[j].id; - result = (* SavedProcVector[X_AllocNamedColor])(client); - if(result != Success) break; + result = (*SavedProcVector[X_AllocNamedColor]) (client); + if (result != Success) + break; } return result; } - -int PanoramiXAllocColorCells(ClientPtr client) +int +PanoramiXAllocColorCells(ClientPtr client) { - int result, j; - PanoramiXRes *cmap; + int result, j; + PanoramiXRes *cmap; + REQUEST(xAllocColorCellsReq); REQUEST_SIZE_MATCH(xAllocColorCellsReq); client->errorValue = stuff->cmap; - result = dixLookupResourceByType((pointer *)&cmap, stuff->cmap, - XRT_COLORMAP, client, DixWriteAccess); + result = dixLookupResourceByType((pointer *) &cmap, stuff->cmap, + XRT_COLORMAP, client, DixWriteAccess); if (result != Success) return result; - - FOR_NSCREENS_BACKWARD(j){ - stuff->cmap = cmap->info[j].id; - result = (* SavedProcVector[X_AllocColorCells])(client); - if(result != Success) break; + + FOR_NSCREENS_BACKWARD(j) { + stuff->cmap = cmap->info[j].id; + result = (*SavedProcVector[X_AllocColorCells]) (client); + if (result != Success) + break; } return result; } - -int PanoramiXAllocColorPlanes(ClientPtr client) +int +PanoramiXAllocColorPlanes(ClientPtr client) { - int result, j; - PanoramiXRes *cmap; + int result, j; + PanoramiXRes *cmap; + REQUEST(xAllocColorPlanesReq); REQUEST_SIZE_MATCH(xAllocColorPlanesReq); client->errorValue = stuff->cmap; - result = dixLookupResourceByType((pointer *)&cmap, stuff->cmap, - XRT_COLORMAP, client, DixWriteAccess); + result = dixLookupResourceByType((pointer *) &cmap, stuff->cmap, + XRT_COLORMAP, client, DixWriteAccess); if (result != Success) return result; - - FOR_NSCREENS_BACKWARD(j){ - stuff->cmap = cmap->info[j].id; - result = (* SavedProcVector[X_AllocColorPlanes])(client); - if(result != Success) break; + + FOR_NSCREENS_BACKWARD(j) { + stuff->cmap = cmap->info[j].id; + result = (*SavedProcVector[X_AllocColorPlanes]) (client); + if (result != Success) + break; } return result; } - - -int PanoramiXFreeColors(ClientPtr client) +int +PanoramiXFreeColors(ClientPtr client) { - int result, j; - PanoramiXRes *cmap; + int result, j; + PanoramiXRes *cmap; + REQUEST(xFreeColorsReq); REQUEST_AT_LEAST_SIZE(xFreeColorsReq); client->errorValue = stuff->cmap; - result = dixLookupResourceByType((pointer *)&cmap, stuff->cmap, - XRT_COLORMAP, client, DixWriteAccess); + result = dixLookupResourceByType((pointer *) &cmap, stuff->cmap, + XRT_COLORMAP, client, DixWriteAccess); if (result != Success) return result; FOR_NSCREENS_BACKWARD(j) { stuff->cmap = cmap->info[j].id; - result = (* SavedProcVector[X_FreeColors])(client); + result = (*SavedProcVector[X_FreeColors]) (client); } return result; } - -int PanoramiXStoreColors(ClientPtr client) +int +PanoramiXStoreColors(ClientPtr client) { - int result, j; - PanoramiXRes *cmap; + int result, j; + PanoramiXRes *cmap; + REQUEST(xStoreColorsReq); REQUEST_AT_LEAST_SIZE(xStoreColorsReq); client->errorValue = stuff->cmap; - result = dixLookupResourceByType((pointer *)&cmap, stuff->cmap, - XRT_COLORMAP, client, DixWriteAccess); + result = dixLookupResourceByType((pointer *) &cmap, stuff->cmap, + XRT_COLORMAP, client, DixWriteAccess); if (result != Success) return result; - FOR_NSCREENS_BACKWARD(j){ - stuff->cmap = cmap->info[j].id; - result = (* SavedProcVector[X_StoreColors])(client); - if(result != Success) break; + FOR_NSCREENS_BACKWARD(j) { + stuff->cmap = cmap->info[j].id; + result = (*SavedProcVector[X_StoreColors]) (client); + if (result != Success) + break; } return result; } - -int PanoramiXStoreNamedColor(ClientPtr client) +int +PanoramiXStoreNamedColor(ClientPtr client) { - int result, j; - PanoramiXRes *cmap; + int result, j; + PanoramiXRes *cmap; + REQUEST(xStoreNamedColorReq); REQUEST_FIXED_SIZE(xStoreNamedColorReq, stuff->nbytes); client->errorValue = stuff->cmap; - result = dixLookupResourceByType((pointer *)&cmap, stuff->cmap, - XRT_COLORMAP, client, DixWriteAccess); + result = dixLookupResourceByType((pointer *) &cmap, stuff->cmap, + XRT_COLORMAP, client, DixWriteAccess); if (result != Success) return result; - FOR_NSCREENS_BACKWARD(j){ - stuff->cmap = cmap->info[j].id; - result = (* SavedProcVector[X_StoreNamedColor])(client); - if(result != Success) break; + FOR_NSCREENS_BACKWARD(j) { + stuff->cmap = cmap->info[j].id; + result = (*SavedProcVector[X_StoreNamedColor]) (client); + if (result != Success) + break; } return result; } diff --git a/Xext/panoramiXsrv.h b/Xext/panoramiXsrv.h index 39d495203..7c605fe66 100644 --- a/Xext/panoramiXsrv.h +++ b/Xext/panoramiXsrv.h @@ -15,8 +15,9 @@ extern _X_EXPORT int PanoramiXPixHeight; extern _X_EXPORT VisualID PanoramiXTranslateVisualID(int screen, VisualID orig); extern _X_EXPORT void PanoramiXConsolidate(void); extern _X_EXPORT Bool PanoramiXCreateConnectionBlock(void); -extern _X_EXPORT PanoramiXRes * PanoramiXFindIDByScrnum(RESTYPE, XID, int); -extern _X_EXPORT Bool XineramaRegisterConnectionBlockCallback(void (*func)(void)); +extern _X_EXPORT PanoramiXRes *PanoramiXFindIDByScrnum(RESTYPE, XID, int); +extern _X_EXPORT Bool +XineramaRegisterConnectionBlockCallback(void (*func) (void)); extern _X_EXPORT int XineramaDeleteResource(pointer, XID); extern _X_EXPORT void XineramaReinitData(void); @@ -35,24 +36,20 @@ extern _X_EXPORT RESTYPE XRT_PICTURE; * layers agree that the visuals are equal. The first visual is always from * screen 0. */ -typedef Bool (*XineramaVisualsEqualProcPtr)(VisualPtr, ScreenPtr, VisualPtr); +typedef Bool (*XineramaVisualsEqualProcPtr) (VisualPtr, ScreenPtr, VisualPtr); extern _X_EXPORT XineramaVisualsEqualProcPtr XineramaVisualsEqualPtr; -extern _X_EXPORT void XineramaGetImageData( - DrawablePtr *pDrawables, - int left, - int top, - int width, - int height, - unsigned int format, - unsigned long planemask, - char *data, - int pitch, - Bool isRoot -); - -static inline void panoramix_setup_ids(PanoramiXRes *resource, - ClientPtr client, XID base_id) +extern _X_EXPORT void XineramaGetImageData(DrawablePtr *pDrawables, + int left, + int top, + int width, + int height, + unsigned int format, + unsigned long planemask, + char *data, int pitch, Bool isRoot); + +static inline void +panoramix_setup_ids(PanoramiXRes * resource, ClientPtr client, XID base_id) { int j; @@ -62,4 +59,4 @@ static inline void panoramix_setup_ids(PanoramiXRes *resource, } } -#endif /* _PANORAMIXSRV_H_ */ +#endif /* _PANORAMIXSRV_H_ */ diff --git a/Xext/saver.c b/Xext/saver.c index 18d5e468d..159153c23 100644 --- a/Xext/saver.c +++ b/Xext/saver.c @@ -26,7 +26,6 @@ in this Software without prior written authorization from the X Consortium. * Author: Keith Packard, MIT X Consortium */ - #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> #endif @@ -62,39 +61,32 @@ in this Software without prior written authorization from the X Consortium. static int ScreenSaverEventBase = 0; - -static Bool ScreenSaverHandle ( - ScreenPtr /* pScreen */, - int /* xstate */, - Bool /* force */ - ); +static Bool ScreenSaverHandle(ScreenPtr /* pScreen */ , + int /* xstate */ , + Bool /* force */ + ); static Bool -CreateSaverWindow ( - ScreenPtr /* pScreen */ - ); + CreateSaverWindow(ScreenPtr /* pScreen */ + ); static Bool -DestroySaverWindow ( - ScreenPtr /* pScreen */ - ); + DestroySaverWindow(ScreenPtr /* pScreen */ + ); static void -UninstallSaverColormap ( - ScreenPtr /* pScreen */ - ); + UninstallSaverColormap(ScreenPtr /* pScreen */ + ); static void -CheckScreenPrivate ( - ScreenPtr /* pScreen */ - ); + CheckScreenPrivate(ScreenPtr /* pScreen */ + ); -static void SScreenSaverNotifyEvent ( - xScreenSaverNotifyEvent * /* from */, - xScreenSaverNotifyEvent * /* to */ - ); +static void SScreenSaverNotifyEvent(xScreenSaverNotifyEvent * /* from */ , + xScreenSaverNotifyEvent * /* to */ + ); -static RESTYPE SuspendType; /* resource type for suspension records */ +static RESTYPE SuspendType; /* resource type for suspension records */ typedef struct _ScreenSaverSuspension *ScreenSaverSuspensionPtr; @@ -107,18 +99,16 @@ static ScreenSaverSuspensionPtr suspendingClients = NULL; * the client disconnects. count is the number of times the client has * requested the screensaver be suspended. */ -typedef struct _ScreenSaverSuspension -{ - ScreenSaverSuspensionPtr next; - ClientPtr pClient; - XID clientResource; - int count; +typedef struct _ScreenSaverSuspension { + ScreenSaverSuspensionPtr next; + ClientPtr pClient; + XID clientResource; + int count; } ScreenSaverSuspensionRec; -static int ScreenSaverFreeSuspend( - pointer /*value */, - XID /* id */ -); +static int ScreenSaverFreeSuspend(pointer /*value */ , + XID /* id */ + ); /* * each screen has a list of clients requesting @@ -128,91 +118,83 @@ static int ScreenSaverFreeSuspend( * entry from the per-screen queue. */ -static RESTYPE SaverEventType; /* resource type for event masks */ +static RESTYPE SaverEventType; /* resource type for event masks */ typedef struct _ScreenSaverEvent *ScreenSaverEventPtr; typedef struct _ScreenSaverEvent { - ScreenSaverEventPtr next; - ClientPtr client; - ScreenPtr screen; - XID resource; - CARD32 mask; + ScreenSaverEventPtr next; + ClientPtr client; + ScreenPtr screen; + XID resource; + CARD32 mask; } ScreenSaverEventRec; -static int ScreenSaverFreeEvents( - pointer /* value */, - XID /* id */ -); +static int ScreenSaverFreeEvents(pointer /* value */ , + XID /* id */ + ); -static Bool setEventMask ( - ScreenPtr /* pScreen */, - ClientPtr /* client */, - unsigned long /* mask */ -); +static Bool setEventMask(ScreenPtr /* pScreen */ , + ClientPtr /* client */ , + unsigned long /* mask */ + ); -static unsigned long getEventMask ( - ScreenPtr /* pScreen */, - ClientPtr /* client */ -); +static unsigned long getEventMask(ScreenPtr /* pScreen */ , + ClientPtr /* client */ + ); /* * when a client sets the screen saver attributes, a resource is * kept to be freed when the client exits */ -static RESTYPE AttrType; /* resource type for attributes */ +static RESTYPE AttrType; /* resource type for attributes */ typedef struct _ScreenSaverAttr { - ScreenPtr screen; - ClientPtr client; - XID resource; - short x, y; - unsigned short width, height, borderWidth; - unsigned char class; - unsigned char depth; - VisualID visual; - CursorPtr pCursor; - PixmapPtr pBackgroundPixmap; - PixmapPtr pBorderPixmap; - Colormap colormap; - unsigned long mask; /* no pixmaps or cursors */ - unsigned long *values; + ScreenPtr screen; + ClientPtr client; + XID resource; + short x, y; + unsigned short width, height, borderWidth; + unsigned char class; + unsigned char depth; + VisualID visual; + CursorPtr pCursor; + PixmapPtr pBackgroundPixmap; + PixmapPtr pBorderPixmap; + Colormap colormap; + unsigned long mask; /* no pixmaps or cursors */ + unsigned long *values; } ScreenSaverAttrRec, *ScreenSaverAttrPtr; -static int ScreenSaverFreeAttr ( - pointer /* value */, - XID /* id */ -); +static int ScreenSaverFreeAttr(pointer /* value */ , + XID /* id */ + ); -static void FreeAttrs ( - ScreenSaverAttrPtr /* pAttr */ -); +static void FreeAttrs(ScreenSaverAttrPtr /* pAttr */ + ); -static void FreeScreenAttr ( - ScreenSaverAttrPtr /* pAttr */ -); +static void FreeScreenAttr(ScreenSaverAttrPtr /* pAttr */ + ); static void -SendScreenSaverNotify ( - ScreenPtr /* pScreen */, - int /* state */, - Bool /* forced */ -); + SendScreenSaverNotify(ScreenPtr /* pScreen */ , + int /* state */ , + Bool /* forced */ + ); typedef struct _ScreenSaverScreenPrivate { - ScreenSaverEventPtr events; - ScreenSaverAttrPtr attr; - Bool hasWindow; - Colormap installedMap; + ScreenSaverEventPtr events; + ScreenSaverAttrPtr attr; + Bool hasWindow; + Colormap installedMap; } ScreenSaverScreenPrivateRec, *ScreenSaverScreenPrivatePtr; -static ScreenSaverScreenPrivatePtr -MakeScreenPrivate ( - ScreenPtr /* pScreen */ - ); +static ScreenSaverScreenPrivatePtr MakeScreenPrivate(ScreenPtr /* pScreen */ + ); static DevPrivateKeyRec ScreenPrivateKeyRec; + #define ScreenPrivateKey (&ScreenPrivateKeyRec) #define GetScreenPrivate(s) ((ScreenSaverScreenPrivatePtr) \ @@ -224,387 +206,370 @@ static DevPrivateKeyRec ScreenPrivateKeyRec; #define New(t) (malloc(sizeof (t))) static void -CheckScreenPrivate (ScreenPtr pScreen) +CheckScreenPrivate(ScreenPtr pScreen) { - SetupScreen (pScreen); + SetupScreen(pScreen); if (!pPriv) - return; + return; if (!pPriv->attr && !pPriv->events && - !pPriv->hasWindow && pPriv->installedMap == None) - { - free(pPriv); - SetScreenPrivate (pScreen, NULL); - pScreen->screensaver.ExternalScreenSaver = NULL; + !pPriv->hasWindow && pPriv->installedMap == None) { + free(pPriv); + SetScreenPrivate(pScreen, NULL); + pScreen->screensaver.ExternalScreenSaver = NULL; } } static ScreenSaverScreenPrivatePtr -MakeScreenPrivate (ScreenPtr pScreen) +MakeScreenPrivate(ScreenPtr pScreen) { - SetupScreen (pScreen); + SetupScreen(pScreen); if (pPriv) - return pPriv; - pPriv = New (ScreenSaverScreenPrivateRec); + return pPriv; + pPriv = New(ScreenSaverScreenPrivateRec); if (!pPriv) - return 0; + return 0; pPriv->events = 0; pPriv->attr = 0; pPriv->hasWindow = FALSE; pPriv->installedMap = None; - SetScreenPrivate (pScreen, pPriv); + SetScreenPrivate(pScreen, pPriv); pScreen->screensaver.ExternalScreenSaver = ScreenSaverHandle; return pPriv; } static unsigned long -getEventMask (ScreenPtr pScreen, ClientPtr client) +getEventMask(ScreenPtr pScreen, ClientPtr client) { SetupScreen(pScreen); - ScreenSaverEventPtr pEv; + ScreenSaverEventPtr pEv; if (!pPriv) - return 0; + return 0; for (pEv = pPriv->events; pEv; pEv = pEv->next) - if (pEv->client == client) - return pEv->mask; + if (pEv->client == client) + return pEv->mask; return 0; } static Bool -setEventMask (ScreenPtr pScreen, ClientPtr client, unsigned long mask) +setEventMask(ScreenPtr pScreen, ClientPtr client, unsigned long mask) { SetupScreen(pScreen); - ScreenSaverEventPtr pEv, *pPrev; - - if (getEventMask (pScreen, client) == mask) - return TRUE; - if (!pPriv) - { - pPriv = MakeScreenPrivate (pScreen); - if (!pPriv) - return FALSE; + ScreenSaverEventPtr pEv, *pPrev; + + if (getEventMask(pScreen, client) == mask) + return TRUE; + if (!pPriv) { + pPriv = MakeScreenPrivate(pScreen); + if (!pPriv) + return FALSE; } for (pPrev = &pPriv->events; (pEv = *pPrev) != 0; pPrev = &pEv->next) - if (pEv->client == client) - break; - if (mask == 0) - { - FreeResource (pEv->resource, SaverEventType); - *pPrev = pEv->next; - free(pEv); - CheckScreenPrivate (pScreen); + if (pEv->client == client) + break; + if (mask == 0) { + FreeResource(pEv->resource, SaverEventType); + *pPrev = pEv->next; + free(pEv); + CheckScreenPrivate(pScreen); } - else - { - if (!pEv) - { - pEv = New (ScreenSaverEventRec); - if (!pEv) - { - CheckScreenPrivate (pScreen); - return FALSE; - } - *pPrev = pEv; - pEv->next = NULL; - pEv->client = client; - pEv->screen = pScreen; - pEv->resource = FakeClientID (client->index); - if (!AddResource (pEv->resource, SaverEventType, (pointer) pEv)) - return FALSE; - } - pEv->mask = mask; + else { + if (!pEv) { + pEv = New(ScreenSaverEventRec); + if (!pEv) { + CheckScreenPrivate(pScreen); + return FALSE; + } + *pPrev = pEv; + pEv->next = NULL; + pEv->client = client; + pEv->screen = pScreen; + pEv->resource = FakeClientID(client->index); + if (!AddResource(pEv->resource, SaverEventType, (pointer) pEv)) + return FALSE; + } + pEv->mask = mask; } return TRUE; } static void -FreeAttrs (ScreenSaverAttrPtr pAttr) +FreeAttrs(ScreenSaverAttrPtr pAttr) { - PixmapPtr pPixmap; - CursorPtr pCursor; + PixmapPtr pPixmap; + CursorPtr pCursor; if ((pPixmap = pAttr->pBackgroundPixmap) != 0) - (*pPixmap->drawable.pScreen->DestroyPixmap)(pPixmap); + (*pPixmap->drawable.pScreen->DestroyPixmap) (pPixmap); if ((pPixmap = pAttr->pBorderPixmap) != 0) - (*pPixmap->drawable.pScreen->DestroyPixmap)(pPixmap); + (*pPixmap->drawable.pScreen->DestroyPixmap) (pPixmap); if ((pCursor = pAttr->pCursor) != 0) - FreeCursor (pCursor, (Cursor) 0); + FreeCursor(pCursor, (Cursor) 0); } static void -FreeScreenAttr (ScreenSaverAttrPtr pAttr) +FreeScreenAttr(ScreenSaverAttrPtr pAttr) { - FreeAttrs (pAttr); + FreeAttrs(pAttr); free(pAttr->values); free(pAttr); } static int -ScreenSaverFreeEvents (pointer value, XID id) +ScreenSaverFreeEvents(pointer value, XID id) { - ScreenSaverEventPtr pOld = (ScreenSaverEventPtr)value; + ScreenSaverEventPtr pOld = (ScreenSaverEventPtr) value; ScreenPtr pScreen = pOld->screen; - SetupScreen (pScreen); - ScreenSaverEventPtr pEv, *pPrev; + + SetupScreen(pScreen); + ScreenSaverEventPtr pEv, *pPrev; if (!pPriv) - return TRUE; + return TRUE; for (pPrev = &pPriv->events; (pEv = *pPrev) != 0; pPrev = &pEv->next) - if (pEv == pOld) - break; + if (pEv == pOld) + break; if (!pEv) - return TRUE; + return TRUE; *pPrev = pEv->next; free(pEv); - CheckScreenPrivate (pScreen); + CheckScreenPrivate(pScreen); return TRUE; } static int -ScreenSaverFreeAttr (pointer value, XID id) +ScreenSaverFreeAttr(pointer value, XID id) { - ScreenSaverAttrPtr pOldAttr = (ScreenSaverAttrPtr)value; - ScreenPtr pScreen = pOldAttr->screen; - SetupScreen (pScreen); + ScreenSaverAttrPtr pOldAttr = (ScreenSaverAttrPtr) value; + ScreenPtr pScreen = pOldAttr->screen; + + SetupScreen(pScreen); if (!pPriv) - return TRUE; + return TRUE; if (pPriv->attr != pOldAttr) - return TRUE; - FreeScreenAttr (pOldAttr); + return TRUE; + FreeScreenAttr(pOldAttr); pPriv->attr = NULL; - if (pPriv->hasWindow) - { - dixSaveScreens (serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset); - dixSaveScreens (serverClient, SCREEN_SAVER_FORCER, ScreenSaverActive); + if (pPriv->hasWindow) { + dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset); + dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverActive); } - CheckScreenPrivate (pScreen); + CheckScreenPrivate(pScreen); return TRUE; } static int -ScreenSaverFreeSuspend (pointer value, XID id) +ScreenSaverFreeSuspend(pointer value, XID id) { ScreenSaverSuspensionPtr data = (ScreenSaverSuspensionPtr) value; ScreenSaverSuspensionPtr *prev, this; /* Unlink and free the suspension record for the client */ - for (prev = &suspendingClients; (this = *prev); prev = &this->next) - { - if (this == data) - { - *prev = this->next; - free(this); - break; - } + for (prev = &suspendingClients; (this = *prev); prev = &this->next) { + if (this == data) { + *prev = this->next; + free(this); + break; + } } /* Reenable the screensaver if this was the last client suspending it. */ - if (screenSaverSuspended && suspendingClients == NULL) - { - screenSaverSuspended = FALSE; + if (screenSaverSuspended && suspendingClients == NULL) { + screenSaverSuspended = FALSE; - /* The screensaver could be active, since suspending it (by design) - doesn't prevent it from being forceably activated */ + /* The screensaver could be active, since suspending it (by design) + doesn't prevent it from being forceably activated */ #ifdef DPMSExtension - if (screenIsSaved != SCREEN_SAVER_ON && DPMSPowerLevel == DPMSModeOn) + if (screenIsSaved != SCREEN_SAVER_ON && DPMSPowerLevel == DPMSModeOn) #else - if (screenIsSaved != SCREEN_SAVER_ON) + if (screenIsSaved != SCREEN_SAVER_ON) #endif - { - UpdateCurrentTimeIf(); - lastDeviceEventTime = currentTime; - SetScreenSaverTimer(); - } + { + UpdateCurrentTimeIf(); + lastDeviceEventTime = currentTime; + SetScreenSaverTimer(); + } } return Success; } static void -SendScreenSaverNotify (ScreenPtr pScreen, int state, Bool forced) +SendScreenSaverNotify(ScreenPtr pScreen, int state, Bool forced) { - ScreenSaverScreenPrivatePtr pPriv; - ScreenSaverEventPtr pEv; - unsigned long mask; - xScreenSaverNotifyEvent ev; - int kind; + ScreenSaverScreenPrivatePtr pPriv; + ScreenSaverEventPtr pEv; + unsigned long mask; + xScreenSaverNotifyEvent ev; + int kind; - UpdateCurrentTimeIf (); + UpdateCurrentTimeIf(); mask = ScreenSaverNotifyMask; if (state == ScreenSaverCycle) - mask = ScreenSaverCycleMask; + mask = ScreenSaverCycleMask; pScreen = screenInfo.screens[pScreen->myNum]; pPriv = GetScreenPrivate(pScreen); if (!pPriv) - return; + return; if (pPriv->attr) - kind = ScreenSaverExternal; + kind = ScreenSaverExternal; else if (ScreenSaverBlanking != DontPreferBlanking) - kind = ScreenSaverBlanked; + kind = ScreenSaverBlanked; else - kind = ScreenSaverInternal; - for (pEv = pPriv->events; pEv; pEv = pEv->next) - { - if (!(pEv->mask & mask)) - continue; - ev.type = ScreenSaverNotify + ScreenSaverEventBase; - ev.state = state; - ev.timestamp = currentTime.milliseconds; - ev.root = pScreen->root->drawable.id; - ev.window = pScreen->screensaver.wid; - ev.kind = kind; - ev.forced = forced; - WriteEventsToClient (pEv->client, 1, (xEvent *) &ev); + kind = ScreenSaverInternal; + for (pEv = pPriv->events; pEv; pEv = pEv->next) { + if (!(pEv->mask & mask)) + continue; + ev.type = ScreenSaverNotify + ScreenSaverEventBase; + ev.state = state; + ev.timestamp = currentTime.milliseconds; + ev.root = pScreen->root->drawable.id; + ev.window = pScreen->screensaver.wid; + ev.kind = kind; + ev.forced = forced; + WriteEventsToClient(pEv->client, 1, (xEvent *) &ev); } } static void -SScreenSaverNotifyEvent (xScreenSaverNotifyEvent *from, - xScreenSaverNotifyEvent *to) +SScreenSaverNotifyEvent(xScreenSaverNotifyEvent * from, + xScreenSaverNotifyEvent * to) { to->type = from->type; to->state = from->state; - cpswaps (from->sequenceNumber, to->sequenceNumber); - cpswapl (from->timestamp, to->timestamp); - cpswapl (from->root, to->root); - cpswapl (from->window, to->window); + cpswaps(from->sequenceNumber, to->sequenceNumber); + cpswapl(from->timestamp, to->timestamp); + cpswapl(from->root, to->root); + cpswapl(from->window, to->window); to->kind = from->kind; to->forced = from->forced; } static void -UninstallSaverColormap (ScreenPtr pScreen) +UninstallSaverColormap(ScreenPtr pScreen) { SetupScreen(pScreen); - ColormapPtr pCmap; + ColormapPtr pCmap; int rc; - if (pPriv && pPriv->installedMap != None) - { - rc = dixLookupResourceByType((pointer *)&pCmap, pPriv->installedMap, - RT_COLORMAP, serverClient, - DixUninstallAccess); - if (rc == Success) - (*pCmap->pScreen->UninstallColormap) (pCmap); - pPriv->installedMap = None; - CheckScreenPrivate (pScreen); + if (pPriv && pPriv->installedMap != None) { + rc = dixLookupResourceByType((pointer *) &pCmap, pPriv->installedMap, + RT_COLORMAP, serverClient, + DixUninstallAccess); + if (rc == Success) + (*pCmap->pScreen->UninstallColormap) (pCmap); + pPriv->installedMap = None; + CheckScreenPrivate(pScreen); } } static Bool -CreateSaverWindow (ScreenPtr pScreen) +CreateSaverWindow(ScreenPtr pScreen) { - SetupScreen (pScreen); - ScreenSaverStuffPtr pSaver; - ScreenSaverAttrPtr pAttr; - WindowPtr pWin; - int result; - unsigned long mask; - Colormap *installedMaps; - int numInstalled; - int i; - Colormap wantMap; - ColormapPtr pCmap; + SetupScreen(pScreen); + ScreenSaverStuffPtr pSaver; + ScreenSaverAttrPtr pAttr; + WindowPtr pWin; + int result; + unsigned long mask; + Colormap *installedMaps; + int numInstalled; + int i; + Colormap wantMap; + ColormapPtr pCmap; pSaver = &pScreen->screensaver; - if (pSaver->pWindow) - { - pSaver->pWindow = NullWindow; - FreeResource (pSaver->wid, RT_NONE); - if (pPriv) - { - UninstallSaverColormap (pScreen); - pPriv->hasWindow = FALSE; - CheckScreenPrivate (pScreen); - } + if (pSaver->pWindow) { + pSaver->pWindow = NullWindow; + FreeResource(pSaver->wid, RT_NONE); + if (pPriv) { + UninstallSaverColormap(pScreen); + pPriv->hasWindow = FALSE; + CheckScreenPrivate(pScreen); + } } if (!pPriv || !(pAttr = pPriv->attr)) - return FALSE; + return FALSE; pPriv->installedMap = None; if (GrabInProgress && GrabInProgress != pAttr->client->index) - return FALSE; - - pWin = CreateWindow (pSaver->wid, pScreen->root, - pAttr->x, pAttr->y, pAttr->width, pAttr->height, - pAttr->borderWidth, pAttr->class, - pAttr->mask, (XID *)pAttr->values, - pAttr->depth, serverClient, pAttr->visual, - &result); + return FALSE; + + pWin = CreateWindow(pSaver->wid, pScreen->root, + pAttr->x, pAttr->y, pAttr->width, pAttr->height, + pAttr->borderWidth, pAttr->class, + pAttr->mask, (XID *) pAttr->values, + pAttr->depth, serverClient, pAttr->visual, &result); if (!pWin) - return FALSE; + return FALSE; if (!AddResource(pWin->drawable.id, RT_WINDOW, pWin)) - return FALSE; + return FALSE; mask = 0; - if (pAttr->pBackgroundPixmap) - { - pWin->backgroundState = BackgroundPixmap; - pWin->background.pixmap = pAttr->pBackgroundPixmap; - pAttr->pBackgroundPixmap->refcnt++; - mask |= CWBackPixmap; + if (pAttr->pBackgroundPixmap) { + pWin->backgroundState = BackgroundPixmap; + pWin->background.pixmap = pAttr->pBackgroundPixmap; + pAttr->pBackgroundPixmap->refcnt++; + mask |= CWBackPixmap; } - if (pAttr->pBorderPixmap) - { - pWin->borderIsPixel = FALSE; - pWin->border.pixmap = pAttr->pBorderPixmap; - pAttr->pBorderPixmap->refcnt++; - mask |= CWBorderPixmap; + if (pAttr->pBorderPixmap) { + pWin->borderIsPixel = FALSE; + pWin->border.pixmap = pAttr->pBorderPixmap; + pAttr->pBorderPixmap->refcnt++; + mask |= CWBorderPixmap; } - if (pAttr->pCursor) - { - if (!pWin->optional) - if (!MakeWindowOptional (pWin)) - { - FreeResource (pWin->drawable.id, RT_NONE); - return FALSE; - } - pAttr->pCursor->refcnt++; - if (pWin->optional->cursor) - FreeCursor (pWin->optional->cursor, (Cursor)0); - pWin->optional->cursor = pAttr->pCursor; - pWin->cursorIsNone = FALSE; - CheckWindowOptionalNeed (pWin); - mask |= CWCursor; + if (pAttr->pCursor) { + if (!pWin->optional) + if (!MakeWindowOptional(pWin)) { + FreeResource(pWin->drawable.id, RT_NONE); + return FALSE; + } + pAttr->pCursor->refcnt++; + if (pWin->optional->cursor) + FreeCursor(pWin->optional->cursor, (Cursor) 0); + pWin->optional->cursor = pAttr->pCursor; + pWin->cursorIsNone = FALSE; + CheckWindowOptionalNeed(pWin); + mask |= CWCursor; } if (mask) - (*pScreen->ChangeWindowAttributes) (pWin, mask); + (*pScreen->ChangeWindowAttributes) (pWin, mask); if (pAttr->colormap != None) - (void) ChangeWindowAttributes (pWin, CWColormap, &pAttr->colormap, - serverClient); + (void) ChangeWindowAttributes(pWin, CWColormap, &pAttr->colormap, + serverClient); - MapWindow (pWin, serverClient); + MapWindow(pWin, serverClient); pPriv->hasWindow = TRUE; pSaver->pWindow = pWin; /* check and install our own colormap if it isn't installed now */ - wantMap = wColormap (pWin); + wantMap = wColormap(pWin); if (wantMap == None) - return TRUE; - installedMaps = malloc(pScreen->maxInstalledCmaps * sizeof (Colormap)); + return TRUE; + installedMaps = malloc(pScreen->maxInstalledCmaps * sizeof(Colormap)); numInstalled = (*pWin->drawable.pScreen->ListInstalledColormaps) - (pScreen, installedMaps); - for (i = 0; i < numInstalled; i++) - if (installedMaps[i] == wantMap) - break; + (pScreen, installedMaps); + for (i = 0; i < numInstalled; i++) + if (installedMaps[i] == wantMap) + break; free((char *) installedMaps); if (i < numInstalled) - return TRUE; + return TRUE; - result = dixLookupResourceByType((pointer *)&pCmap, wantMap, RT_COLORMAP, - serverClient, DixInstallAccess); + result = dixLookupResourceByType((pointer *) &pCmap, wantMap, RT_COLORMAP, + serverClient, DixInstallAccess); if (result != Success) - return TRUE; + return TRUE; pPriv->installedMap = wantMap; @@ -614,229 +579,221 @@ CreateSaverWindow (ScreenPtr pScreen) } static Bool -DestroySaverWindow (ScreenPtr pScreen) +DestroySaverWindow(ScreenPtr pScreen) { SetupScreen(pScreen); - ScreenSaverStuffPtr pSaver; + ScreenSaverStuffPtr pSaver; if (!pPriv || !pPriv->hasWindow) - return FALSE; + return FALSE; pSaver = &pScreen->screensaver; - if (pSaver->pWindow) - { - pSaver->pWindow = NullWindow; - FreeResource (pSaver->wid, RT_NONE); + if (pSaver->pWindow) { + pSaver->pWindow = NullWindow; + FreeResource(pSaver->wid, RT_NONE); } pPriv->hasWindow = FALSE; - CheckScreenPrivate (pScreen); - UninstallSaverColormap (pScreen); + CheckScreenPrivate(pScreen); + UninstallSaverColormap(pScreen); return TRUE; } static Bool -ScreenSaverHandle (ScreenPtr pScreen, int xstate, Bool force) +ScreenSaverHandle(ScreenPtr pScreen, int xstate, Bool force) { - int state = 0; - Bool ret = FALSE; - ScreenSaverScreenPrivatePtr pPriv; - - switch (xstate) - { - case SCREEN_SAVER_ON: - state = ScreenSaverOn; - ret = CreateSaverWindow (pScreen); - break; - case SCREEN_SAVER_OFF: - state = ScreenSaverOff; - ret = DestroySaverWindow (pScreen); - break; - case SCREEN_SAVER_CYCLE: - state = ScreenSaverCycle; - pPriv = GetScreenPrivate (pScreen); - if (pPriv && pPriv->hasWindow) - ret = TRUE; - + int state = 0; + Bool ret = FALSE; + ScreenSaverScreenPrivatePtr pPriv; + + switch (xstate) { + case SCREEN_SAVER_ON: + state = ScreenSaverOn; + ret = CreateSaverWindow(pScreen); + break; + case SCREEN_SAVER_OFF: + state = ScreenSaverOff; + ret = DestroySaverWindow(pScreen); + break; + case SCREEN_SAVER_CYCLE: + state = ScreenSaverCycle; + pPriv = GetScreenPrivate(pScreen); + if (pPriv && pPriv->hasWindow) + ret = TRUE; + } #ifdef PANORAMIX - if(noPanoramiXExtension || !pScreen->myNum) + if (noPanoramiXExtension || !pScreen->myNum) #endif - SendScreenSaverNotify (pScreen, state, force); + SendScreenSaverNotify(pScreen, state, force); return ret; } static int -ProcScreenSaverQueryVersion (ClientPtr client) +ProcScreenSaverQueryVersion(ClientPtr client) { - xScreenSaverQueryVersionReply rep; - REQUEST_SIZE_MATCH (xScreenSaverQueryVersionReq); + xScreenSaverQueryVersionReply rep; + + REQUEST_SIZE_MATCH(xScreenSaverQueryVersionReq); rep.type = X_Reply; rep.length = 0; rep.sequenceNumber = client->sequence; rep.majorVersion = SERVER_SAVER_MAJOR_VERSION; rep.minorVersion = SERVER_SAVER_MINOR_VERSION; if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); + swaps(&rep.sequenceNumber); + swapl(&rep.length); } - WriteToClient(client, sizeof (xScreenSaverQueryVersionReply), (char *)&rep); + WriteToClient(client, sizeof(xScreenSaverQueryVersionReply), (char *) &rep); return Success; } static int -ProcScreenSaverQueryInfo (ClientPtr client) +ProcScreenSaverQueryInfo(ClientPtr client) { REQUEST(xScreenSaverQueryInfoReq); - xScreenSaverQueryInfoReply rep; - int rc; - ScreenSaverStuffPtr pSaver; - DrawablePtr pDraw; - CARD32 lastInput; - ScreenSaverScreenPrivatePtr pPriv; - - REQUEST_SIZE_MATCH (xScreenSaverQueryInfoReq); + xScreenSaverQueryInfoReply rep; + int rc; + ScreenSaverStuffPtr pSaver; + DrawablePtr pDraw; + CARD32 lastInput; + ScreenSaverScreenPrivatePtr pPriv; + + REQUEST_SIZE_MATCH(xScreenSaverQueryInfoReq); rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, - DixGetAttrAccess); + DixGetAttrAccess); if (rc != Success) - return rc; + return rc; rc = XaceHook(XACE_SCREENSAVER_ACCESS, client, pDraw->pScreen, - DixGetAttrAccess); + DixGetAttrAccess); if (rc != Success) - return rc; + return rc; pSaver = &pDraw->pScreen->screensaver; - pPriv = GetScreenPrivate (pDraw->pScreen); + pPriv = GetScreenPrivate(pDraw->pScreen); - UpdateCurrentTime (); + UpdateCurrentTime(); lastInput = GetTimeInMillis() - lastDeviceEventTime.milliseconds; rep.type = X_Reply; rep.length = 0; rep.sequenceNumber = client->sequence; rep.window = pSaver->wid; - if (screenIsSaved != SCREEN_SAVER_OFF) - { - rep.state = ScreenSaverOn; - if (ScreenSaverTime) - rep.tilOrSince = lastInput - ScreenSaverTime; - else - rep.tilOrSince = 0; + if (screenIsSaved != SCREEN_SAVER_OFF) { + rep.state = ScreenSaverOn; + if (ScreenSaverTime) + rep.tilOrSince = lastInput - ScreenSaverTime; + else + rep.tilOrSince = 0; } - else - { - if (ScreenSaverTime) - { - rep.state = ScreenSaverOff; - if (ScreenSaverTime < lastInput) - rep.tilOrSince = 0; - else - rep.tilOrSince = ScreenSaverTime - lastInput; - } - else - { - rep.state = ScreenSaverDisabled; - rep.tilOrSince = 0; - } + else { + if (ScreenSaverTime) { + rep.state = ScreenSaverOff; + if (ScreenSaverTime < lastInput) + rep.tilOrSince = 0; + else + rep.tilOrSince = ScreenSaverTime - lastInput; + } + else { + rep.state = ScreenSaverDisabled; + rep.tilOrSince = 0; + } } rep.idle = lastInput; - rep.eventMask = getEventMask (pDraw->pScreen, client); + rep.eventMask = getEventMask(pDraw->pScreen, client); if (pPriv && pPriv->attr) - rep.kind = ScreenSaverExternal; + rep.kind = ScreenSaverExternal; else if (ScreenSaverBlanking != DontPreferBlanking) - rep.kind = ScreenSaverBlanked; + rep.kind = ScreenSaverBlanked; else - rep.kind = ScreenSaverInternal; - if (client->swapped) - { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - swapl(&rep.window); - swapl(&rep.tilOrSince); - swapl(&rep.idle); - swapl(&rep.eventMask); + rep.kind = ScreenSaverInternal; + if (client->swapped) { + swaps(&rep.sequenceNumber); + swapl(&rep.length); + swapl(&rep.window); + swapl(&rep.tilOrSince); + swapl(&rep.idle); + swapl(&rep.eventMask); } - WriteToClient(client, sizeof (xScreenSaverQueryInfoReply), (char *)&rep); + WriteToClient(client, sizeof(xScreenSaverQueryInfoReply), (char *) &rep); return Success; } static int -ProcScreenSaverSelectInput (ClientPtr client) +ProcScreenSaverSelectInput(ClientPtr client) { REQUEST(xScreenSaverSelectInputReq); - DrawablePtr pDraw; - int rc; + DrawablePtr pDraw; + int rc; - REQUEST_SIZE_MATCH (xScreenSaverSelectInputReq); - rc = dixLookupDrawable (&pDraw, stuff->drawable, client, 0, - DixGetAttrAccess); + REQUEST_SIZE_MATCH(xScreenSaverSelectInputReq); + rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, + DixGetAttrAccess); if (rc != Success) - return rc; + return rc; rc = XaceHook(XACE_SCREENSAVER_ACCESS, client, pDraw->pScreen, - DixSetAttrAccess); + DixSetAttrAccess); if (rc != Success) - return rc; + return rc; - if (!setEventMask (pDraw->pScreen, client, stuff->eventMask)) - return BadAlloc; + if (!setEventMask(pDraw->pScreen, client, stuff->eventMask)) + return BadAlloc; return Success; } static int -ScreenSaverSetAttributes (ClientPtr client) +ScreenSaverSetAttributes(ClientPtr client) { REQUEST(xScreenSaverSetAttributesReq); - DrawablePtr pDraw; - WindowPtr pParent; - ScreenPtr pScreen; + DrawablePtr pDraw; + WindowPtr pParent; + ScreenPtr pScreen; ScreenSaverScreenPrivatePtr pPriv = 0; - ScreenSaverAttrPtr pAttr = 0; - int ret, len, class, bw, depth; - unsigned long visual; - int idepth, ivisual; - Bool fOK; - DepthPtr pDepth; - WindowOptPtr ancwopt; - unsigned int *pVlist; - unsigned long *values = 0; - unsigned long tmask, imask; - unsigned long val; - Pixmap pixID; - PixmapPtr pPixmap; - Cursor cursorID; - CursorPtr pCursor; - Colormap cmap; - ColormapPtr pCmap; - - REQUEST_AT_LEAST_SIZE (xScreenSaverSetAttributesReq); + ScreenSaverAttrPtr pAttr = 0; + int ret, len, class, bw, depth; + unsigned long visual; + int idepth, ivisual; + Bool fOK; + DepthPtr pDepth; + WindowOptPtr ancwopt; + unsigned int *pVlist; + unsigned long *values = 0; + unsigned long tmask, imask; + unsigned long val; + Pixmap pixID; + PixmapPtr pPixmap; + Cursor cursorID; + CursorPtr pCursor; + Colormap cmap; + ColormapPtr pCmap; + + REQUEST_AT_LEAST_SIZE(xScreenSaverSetAttributesReq); ret = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, - DixGetAttrAccess); + DixGetAttrAccess); if (ret != Success) - return ret; + return ret; pScreen = pDraw->pScreen; pParent = pScreen->root; ret = XaceHook(XACE_SCREENSAVER_ACCESS, client, pScreen, DixSetAttrAccess); if (ret != Success) - return ret; + return ret; - len = stuff->length - bytes_to_int32(sizeof(xScreenSaverSetAttributesReq)); + len = stuff->length - bytes_to_int32(sizeof(xScreenSaverSetAttributesReq)); if (Ones(stuff->mask) != len) return BadLength; - if (!stuff->width || !stuff->height) - { - client->errorValue = 0; + if (!stuff->width || !stuff->height) { + client->errorValue = 0; return BadValue; } - switch (class = stuff->c_class) - { + switch (class = stuff->c_class) { case CopyFromParent: case InputOnly: case InputOutput: - break; + break; default: - client->errorValue = class; - return BadValue; + client->errorValue = class; + return BadValue; } bw = stuff->borderWidth; depth = stuff->depth; @@ -845,12 +802,11 @@ ScreenSaverSetAttributes (ClientPtr client) /* copied directly from CreateWindow */ if (class == CopyFromParent) - class = pParent->drawable.class; + class = pParent->drawable.class; - if ((class != InputOutput) && (class != InputOnly)) - { - client->errorValue = class; - return BadValue; + if ((class != InputOutput) && (class != InputOnly)) { + client->errorValue = class; + return BadValue; } if ((class != InputOnly) && (pParent->drawable.class == InputOnly)) @@ -863,73 +819,61 @@ ScreenSaverSetAttributes (ClientPtr client) depth = pParent->drawable.depth; ancwopt = pParent->optional; if (!ancwopt) - ancwopt = FindWindowWithOptional(pParent)->optional; + ancwopt = FindWindowWithOptional(pParent)->optional; if (visual == CopyFromParent) - visual = ancwopt->visual; + visual = ancwopt->visual; /* Find out if the depth and visual are acceptable for this Screen */ - if ((visual != ancwopt->visual) || (depth != pParent->drawable.depth)) - { - fOK = FALSE; - for(idepth = 0; idepth < pScreen->numDepths; idepth++) - { - pDepth = (DepthPtr) &pScreen->allowedDepths[idepth]; - if ((depth == pDepth->depth) || (depth == 0)) - { - for (ivisual = 0; ivisual < pDepth->numVids; ivisual++) - { - if (visual == pDepth->vids[ivisual]) - { - fOK = TRUE; - break; - } - } - } - } - if (fOK == FALSE) - return BadMatch; + if ((visual != ancwopt->visual) || (depth != pParent->drawable.depth)) { + fOK = FALSE; + for (idepth = 0; idepth < pScreen->numDepths; idepth++) { + pDepth = (DepthPtr) & pScreen->allowedDepths[idepth]; + if ((depth == pDepth->depth) || (depth == 0)) { + for (ivisual = 0; ivisual < pDepth->numVids; ivisual++) { + if (visual == pDepth->vids[ivisual]) { + fOK = TRUE; + break; + } + } + } + } + if (fOK == FALSE) + return BadMatch; } if (((stuff->mask & (CWBorderPixmap | CWBorderPixel)) == 0) && - (class != InputOnly) && - (depth != pParent->drawable.depth)) - { + (class != InputOnly) && (depth != pParent->drawable.depth)) { return BadMatch; } if (((stuff->mask & CWColormap) == 0) && - (class != InputOnly) && - ((visual != ancwopt->visual) || (ancwopt->colormap == None))) - { - return BadMatch; + (class != InputOnly) && + ((visual != ancwopt->visual) || (ancwopt->colormap == None))) { + return BadMatch; } /* end of errors from CreateWindow */ - pPriv = GetScreenPrivate (pScreen); - if (pPriv && pPriv->attr) - { - if (pPriv->attr->client != client) - return BadAccess; + pPriv = GetScreenPrivate(pScreen); + if (pPriv && pPriv->attr) { + if (pPriv->attr->client != client) + return BadAccess; } - if (!pPriv) - { - pPriv = MakeScreenPrivate (pScreen); - if (!pPriv) - return FALSE; + if (!pPriv) { + pPriv = MakeScreenPrivate(pScreen); + if (!pPriv) + return FALSE; } - pAttr = New (ScreenSaverAttrRec); - if (!pAttr) - { - ret = BadAlloc; - goto bail; + pAttr = New(ScreenSaverAttrRec); + if (!pAttr) { + ret = BadAlloc; + goto bail; } /* over allocate for override redirect */ - pAttr->values = values = malloc((len + 1) * sizeof (unsigned long)); - if (!values) - { - ret = BadAlloc; - goto bail; + pAttr->values = values = malloc((len + 1) * sizeof(unsigned long)); + if (!values) { + ret = BadAlloc; + goto bail; } pAttr->screen = pScreen; pAttr->client = client; @@ -953,318 +897,297 @@ ScreenSaverSetAttributes (ClientPtr client) pAttr->mask = tmask = stuff->mask | CWOverrideRedirect; pVlist = (unsigned int *) (stuff + 1); while (tmask) { - imask = lowbit (tmask); - tmask &= ~imask; - switch (imask) - { - case CWBackPixmap: - pixID = (Pixmap )*pVlist; - if (pixID == None) - { - *values++ = None; - } - else if (pixID == ParentRelative) - { - if (depth != pParent->drawable.depth) - { - ret = BadMatch; - goto PatchUp; - } - *values++ = ParentRelative; - } - else - { - ret = dixLookupResourceByType((pointer *)&pPixmap, pixID, RT_PIXMAP, - client, DixReadAccess); - if (ret == Success) - { - if ((pPixmap->drawable.depth != depth) || - (pPixmap->drawable.pScreen != pScreen)) - { + imask = lowbit(tmask); + tmask &= ~imask; + switch (imask) { + case CWBackPixmap: + pixID = (Pixmap) * pVlist; + if (pixID == None) { + *values++ = None; + } + else if (pixID == ParentRelative) { + if (depth != pParent->drawable.depth) { + ret = BadMatch; + goto PatchUp; + } + *values++ = ParentRelative; + } + else { + ret = + dixLookupResourceByType((pointer *) &pPixmap, pixID, + RT_PIXMAP, client, DixReadAccess); + if (ret == Success) { + if ((pPixmap->drawable.depth != depth) || + (pPixmap->drawable.pScreen != pScreen)) { + ret = BadMatch; + goto PatchUp; + } + pAttr->pBackgroundPixmap = pPixmap; + pPixmap->refcnt++; + pAttr->mask &= ~CWBackPixmap; + } + else { + client->errorValue = pixID; + goto PatchUp; + } + } + break; + case CWBackPixel: + *values++ = (CARD32) *pVlist; + break; + case CWBorderPixmap: + pixID = (Pixmap) * pVlist; + if (pixID == CopyFromParent) { + if (depth != pParent->drawable.depth) { + ret = BadMatch; + goto PatchUp; + } + *values++ = CopyFromParent; + } + else { + ret = + dixLookupResourceByType((pointer *) &pPixmap, pixID, + RT_PIXMAP, client, DixReadAccess); + if (ret == Success) { + if ((pPixmap->drawable.depth != depth) || + (pPixmap->drawable.pScreen != pScreen)) { ret = BadMatch; - goto PatchUp; - } - pAttr->pBackgroundPixmap = pPixmap; - pPixmap->refcnt++; - pAttr->mask &= ~CWBackPixmap; - } - else - { - client->errorValue = pixID; - goto PatchUp; - } - } - break; - case CWBackPixel: - *values++ = (CARD32) *pVlist; - break; - case CWBorderPixmap: - pixID = (Pixmap ) *pVlist; - if (pixID == CopyFromParent) - { - if (depth != pParent->drawable.depth) - { - ret = BadMatch; - goto PatchUp; - } - *values++ = CopyFromParent; - } - else - { - ret = dixLookupResourceByType((pointer *)&pPixmap, pixID, RT_PIXMAP, - client, DixReadAccess); - if (ret == Success) - { - if ((pPixmap->drawable.depth != depth) || - (pPixmap->drawable.pScreen != pScreen)) - { - ret = BadMatch; - goto PatchUp; - } - pAttr->pBorderPixmap = pPixmap; - pPixmap->refcnt++; - pAttr->mask &= ~CWBorderPixmap; - } - else - { - client->errorValue = pixID; - goto PatchUp; - } - } - break; - case CWBorderPixel: + goto PatchUp; + } + pAttr->pBorderPixmap = pPixmap; + pPixmap->refcnt++; + pAttr->mask &= ~CWBorderPixmap; + } + else { + client->errorValue = pixID; + goto PatchUp; + } + } + break; + case CWBorderPixel: + *values++ = (CARD32) *pVlist; + break; + case CWBitGravity: + val = (CARD8) *pVlist; + if (val > StaticGravity) { + ret = BadValue; + client->errorValue = val; + goto PatchUp; + } + *values++ = val; + break; + case CWWinGravity: + val = (CARD8) *pVlist; + if (val > StaticGravity) { + ret = BadValue; + client->errorValue = val; + goto PatchUp; + } + *values++ = val; + break; + case CWBackingStore: + val = (CARD8) *pVlist; + if ((val != NotUseful) && (val != WhenMapped) && (val != Always)) { + ret = BadValue; + client->errorValue = val; + goto PatchUp; + } + *values++ = val; + break; + case CWBackingPlanes: *values++ = (CARD32) *pVlist; break; - case CWBitGravity: - val = (CARD8 )*pVlist; - if (val > StaticGravity) - { - ret = BadValue; - client->errorValue = val; - goto PatchUp; - } - *values++ = val; - break; - case CWWinGravity: - val = (CARD8 )*pVlist; - if (val > StaticGravity) - { - ret = BadValue; - client->errorValue = val; - goto PatchUp; - } - *values++ = val; - break; - case CWBackingStore: - val = (CARD8 )*pVlist; - if ((val != NotUseful) && (val != WhenMapped) && (val != Always)) - { - ret = BadValue; - client->errorValue = val; - goto PatchUp; - } - *values++ = val; - break; - case CWBackingPlanes: - *values++ = (CARD32) *pVlist; - break; - case CWBackingPixel: - *values++ = (CARD32) *pVlist; - break; - case CWSaveUnder: - val = (BOOL) *pVlist; - if ((val != xTrue) && (val != xFalse)) - { - ret = BadValue; - client->errorValue = val; - goto PatchUp; - } - *values++ = val; - break; - case CWEventMask: - *values++ = (CARD32) *pVlist; - break; - case CWDontPropagate: - *values++ = (CARD32) *pVlist; - break; - case CWOverrideRedirect: - if (!(stuff->mask & CWOverrideRedirect)) - pVlist--; - else - { - val = (BOOL ) *pVlist; - if ((val != xTrue) && (val != xFalse)) - { - ret = BadValue; - client->errorValue = val; - goto PatchUp; - } - } - *values++ = xTrue; - break; - case CWColormap: - cmap = (Colormap) *pVlist; - ret = dixLookupResourceByType((pointer *)&pCmap, cmap, RT_COLORMAP, - client, DixUseAccess); - if (ret != Success) - { - client->errorValue = cmap; - goto PatchUp; - } - if (pCmap->pVisual->vid != visual || pCmap->pScreen != pScreen) - { - ret = BadMatch; - goto PatchUp; - } - pAttr->colormap = cmap; - pAttr->mask &= ~CWColormap; - break; - case CWCursor: - cursorID = (Cursor ) *pVlist; - if ( cursorID == None) - { - *values++ = None; - } - else - { - ret = dixLookupResourceByType((pointer *)&pCursor, cursorID, - RT_CURSOR, client, DixUseAccess); - if (ret != Success) - { - client->errorValue = cursorID; - goto PatchUp; - } - pCursor->refcnt++; - pAttr->pCursor = pCursor; - pAttr->mask &= ~CWCursor; - } - break; - default: - ret = BadValue; - client->errorValue = stuff->mask; - goto PatchUp; - } - pVlist++; + case CWBackingPixel: + *values++ = (CARD32) *pVlist; + break; + case CWSaveUnder: + val = (BOOL) * pVlist; + if ((val != xTrue) && (val != xFalse)) { + ret = BadValue; + client->errorValue = val; + goto PatchUp; + } + *values++ = val; + break; + case CWEventMask: + *values++ = (CARD32) *pVlist; + break; + case CWDontPropagate: + *values++ = (CARD32) *pVlist; + break; + case CWOverrideRedirect: + if (!(stuff->mask & CWOverrideRedirect)) + pVlist--; + else { + val = (BOOL) * pVlist; + if ((val != xTrue) && (val != xFalse)) { + ret = BadValue; + client->errorValue = val; + goto PatchUp; + } + } + *values++ = xTrue; + break; + case CWColormap: + cmap = (Colormap) * pVlist; + ret = dixLookupResourceByType((pointer *) &pCmap, cmap, RT_COLORMAP, + client, DixUseAccess); + if (ret != Success) { + client->errorValue = cmap; + goto PatchUp; + } + if (pCmap->pVisual->vid != visual || pCmap->pScreen != pScreen) { + ret = BadMatch; + goto PatchUp; + } + pAttr->colormap = cmap; + pAttr->mask &= ~CWColormap; + break; + case CWCursor: + cursorID = (Cursor) * pVlist; + if (cursorID == None) { + *values++ = None; + } + else { + ret = dixLookupResourceByType((pointer *) &pCursor, cursorID, + RT_CURSOR, client, DixUseAccess); + if (ret != Success) { + client->errorValue = cursorID; + goto PatchUp; + } + pCursor->refcnt++; + pAttr->pCursor = pCursor; + pAttr->mask &= ~CWCursor; + } + break; + default: + ret = BadValue; + client->errorValue = stuff->mask; + goto PatchUp; + } + pVlist++; } if (pPriv->attr) - FreeScreenAttr (pPriv->attr); + FreeScreenAttr(pPriv->attr); pPriv->attr = pAttr; - pAttr->resource = FakeClientID (client->index); - if (!AddResource (pAttr->resource, AttrType, (pointer) pAttr)) - return BadAlloc; + pAttr->resource = FakeClientID(client->index); + if (!AddResource(pAttr->resource, AttrType, (pointer) pAttr)) + return BadAlloc; return Success; -PatchUp: - FreeAttrs (pAttr); -bail: - CheckScreenPrivate (pScreen); - if (pAttr) free(pAttr->values); + PatchUp: + FreeAttrs(pAttr); + bail: + CheckScreenPrivate(pScreen); + if (pAttr) + free(pAttr->values); free(pAttr); return ret; } static int -ScreenSaverUnsetAttributes (ClientPtr client) +ScreenSaverUnsetAttributes(ClientPtr client) { REQUEST(xScreenSaverSetAttributesReq); - DrawablePtr pDraw; - ScreenSaverScreenPrivatePtr pPriv; - int rc; + DrawablePtr pDraw; + ScreenSaverScreenPrivatePtr pPriv; + int rc; - REQUEST_SIZE_MATCH (xScreenSaverUnsetAttributesReq); + REQUEST_SIZE_MATCH(xScreenSaverUnsetAttributesReq); rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, - DixGetAttrAccess); + DixGetAttrAccess); if (rc != Success) - return rc; - pPriv = GetScreenPrivate (pDraw->pScreen); - if (pPriv && pPriv->attr && pPriv->attr->client == client) - { - FreeResource (pPriv->attr->resource, AttrType); - FreeScreenAttr (pPriv->attr); - pPriv->attr = NULL; - CheckScreenPrivate (pDraw->pScreen); + return rc; + pPriv = GetScreenPrivate(pDraw->pScreen); + if (pPriv && pPriv->attr && pPriv->attr->client == client) { + FreeResource(pPriv->attr->resource, AttrType); + FreeScreenAttr(pPriv->attr); + pPriv->attr = NULL; + CheckScreenPrivate(pDraw->pScreen); } return Success; } static int -ProcScreenSaverSetAttributes (ClientPtr client) +ProcScreenSaverSetAttributes(ClientPtr client) { #ifdef PANORAMIX - if(!noPanoramiXExtension) { - REQUEST(xScreenSaverSetAttributesReq); - PanoramiXRes *draw; - PanoramiXRes *backPix = NULL; - PanoramiXRes *bordPix = NULL; - PanoramiXRes *cmap = NULL; - int i, status, len; - int pback_offset = 0, pbord_offset = 0, cmap_offset = 0; - XID orig_visual, tmp; - - REQUEST_AT_LEAST_SIZE (xScreenSaverSetAttributesReq); - - status = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, - XRC_DRAWABLE, client, DixWriteAccess); - if (status != Success) - return (status == BadValue) ? BadDrawable : status; - - len = stuff->length - bytes_to_int32(sizeof(xScreenSaverSetAttributesReq)); - if (Ones(stuff->mask) != len) - return BadLength; - - if((Mask)stuff->mask & CWBackPixmap) { - pback_offset = Ones((Mask)stuff->mask & (CWBackPixmap - 1)); - tmp = *((CARD32 *) &stuff[1] + pback_offset); - if ((tmp != None) && (tmp != ParentRelative)) { - status = dixLookupResourceByType((pointer *)&backPix, tmp, - XRT_PIXMAP, client, - DixReadAccess); - if (status != Success) - return status; - } - } - - if ((Mask)stuff->mask & CWBorderPixmap) { - pbord_offset = Ones((Mask)stuff->mask & (CWBorderPixmap - 1)); - tmp = *((CARD32 *) &stuff[1] + pbord_offset); - if (tmp != CopyFromParent) { - status = dixLookupResourceByType((pointer *)&bordPix, tmp, - XRT_PIXMAP, client, - DixReadAccess); - if (status != Success) - return status; - } - } - - if ((Mask)stuff->mask & CWColormap) { - cmap_offset = Ones((Mask)stuff->mask & (CWColormap - 1)); - tmp = *((CARD32 *) &stuff[1] + cmap_offset); - if ((tmp != CopyFromParent) && (tmp != None)) { - status = dixLookupResourceByType((pointer *)&cmap, tmp, - XRT_COLORMAP, client, - DixReadAccess); - if (status != Success) - return status; - } - } - - orig_visual = stuff->visualID; - - FOR_NSCREENS_BACKWARD(i) { - stuff->drawable = draw->info[i].id; - if (backPix) - *((CARD32 *) &stuff[1] + pback_offset) = backPix->info[i].id; - if (bordPix) - *((CARD32 *) &stuff[1] + pbord_offset) = bordPix->info[i].id; - if (cmap) - *((CARD32 *) &stuff[1] + cmap_offset) = cmap->info[i].id; - - if (orig_visual != CopyFromParent) - stuff->visualID = PanoramiXTranslateVisualID(i, orig_visual); - - status = ScreenSaverSetAttributes(client); - } - - return status; + if (!noPanoramiXExtension) { + REQUEST(xScreenSaverSetAttributesReq); + PanoramiXRes *draw; + PanoramiXRes *backPix = NULL; + PanoramiXRes *bordPix = NULL; + PanoramiXRes *cmap = NULL; + int i, status, len; + int pback_offset = 0, pbord_offset = 0, cmap_offset = 0; + XID orig_visual, tmp; + + REQUEST_AT_LEAST_SIZE(xScreenSaverSetAttributesReq); + + status = dixLookupResourceByClass((pointer *) &draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (status != Success) + return (status == BadValue) ? BadDrawable : status; + + len = + stuff->length - + bytes_to_int32(sizeof(xScreenSaverSetAttributesReq)); + if (Ones(stuff->mask) != len) + return BadLength; + + if ((Mask) stuff->mask & CWBackPixmap) { + pback_offset = Ones((Mask) stuff->mask & (CWBackPixmap - 1)); + tmp = *((CARD32 *) &stuff[1] + pback_offset); + if ((tmp != None) && (tmp != ParentRelative)) { + status = dixLookupResourceByType((pointer *) &backPix, tmp, + XRT_PIXMAP, client, + DixReadAccess); + if (status != Success) + return status; + } + } + + if ((Mask) stuff->mask & CWBorderPixmap) { + pbord_offset = Ones((Mask) stuff->mask & (CWBorderPixmap - 1)); + tmp = *((CARD32 *) &stuff[1] + pbord_offset); + if (tmp != CopyFromParent) { + status = dixLookupResourceByType((pointer *) &bordPix, tmp, + XRT_PIXMAP, client, + DixReadAccess); + if (status != Success) + return status; + } + } + + if ((Mask) stuff->mask & CWColormap) { + cmap_offset = Ones((Mask) stuff->mask & (CWColormap - 1)); + tmp = *((CARD32 *) &stuff[1] + cmap_offset); + if ((tmp != CopyFromParent) && (tmp != None)) { + status = dixLookupResourceByType((pointer *) &cmap, tmp, + XRT_COLORMAP, client, + DixReadAccess); + if (status != Success) + return status; + } + } + + orig_visual = stuff->visualID; + + FOR_NSCREENS_BACKWARD(i) { + stuff->drawable = draw->info[i].id; + if (backPix) + *((CARD32 *) &stuff[1] + pback_offset) = backPix->info[i].id; + if (bordPix) + *((CARD32 *) &stuff[1] + pbord_offset) = bordPix->info[i].id; + if (cmap) + *((CARD32 *) &stuff[1] + cmap_offset) = cmap->info[i].id; + + if (orig_visual != CopyFromParent) + stuff->visualID = PanoramiXTranslateVisualID(i, orig_visual); + + status = ScreenSaverSetAttributes(client); + } + + return status; } #endif @@ -1272,25 +1195,25 @@ ProcScreenSaverSetAttributes (ClientPtr client) } static int -ProcScreenSaverUnsetAttributes (ClientPtr client) +ProcScreenSaverUnsetAttributes(ClientPtr client) { #ifdef PANORAMIX - if(!noPanoramiXExtension) { - REQUEST(xScreenSaverUnsetAttributesReq); - PanoramiXRes *draw; - int rc, i; + if (!noPanoramiXExtension) { + REQUEST(xScreenSaverUnsetAttributesReq); + PanoramiXRes *draw; + int rc, i; - rc = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, - XRC_DRAWABLE, client, DixWriteAccess); - if (rc != Success) - return (rc == BadValue) ? BadDrawable : rc; + rc = dixLookupResourceByClass((pointer *) &draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (rc != Success) + return (rc == BadValue) ? BadDrawable : rc; - for(i = PanoramiXNumScreens - 1; i > 0; i--) { + for (i = PanoramiXNumScreens - 1; i > 0; i--) { stuff->drawable = draw->info[i].id; ScreenSaverUnsetAttributes(client); - } + } - stuff->drawable = draw->info[0].id; + stuff->drawable = draw->info[0].id; } #endif @@ -1298,7 +1221,7 @@ ProcScreenSaverUnsetAttributes (ClientPtr client) } static int -ProcScreenSaverSuspend (ClientPtr client) +ProcScreenSaverSuspend(ClientPtr client) { ScreenSaverSuspensionPtr *prev, this; @@ -1307,22 +1230,21 @@ ProcScreenSaverSuspend (ClientPtr client) /* Check if this client is suspending the screensaver */ for (prev = &suspendingClients; (this = *prev); prev = &this->next) - if (this->pClient == client) - break; + if (this->pClient == client) + break; - if (this) - { - if (stuff->suspend == TRUE) - this->count++; - else if (--this->count == 0) - FreeResource (this->clientResource, RT_NONE); + if (this) { + if (stuff->suspend == TRUE) + this->count++; + else if (--this->count == 0) + FreeResource(this->clientResource, RT_NONE); - return Success; + return Success; } /* If we get to this point, this client isn't suspending the screensaver */ if (stuff->suspend == FALSE) - return Success; + return Success; /* * Allocate a suspension record for the client, and stop the screensaver @@ -1330,85 +1252,81 @@ ProcScreenSaverSuspend (ClientPtr client) * to the record, so the screensaver will be reenabled and the record freed * if the client disconnects without reenabling it first. */ - this = malloc(sizeof (ScreenSaverSuspensionRec)); + this = malloc(sizeof(ScreenSaverSuspensionRec)); if (!this) - return BadAlloc; + return BadAlloc; - this->next = NULL; - this->pClient = client; - this->count = 1; - this->clientResource = FakeClientID (client->index); + this->next = NULL; + this->pClient = client; + this->count = 1; + this->clientResource = FakeClientID(client->index); - if (!AddResource (this->clientResource, SuspendType, (pointer) this)) - { - free(this); - return BadAlloc; + if (!AddResource(this->clientResource, SuspendType, (pointer) this)) { + free(this); + return BadAlloc; } *prev = this; - if (!screenSaverSuspended) - { - screenSaverSuspended = TRUE; - FreeScreenSaverTimer(); + if (!screenSaverSuspended) { + screenSaverSuspended = TRUE; + FreeScreenSaverTimer(); } return Success; } -static int (*NormalVector[]) (ClientPtr /* client */) = { - ProcScreenSaverQueryVersion, - ProcScreenSaverQueryInfo, - ProcScreenSaverSelectInput, - ProcScreenSaverSetAttributes, - ProcScreenSaverUnsetAttributes, - ProcScreenSaverSuspend, -}; +static int (*NormalVector[]) (ClientPtr /* client */ ) = { +ProcScreenSaverQueryVersion, + ProcScreenSaverQueryInfo, + ProcScreenSaverSelectInput, + ProcScreenSaverSetAttributes, + ProcScreenSaverUnsetAttributes, ProcScreenSaverSuspend,}; #define NUM_REQUESTS ((sizeof NormalVector) / (sizeof NormalVector[0])) static int -ProcScreenSaverDispatch (ClientPtr client) +ProcScreenSaverDispatch(ClientPtr client) { REQUEST(xReq); if (stuff->data < NUM_REQUESTS) - return (*NormalVector[stuff->data])(client); + return (*NormalVector[stuff->data]) (client); return BadRequest; } static int -SProcScreenSaverQueryVersion (ClientPtr client) +SProcScreenSaverQueryVersion(ClientPtr client) { REQUEST(xScreenSaverQueryVersionReq); swaps(&stuff->length); REQUEST_SIZE_MATCH(xScreenSaverQueryVersionReq); - return ProcScreenSaverQueryVersion (client); + return ProcScreenSaverQueryVersion(client); } static int -SProcScreenSaverQueryInfo (ClientPtr client) +SProcScreenSaverQueryInfo(ClientPtr client) { REQUEST(xScreenSaverQueryInfoReq); swaps(&stuff->length); REQUEST_SIZE_MATCH(xScreenSaverQueryInfoReq); swapl(&stuff->drawable); - return ProcScreenSaverQueryInfo (client); + return ProcScreenSaverQueryInfo(client); } static int -SProcScreenSaverSelectInput (ClientPtr client) +SProcScreenSaverSelectInput(ClientPtr client) { REQUEST(xScreenSaverSelectInputReq); swaps(&stuff->length); REQUEST_SIZE_MATCH(xScreenSaverSelectInputReq); swapl(&stuff->drawable); swapl(&stuff->eventMask); - return ProcScreenSaverSelectInput (client); + return ProcScreenSaverSelectInput(client); } static int -SProcScreenSaverSetAttributes (ClientPtr client) +SProcScreenSaverSetAttributes(ClientPtr client) { REQUEST(xScreenSaverSetAttributesReq); swaps(&stuff->length); @@ -1422,45 +1340,43 @@ SProcScreenSaverSetAttributes (ClientPtr client) swapl(&stuff->visualID); swapl(&stuff->mask); SwapRestL(stuff); - return ProcScreenSaverSetAttributes (client); + return ProcScreenSaverSetAttributes(client); } static int -SProcScreenSaverUnsetAttributes (ClientPtr client) +SProcScreenSaverUnsetAttributes(ClientPtr client) { REQUEST(xScreenSaverUnsetAttributesReq); swaps(&stuff->length); REQUEST_SIZE_MATCH(xScreenSaverUnsetAttributesReq); swapl(&stuff->drawable); - return ProcScreenSaverUnsetAttributes (client); + return ProcScreenSaverUnsetAttributes(client); } static int -SProcScreenSaverSuspend (ClientPtr client) +SProcScreenSaverSuspend(ClientPtr client) { REQUEST(xScreenSaverSuspendReq); swaps(&stuff->length); REQUEST_SIZE_MATCH(xScreenSaverSuspendReq); - return ProcScreenSaverSuspend (client); + return ProcScreenSaverSuspend(client); } -static int (*SwappedVector[]) (ClientPtr /* client */) = { - SProcScreenSaverQueryVersion, - SProcScreenSaverQueryInfo, - SProcScreenSaverSelectInput, - SProcScreenSaverSetAttributes, - SProcScreenSaverUnsetAttributes, - SProcScreenSaverSuspend, -}; +static int (*SwappedVector[]) (ClientPtr /* client */ ) = { +SProcScreenSaverQueryVersion, + SProcScreenSaverQueryInfo, + SProcScreenSaverSelectInput, + SProcScreenSaverSetAttributes, + SProcScreenSaverUnsetAttributes, SProcScreenSaverSuspend,}; static int -SProcScreenSaverDispatch (ClientPtr client) +SProcScreenSaverDispatch(ClientPtr client) { REQUEST(xReq); if (stuff->data < NUM_REQUESTS) - return (*SwappedVector[stuff->data])(client); + return (*SwappedVector[stuff->data]) (client); return BadRequest; } @@ -1468,29 +1384,27 @@ void ScreenSaverExtensionInit(INITARGS) { ExtensionEntry *extEntry; - int i; - ScreenPtr pScreen; + int i; + ScreenPtr pScreen; if (!dixRegisterPrivateKey(&ScreenPrivateKeyRec, PRIVATE_SCREEN, 0)) - return; + return; AttrType = CreateNewResourceType(ScreenSaverFreeAttr, "SaverAttr"); - SaverEventType = CreateNewResourceType(ScreenSaverFreeEvents, - "SaverEvent"); - SuspendType = CreateNewResourceType(ScreenSaverFreeSuspend, - "SaverSuspend"); - - for (i = 0; i < screenInfo.numScreens; i++) - { - pScreen = screenInfo.screens[i]; - SetScreenPrivate (pScreen, NULL); + SaverEventType = CreateNewResourceType(ScreenSaverFreeEvents, "SaverEvent"); + SuspendType = CreateNewResourceType(ScreenSaverFreeSuspend, "SaverSuspend"); + + for (i = 0; i < screenInfo.numScreens; i++) { + pScreen = screenInfo.screens[i]; + SetScreenPrivate(pScreen, NULL); } if (AttrType && SaverEventType && SuspendType && - (extEntry = AddExtension(ScreenSaverName, ScreenSaverNumberEvents, 0, - ProcScreenSaverDispatch, SProcScreenSaverDispatch, - NULL, StandardMinorOpcode))) - { - ScreenSaverEventBase = extEntry->eventBase; - EventSwapVector[ScreenSaverEventBase] = (EventSwapPtr) SScreenSaverNotifyEvent; + (extEntry = AddExtension(ScreenSaverName, ScreenSaverNumberEvents, 0, + ProcScreenSaverDispatch, + SProcScreenSaverDispatch, NULL, + StandardMinorOpcode))) { + ScreenSaverEventBase = extEntry->eventBase; + EventSwapVector[ScreenSaverEventBase] = + (EventSwapPtr) SScreenSaverNotifyEvent; } } diff --git a/Xext/security.c b/Xext/security.c index df5bd5822..3699510d3 100644 --- a/Xext/security.c +++ b/Xext/security.c @@ -42,16 +42,17 @@ in this Software without prior written authorization from The Open Group. #include "protocol-versions.h" /* Extension stuff */ -static int SecurityErrorBase; /* first Security error number */ -static int SecurityEventBase; /* first Security event number */ +static int SecurityErrorBase; /* first Security error number */ +static int SecurityEventBase; /* first Security event number */ -RESTYPE SecurityAuthorizationResType; /* resource type for authorizations */ +RESTYPE SecurityAuthorizationResType; /* resource type for authorizations */ static RESTYPE RTEventClient; static CallbackListPtr SecurityValidateGroupCallback = NULL; /* Private state record */ static DevPrivateKeyRec stateKeyRec; + #define stateKey (&stateKeyRec) /* This is what we store as client security state */ @@ -84,7 +85,6 @@ static const Mask SecurityDeviceMask = static const Mask SecurityServerMask = DixGetAttrAccess | DixGrabAccess; static const Mask SecurityClientMask = DixGetAttrAccess; - /* SecurityAudit * * Arguments: @@ -97,33 +97,34 @@ static const Mask SecurityClientMask = DixGetAttrAccess; * Writes the message to the log file if security logging is on. */ -static void _X_ATTRIBUTE_PRINTF(1,2) +static void +_X_ATTRIBUTE_PRINTF(1, 2) SecurityAudit(const char *format, ...) { va_list args; if (auditTrailLevel < SECURITY_AUDIT_LEVEL) - return; + return; va_start(args, format); VAuditF(format, args); va_end(args); -} /* SecurityAudit */ +} /* SecurityAudit */ /* * Performs a Security permission check. */ static int -SecurityDoCheck(SecurityStateRec *subj, SecurityStateRec *obj, - Mask requested, Mask allowed) +SecurityDoCheck(SecurityStateRec * subj, SecurityStateRec * obj, + Mask requested, Mask allowed) { if (!subj->haveState || !obj->haveState) - return Success; + return Success; if (subj->trustLevel == XSecurityClientTrusted) - return Success; + return Success; if (obj->trustLevel != XSecurityClientTrusted) - return Success; + return Success; if ((requested | allowed) == allowed) - return Success; + return Success; return BadAccess; } @@ -151,7 +152,6 @@ SecurityLookupRequestName(ClientPtr client) return LookupRequestName(client->majorOp, client->minorOp); } - /* SecurityDeleteAuthorization * * Arguments: @@ -165,11 +165,9 @@ SecurityLookupRequestName(ClientPtr client) */ static int -SecurityDeleteAuthorization( - pointer value, - XID id) +SecurityDeleteAuthorization(pointer value, XID id) { - SecurityAuthorizationPtr pAuth = (SecurityAuthorizationPtr)value; + SecurityAuthorizationPtr pAuth = (SecurityAuthorizationPtr) value; unsigned short name_len, data_len; const char *name; char *data; @@ -179,74 +177,67 @@ SecurityDeleteAuthorization( /* Remove the auth using the os layer auth manager */ - status = AuthorizationFromID(pAuth->id, &name_len, &name, - &data_len, &data); + status = AuthorizationFromID(pAuth->id, &name_len, &name, &data_len, &data); assert(status); status = RemoveAuthorization(name_len, name, data_len, data); assert(status); - (void)status; + (void) status; /* free the auth timer if there is one */ - if (pAuth->timer) TimerFree(pAuth->timer); + if (pAuth->timer) + TimerFree(pAuth->timer); /* send revoke events */ - while ((pEventClient = pAuth->eventClients)) - { - /* send revocation event event */ - xSecurityAuthorizationRevokedEvent are; - are.type = SecurityEventBase + XSecurityAuthorizationRevoked; - are.authId = pAuth->id; - WriteEventsToClient(rClient(pEventClient), 1, (xEvent *)&are); - FreeResource(pEventClient->resource, RT_NONE); + while ((pEventClient = pAuth->eventClients)) { + /* send revocation event event */ + xSecurityAuthorizationRevokedEvent are; + + are.type = SecurityEventBase + XSecurityAuthorizationRevoked; + are.authId = pAuth->id; + WriteEventsToClient(rClient(pEventClient), 1, (xEvent *) &are); + FreeResource(pEventClient->resource, RT_NONE); } /* kill all clients using this auth */ - for (i = 1; i<currentMaxClients; i++) - if (clients[i]) { - SecurityStateRec *state; - state = dixLookupPrivate(&clients[i]->devPrivates, stateKey); - if (state->haveState && state->authId == pAuth->id) - CloseDownClient(clients[i]); - } + for (i = 1; i < currentMaxClients; i++) + if (clients[i]) { + SecurityStateRec *state; + + state = dixLookupPrivate(&clients[i]->devPrivates, stateKey); + if (state->haveState && state->authId == pAuth->id) + CloseDownClient(clients[i]); + } SecurityAudit("revoked authorization ID %d\n", pAuth->id); free(pAuth); return Success; -} /* SecurityDeleteAuthorization */ - +} /* SecurityDeleteAuthorization */ /* resource delete function for RTEventClient */ static int -SecurityDeleteAuthorizationEventClient( - pointer value, - XID id) +SecurityDeleteAuthorizationEventClient(pointer value, XID id) { OtherClientsPtr pEventClient, prev = NULL; - SecurityAuthorizationPtr pAuth = (SecurityAuthorizationPtr)value; + SecurityAuthorizationPtr pAuth = (SecurityAuthorizationPtr) value; for (pEventClient = pAuth->eventClients; - pEventClient; - pEventClient = pEventClient->next) - { - if (pEventClient->resource == id) - { - if (prev) - prev->next = pEventClient->next; - else - pAuth->eventClients = pEventClient->next; - free(pEventClient); - return Success; - } - prev = pEventClient; + pEventClient; pEventClient = pEventClient->next) { + if (pEventClient->resource == id) { + if (prev) + prev->next = pEventClient->next; + else + pAuth->eventClients = pEventClient->next; + free(pEventClient); + return Success; + } + prev = pEventClient; } - /*NOTREACHED*/ - return -1; /* make compiler happy */ -} /* SecurityDeleteAuthorizationEventClient */ - + /*NOTREACHED*/ return -1; /* make compiler happy */ +} /* SecurityDeleteAuthorizationEventClient */ /* SecurityComputeAuthorizationTimeout * @@ -263,26 +254,23 @@ SecurityDeleteAuthorizationEventClient( */ static CARD32 -SecurityComputeAuthorizationTimeout( - SecurityAuthorizationPtr pAuth, - unsigned int seconds) +SecurityComputeAuthorizationTimeout(SecurityAuthorizationPtr pAuth, + unsigned int seconds) { /* maxSecs is the number of full seconds that can be expressed in * 32 bits worth of milliseconds */ - CARD32 maxSecs = (CARD32)(~0) / (CARD32)MILLI_PER_SECOND; + CARD32 maxSecs = (CARD32) (~0) / (CARD32) MILLI_PER_SECOND; - if (seconds > maxSecs) - { /* only come here if we want to wait more than 49 days */ - pAuth->secondsRemaining = seconds - maxSecs; - return maxSecs * MILLI_PER_SECOND; + if (seconds > maxSecs) { /* only come here if we want to wait more than 49 days */ + pAuth->secondsRemaining = seconds - maxSecs; + return maxSecs * MILLI_PER_SECOND; } - else - { /* by far the common case */ - pAuth->secondsRemaining = 0; - return seconds * MILLI_PER_SECOND; + else { /* by far the common case */ + pAuth->secondsRemaining = 0; + return seconds * MILLI_PER_SECOND; } -} /* SecurityStartAuthorizationTimer */ +} /* SecurityStartAuthorizationTimer */ /* SecurityAuthorizationExpired * @@ -304,26 +292,21 @@ SecurityComputeAuthorizationTimeout( */ static CARD32 -SecurityAuthorizationExpired( - OsTimerPtr timer, - CARD32 time, - pointer pval) +SecurityAuthorizationExpired(OsTimerPtr timer, CARD32 time, pointer pval) { - SecurityAuthorizationPtr pAuth = (SecurityAuthorizationPtr)pval; + SecurityAuthorizationPtr pAuth = (SecurityAuthorizationPtr) pval; assert(pAuth->timer == timer); - if (pAuth->secondsRemaining) - { - return SecurityComputeAuthorizationTimeout(pAuth, - pAuth->secondsRemaining); + if (pAuth->secondsRemaining) { + return SecurityComputeAuthorizationTimeout(pAuth, + pAuth->secondsRemaining); } - else - { - FreeResource(pAuth->id, RT_NONE); - return 0; + else { + FreeResource(pAuth->id, RT_NONE); + return 0; } -} /* SecurityAuthorizationExpired */ +} /* SecurityAuthorizationExpired */ /* SecurityStartAuthorizationTimer * @@ -339,104 +322,91 @@ SecurityAuthorizationExpired( */ static void -SecurityStartAuthorizationTimer( - SecurityAuthorizationPtr pAuth) +SecurityStartAuthorizationTimer(SecurityAuthorizationPtr pAuth) { pAuth->timer = TimerSet(pAuth->timer, 0, - SecurityComputeAuthorizationTimeout(pAuth, pAuth->timeout), - SecurityAuthorizationExpired, pAuth); -} /* SecurityStartAuthorizationTimer */ - + SecurityComputeAuthorizationTimeout(pAuth, + pAuth->timeout), + SecurityAuthorizationExpired, pAuth); +} /* SecurityStartAuthorizationTimer */ /* Proc functions all take a client argument, execute the request in * client->requestBuffer, and return a protocol error status. */ static int -ProcSecurityQueryVersion( - ClientPtr client) +ProcSecurityQueryVersion(ClientPtr client) { /* REQUEST(xSecurityQueryVersionReq); */ - xSecurityQueryVersionReply rep; + xSecurityQueryVersionReply rep; REQUEST_SIZE_MATCH(xSecurityQueryVersionReq); - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.length = 0; - rep.majorVersion = SERVER_SECURITY_MAJOR_VERSION; - rep.minorVersion = SERVER_SECURITY_MINOR_VERSION; - if(client->swapped) - { - swaps(&rep.sequenceNumber); - swaps(&rep.majorVersion); - swaps(&rep.minorVersion); + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.length = 0; + rep.majorVersion = SERVER_SECURITY_MAJOR_VERSION; + rep.minorVersion = SERVER_SECURITY_MINOR_VERSION; + if (client->swapped) { + swaps(&rep.sequenceNumber); + swaps(&rep.majorVersion); + swaps(&rep.minorVersion); } - (void)WriteToClient(client, SIZEOF(xSecurityQueryVersionReply), - (char *)&rep); + (void) WriteToClient(client, SIZEOF(xSecurityQueryVersionReply), + (char *) &rep); return Success; -} /* ProcSecurityQueryVersion */ - +} /* ProcSecurityQueryVersion */ static int -SecurityEventSelectForAuthorization( - SecurityAuthorizationPtr pAuth, - ClientPtr client, - Mask mask) +SecurityEventSelectForAuthorization(SecurityAuthorizationPtr pAuth, + ClientPtr client, Mask mask) { OtherClients *pEventClient; for (pEventClient = pAuth->eventClients; - pEventClient; - pEventClient = pEventClient->next) - { - if (SameClient(pEventClient, client)) - { - if (mask == 0) - FreeResource(pEventClient->resource, RT_NONE); - else - pEventClient->mask = mask; - return Success; - } + pEventClient; pEventClient = pEventClient->next) { + if (SameClient(pEventClient, client)) { + if (mask == 0) + FreeResource(pEventClient->resource, RT_NONE); + else + pEventClient->mask = mask; + return Success; + } } - + pEventClient = malloc(sizeof(OtherClients)); if (!pEventClient) - return BadAlloc; + return BadAlloc; pEventClient->mask = mask; pEventClient->resource = FakeClientID(client->index); pEventClient->next = pAuth->eventClients; - if (!AddResource(pEventClient->resource, RTEventClient, - (pointer)pAuth)) - { - free(pEventClient); - return BadAlloc; + if (!AddResource(pEventClient->resource, RTEventClient, (pointer) pAuth)) { + free(pEventClient); + return BadAlloc; } pAuth->eventClients = pEventClient; return Success; -} /* SecurityEventSelectForAuthorization */ - +} /* SecurityEventSelectForAuthorization */ static int -ProcSecurityGenerateAuthorization( - ClientPtr client) +ProcSecurityGenerateAuthorization(ClientPtr client) { REQUEST(xSecurityGenerateAuthorizationReq); - int len; /* request length in CARD32s*/ - Bool removeAuth = FALSE; /* if bailout, call RemoveAuthorization? */ - SecurityAuthorizationPtr pAuth = NULL; /* auth we are creating */ - int err; /* error to return from this function */ - XID authId; /* authorization ID assigned by os layer */ - xSecurityGenerateAuthorizationReply rep; /* reply struct */ + int len; /* request length in CARD32s */ + Bool removeAuth = FALSE; /* if bailout, call RemoveAuthorization? */ + SecurityAuthorizationPtr pAuth = NULL; /* auth we are creating */ + int err; /* error to return from this function */ + XID authId; /* authorization ID assigned by os layer */ + xSecurityGenerateAuthorizationReply rep; /* reply struct */ unsigned int trustLevel; /* trust level of new auth */ - XID group; /* group of new auth */ - CARD32 timeout; /* timeout of new auth */ - CARD32 *values; /* list of supplied attributes */ - char *protoname; /* auth proto name sent in request */ - char *protodata; /* auth proto data sent in request */ + XID group; /* group of new auth */ + CARD32 timeout; /* timeout of new auth */ + CARD32 *values; /* list of supplied attributes */ + char *protoname; /* auth proto name sent in request */ + char *protodata; /* auth proto data sent in request */ unsigned int authdata_len; /* # bytes of generated auth data */ - char *pAuthdata; /* generated auth data */ - Mask eventMask; /* what events on this auth does client want */ + char *pAuthdata; /* generated auth data */ + Mask eventMask; /* what events on this auth does client want */ /* check request length */ @@ -444,84 +414,75 @@ ProcSecurityGenerateAuthorization( len = bytes_to_int32(SIZEOF(xSecurityGenerateAuthorizationReq)); len += bytes_to_int32(stuff->nbytesAuthProto); len += bytes_to_int32(stuff->nbytesAuthData); - values = ((CARD32 *)stuff) + len; + values = ((CARD32 *) stuff) + len; len += Ones(stuff->valueMask); if (client->req_len != len) - return BadLength; + return BadLength; /* check valuemask */ - if (stuff->valueMask & ~XSecurityAllAuthorizationAttributes) - { - client->errorValue = stuff->valueMask; - return BadValue; + if (stuff->valueMask & ~XSecurityAllAuthorizationAttributes) { + client->errorValue = stuff->valueMask; + return BadValue; } /* check timeout */ timeout = 60; - if (stuff->valueMask & XSecurityTimeout) - { - timeout = *values++; + if (stuff->valueMask & XSecurityTimeout) { + timeout = *values++; } /* check trustLevel */ trustLevel = XSecurityClientUntrusted; - if (stuff->valueMask & XSecurityTrustLevel) - { - trustLevel = *values++; - if (trustLevel != XSecurityClientTrusted && - trustLevel != XSecurityClientUntrusted) - { - client->errorValue = trustLevel; - return BadValue; - } + if (stuff->valueMask & XSecurityTrustLevel) { + trustLevel = *values++; + if (trustLevel != XSecurityClientTrusted && + trustLevel != XSecurityClientUntrusted) { + client->errorValue = trustLevel; + return BadValue; + } } /* check group */ group = None; - if (stuff->valueMask & XSecurityGroup) - { - group = *values++; - if (SecurityValidateGroupCallback) - { - SecurityValidateGroupInfoRec vgi; - vgi.group = group; - vgi.valid = FALSE; - CallCallbacks(&SecurityValidateGroupCallback, (pointer)&vgi); - - /* if nobody said they recognized it, it's an error */ - - if (!vgi.valid) - { - client->errorValue = group; - return BadValue; - } - } + if (stuff->valueMask & XSecurityGroup) { + group = *values++; + if (SecurityValidateGroupCallback) { + SecurityValidateGroupInfoRec vgi; + + vgi.group = group; + vgi.valid = FALSE; + CallCallbacks(&SecurityValidateGroupCallback, (pointer) &vgi); + + /* if nobody said they recognized it, it's an error */ + + if (!vgi.valid) { + client->errorValue = group; + return BadValue; + } + } } /* check event mask */ eventMask = 0; - if (stuff->valueMask & XSecurityEventMask) - { - eventMask = *values++; - if (eventMask & ~XSecurityAllEventMasks) - { - client->errorValue = eventMask; - return BadValue; - } + if (stuff->valueMask & XSecurityEventMask) { + eventMask = *values++; + if (eventMask & ~XSecurityAllEventMasks) { + client->errorValue = eventMask; + return BadValue; + } } - protoname = (char *)&stuff[1]; + protoname = (char *) &stuff[1]; protodata = protoname + bytes_to_int32(stuff->nbytesAuthProto); /* call os layer to generate the authorization */ authId = GenerateAuthorization(stuff->nbytesAuthProto, protoname, - stuff->nbytesAuthData, protodata, - &authdata_len, &pAuthdata); - if ((XID) ~0L == authId) - { - err = SecurityErrorBase + XSecurityBadAuthorizationProtocol; - goto bailout; + stuff->nbytesAuthData, protodata, + &authdata_len, &pAuthdata); + if ((XID) ~0L == authId) { + err = SecurityErrorBase + XSecurityBadAuthorizationProtocol; + goto bailout; } /* now that we've added the auth, remember to remove it if we have to @@ -532,10 +493,9 @@ ProcSecurityGenerateAuthorization( /* associate additional information with this auth ID */ pAuth = malloc(sizeof(SecurityAuthorizationRec)); - if (!pAuth) - { - err = BadAlloc; - goto bailout; + if (!pAuth) { + err = BadAlloc; + goto bailout; } /* fill in the auth fields */ @@ -544,29 +504,27 @@ ProcSecurityGenerateAuthorization( pAuth->timeout = timeout; pAuth->group = group; pAuth->trustLevel = trustLevel; - pAuth->refcnt = 0; /* the auth was just created; nobody's using it yet */ + pAuth->refcnt = 0; /* the auth was just created; nobody's using it yet */ pAuth->secondsRemaining = 0; pAuth->timer = NULL; pAuth->eventClients = NULL; /* handle event selection */ - if (eventMask) - { - err = SecurityEventSelectForAuthorization(pAuth, client, eventMask); - if (err != Success) - goto bailout; + if (eventMask) { + err = SecurityEventSelectForAuthorization(pAuth, client, eventMask); + if (err != Success) + goto bailout; } - if (!AddResource(authId, SecurityAuthorizationResType, pAuth)) - { - err = BadAlloc; - goto bailout; + if (!AddResource(authId, SecurityAuthorizationResType, pAuth)) { + err = BadAlloc; + goto bailout; } /* start the timer ticking */ if (pAuth->timeout != 0) - SecurityStartAuthorizationTimer(pAuth); + SecurityStartAuthorizationTimer(pAuth); /* tell client the auth id and data */ @@ -576,37 +534,36 @@ ProcSecurityGenerateAuthorization( rep.authId = authId; rep.dataLength = authdata_len; - if (client->swapped) - { - swapl(&rep.length); - swaps(&rep.sequenceNumber); - swapl(&rep.authId); - swaps(&rep.dataLength); + if (client->swapped) { + swapl(&rep.length); + swaps(&rep.sequenceNumber); + swapl(&rep.authId); + swaps(&rep.dataLength); } WriteToClient(client, SIZEOF(xSecurityGenerateAuthorizationReply), - (char *)&rep); + (char *) &rep); WriteToClient(client, authdata_len, pAuthdata); - SecurityAudit("client %d generated authorization %d trust %d timeout %d group %d events %d\n", - client->index, pAuth->id, pAuth->trustLevel, pAuth->timeout, - pAuth->group, eventMask); + SecurityAudit + ("client %d generated authorization %d trust %d timeout %d group %d events %d\n", + client->index, pAuth->id, pAuth->trustLevel, pAuth->timeout, + pAuth->group, eventMask); /* the request succeeded; don't call RemoveAuthorization or free pAuth */ return Success; -bailout: + bailout: if (removeAuth) - RemoveAuthorization(stuff->nbytesAuthProto, protoname, - authdata_len, pAuthdata); + RemoveAuthorization(stuff->nbytesAuthProto, protoname, + authdata_len, pAuthdata); free(pAuth); return err; -} /* ProcSecurityGenerateAuthorization */ +} /* ProcSecurityGenerateAuthorization */ static int -ProcSecurityRevokeAuthorization( - ClientPtr client) +ProcSecurityRevokeAuthorization(ClientPtr client) { REQUEST(xSecurityRevokeAuthorizationReq); SecurityAuthorizationPtr pAuth; @@ -614,39 +571,35 @@ ProcSecurityRevokeAuthorization( REQUEST_SIZE_MATCH(xSecurityRevokeAuthorizationReq); - rc = dixLookupResourceByType((pointer *)&pAuth, stuff->authId, - SecurityAuthorizationResType, client, - DixDestroyAccess); + rc = dixLookupResourceByType((pointer *) &pAuth, stuff->authId, + SecurityAuthorizationResType, client, + DixDestroyAccess); if (rc != Success) - return rc; + return rc; FreeResource(stuff->authId, RT_NONE); return Success; -} /* ProcSecurityRevokeAuthorization */ - +} /* ProcSecurityRevokeAuthorization */ static int -ProcSecurityDispatch( - ClientPtr client) +ProcSecurityDispatch(ClientPtr client) { REQUEST(xReq); - switch (stuff->data) - { - case X_SecurityQueryVersion: - return ProcSecurityQueryVersion(client); - case X_SecurityGenerateAuthorization: - return ProcSecurityGenerateAuthorization(client); - case X_SecurityRevokeAuthorization: - return ProcSecurityRevokeAuthorization(client); - default: - return BadRequest; + switch (stuff->data) { + case X_SecurityQueryVersion: + return ProcSecurityQueryVersion(client); + case X_SecurityGenerateAuthorization: + return ProcSecurityGenerateAuthorization(client); + case X_SecurityRevokeAuthorization: + return ProcSecurityRevokeAuthorization(client); + default: + return BadRequest; } -} /* ProcSecurityDispatch */ +} /* ProcSecurityDispatch */ static int -SProcSecurityQueryVersion( - ClientPtr client) +SProcSecurityQueryVersion(ClientPtr client) { REQUEST(xSecurityQueryVersionReq); @@ -655,12 +608,10 @@ SProcSecurityQueryVersion( swaps(&stuff->majorVersion); swaps(&stuff->minorVersion); return ProcSecurityQueryVersion(client); -} /* SProcSecurityQueryVersion */ - +} /* SProcSecurityQueryVersion */ static int -SProcSecurityGenerateAuthorization( - ClientPtr client) +SProcSecurityGenerateAuthorization(ClientPtr client) { REQUEST(xSecurityGenerateAuthorizationReq); CARD32 *values; @@ -673,20 +624,18 @@ SProcSecurityGenerateAuthorization( swaps(&stuff->nbytesAuthData); swapl(&stuff->valueMask); values_offset = bytes_to_int32(stuff->nbytesAuthProto) + - bytes_to_int32(stuff->nbytesAuthData); - if (values_offset > - stuff->length - bytes_to_int32(sz_xSecurityGenerateAuthorizationReq)) - return BadLength; - values = (CARD32 *)(&stuff[1]) + values_offset; - nvalues = (((CARD32 *)stuff) + stuff->length) - values; + bytes_to_int32(stuff->nbytesAuthData); + if (values_offset > + stuff->length - bytes_to_int32(sz_xSecurityGenerateAuthorizationReq)) + return BadLength; + values = (CARD32 *) (&stuff[1]) + values_offset; + nvalues = (((CARD32 *) stuff) + stuff->length) - values; SwapLongs(values, nvalues); return ProcSecurityGenerateAuthorization(client); -} /* SProcSecurityGenerateAuthorization */ - +} /* SProcSecurityGenerateAuthorization */ static int -SProcSecurityRevokeAuthorization( - ClientPtr client) +SProcSecurityRevokeAuthorization(ClientPtr client) { REQUEST(xSecurityRevokeAuthorizationReq); @@ -694,32 +643,28 @@ SProcSecurityRevokeAuthorization( REQUEST_SIZE_MATCH(xSecurityRevokeAuthorizationReq); swapl(&stuff->authId); return ProcSecurityRevokeAuthorization(client); -} /* SProcSecurityRevokeAuthorization */ - +} /* SProcSecurityRevokeAuthorization */ static int -SProcSecurityDispatch( - ClientPtr client) +SProcSecurityDispatch(ClientPtr client) { REQUEST(xReq); - switch (stuff->data) - { - case X_SecurityQueryVersion: - return SProcSecurityQueryVersion(client); - case X_SecurityGenerateAuthorization: - return SProcSecurityGenerateAuthorization(client); - case X_SecurityRevokeAuthorization: - return SProcSecurityRevokeAuthorization(client); - default: - return BadRequest; + switch (stuff->data) { + case X_SecurityQueryVersion: + return SProcSecurityQueryVersion(client); + case X_SecurityGenerateAuthorization: + return SProcSecurityGenerateAuthorization(client); + case X_SecurityRevokeAuthorization: + return SProcSecurityRevokeAuthorization(client); + default: + return BadRequest; } -} /* SProcSecurityDispatch */ +} /* SProcSecurityDispatch */ -static void -SwapSecurityAuthorizationRevokedEvent( - xSecurityAuthorizationRevokedEvent *from, - xSecurityAuthorizationRevokedEvent *to) +static void +SwapSecurityAuthorizationRevokedEvent(xSecurityAuthorizationRevokedEvent * from, + xSecurityAuthorizationRevokedEvent * to) { to->type = from->type; to->detail = from->detail; @@ -755,14 +700,14 @@ SecurityDevice(CallbackListPtr *pcbl, pointer unused, pointer calldata) obj = dixLookupPrivate(&serverClient->devPrivates, stateKey); if (rec->dev != inputInfo.keyboard) - /* this extension only supports the core keyboard */ - allowed = requested; + /* this extension only supports the core keyboard */ + allowed = requested; if (SecurityDoCheck(subj, obj, requested, allowed) != Success) { - SecurityAudit("Security denied client %d keyboard access on request " - "%s\n", rec->client->index, - SecurityLookupRequestName(rec->client)); - rec->status = BadAccess; + SecurityAudit("Security denied client %d keyboard access on request " + "%s\n", rec->client->index, + SecurityLookupRequestName(rec->client)); + rec->status = BadAccess; } } @@ -800,42 +745,41 @@ SecurityResource(CallbackListPtr *pcbl, pointer unused, pointer calldata) /* disable background None for untrusted windows */ if ((requested & DixCreateAccess) && (rec->rtype == RT_WINDOW)) - if (subj->haveState && subj->trustLevel != XSecurityClientTrusted) - ((WindowPtr)rec->res)->forcedBG = TRUE; + if (subj->haveState && subj->trustLevel != XSecurityClientTrusted) + ((WindowPtr) rec->res)->forcedBG = TRUE; /* additional permissions for specific resource types */ if (rec->rtype == RT_WINDOW) - allowed |= SecurityWindowExtraMask; + allowed |= SecurityWindowExtraMask; /* special checks for server-owned resources */ if (cid == 0) { - if (rec->rtype & RC_DRAWABLE) - /* additional operations allowed on root windows */ - allowed |= SecurityRootWindowExtraMask; + if (rec->rtype & RC_DRAWABLE) + /* additional operations allowed on root windows */ + allowed |= SecurityRootWindowExtraMask; - else if (rec->rtype == RT_COLORMAP) - /* allow access to default colormaps */ - allowed = requested; + else if (rec->rtype == RT_COLORMAP) + /* allow access to default colormaps */ + allowed = requested; - else - /* allow read access to other server-owned resources */ - allowed |= DixReadAccess; + else + /* allow read access to other server-owned resources */ + allowed |= DixReadAccess; } if (clients[cid] != NULL) { - obj = dixLookupPrivate(&clients[cid]->devPrivates, stateKey); - if (SecurityDoCheck(subj, obj, requested, allowed) == Success) - return; + obj = dixLookupPrivate(&clients[cid]->devPrivates, stateKey); + if (SecurityDoCheck(subj, obj, requested, allowed) == Success) + return; } SecurityAudit("Security: denied client %d access %x to resource 0x%x " - "of client %d on request %s\n", rec->client->index, - requested, rec->id, cid, - SecurityLookupRequestName(rec->client)); - rec->status = BadAccess; /* deny access */ + "of client %d on request %s\n", rec->client->index, + requested, rec->id, cid, + SecurityLookupRequestName(rec->client)); + rec->status = BadAccess; /* deny access */ } - static void SecurityExtension(CallbackListPtr *pcbl, pointer unused, pointer calldata) { @@ -846,16 +790,16 @@ SecurityExtension(CallbackListPtr *pcbl, pointer unused, pointer calldata) subj = dixLookupPrivate(&rec->client->devPrivates, stateKey); if (subj->haveState && subj->trustLevel == XSecurityClientTrusted) - return; + return; while (SecurityTrustedExtensions[i]) - if (!strcmp(SecurityTrustedExtensions[i++], rec->ext->name)) - return; + if (!strcmp(SecurityTrustedExtensions[i++], rec->ext->name)) + return; SecurityAudit("Security: denied client %d access to extension " - "%s on request %s\n", - rec->client->index, rec->ext->name, - SecurityLookupRequestName(rec->client)); + "%s on request %s\n", + rec->client->index, rec->ext->name, + SecurityLookupRequestName(rec->client)); rec->status = BadAccess; } @@ -869,12 +813,12 @@ SecurityServer(CallbackListPtr *pcbl, pointer unused, pointer calldata) subj = dixLookupPrivate(&rec->client->devPrivates, stateKey); obj = dixLookupPrivate(&serverClient->devPrivates, stateKey); - + if (SecurityDoCheck(subj, obj, requested, allowed) != Success) { - SecurityAudit("Security: denied client %d access to server " - "configuration request %s\n", rec->client->index, - SecurityLookupRequestName(rec->client)); - rec->status = BadAccess; + SecurityAudit("Security: denied client %d access to server " + "configuration request %s\n", rec->client->index, + SecurityLookupRequestName(rec->client)); + rec->status = BadAccess; } } @@ -890,16 +834,16 @@ SecurityClient(CallbackListPtr *pcbl, pointer unused, pointer calldata) obj = dixLookupPrivate(&rec->target->devPrivates, stateKey); if (SecurityDoCheck(subj, obj, requested, allowed) != Success) { - SecurityAudit("Security: denied client %d access to client %d on " - "request %s\n", rec->client->index, rec->target->index, - SecurityLookupRequestName(rec->client)); - rec->status = BadAccess; + SecurityAudit("Security: denied client %d access to client %d on " + "request %s\n", rec->client->index, rec->target->index, + SecurityLookupRequestName(rec->client)); + rec->status = BadAccess; } } static void SecurityProperty(CallbackListPtr *pcbl, pointer unused, pointer calldata) -{ |