diff options
Diffstat (limited to 'xorg-server/Xext/saver.c')
-rw-r--r-- | xorg-server/Xext/saver.c | 164 |
1 files changed, 70 insertions, 94 deletions
diff --git a/xorg-server/Xext/saver.c b/xorg-server/Xext/saver.c index 86db7b0b9..18de4b540 100644 --- a/xorg-server/Xext/saver.c +++ b/xorg-server/Xext/saver.c @@ -27,8 +27,6 @@ in this Software without prior written authorization from the X Consortium. */ -#define NEED_REPLIES -#define NEED_EVENTS #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> #endif @@ -54,8 +52,7 @@ in this Software without prior written authorization from the X Consortium. #include "panoramiXsrv.h" #endif #ifdef DPMSExtension -#define DPMS_SERVER -#include <X11/extensions/dpms.h> +#include <X11/extensions/dpmsconst.h> #endif #include <stdio.h> @@ -144,7 +141,7 @@ static int ScreenSaverFreeSuspend( * entry from the per-screen queue. */ -static RESTYPE EventType; /* resource type for event masks */ +static RESTYPE SaverEventType; /* resource type for event masks */ typedef struct _ScreenSaverEvent *ScreenSaverEventPtr; @@ -237,7 +234,7 @@ static DevPrivateKey ScreenPrivateKey = &ScreenPrivateKeyIndex; dixSetPrivate(&(s)->devPrivates, ScreenPrivateKey, v); #define SetupScreen(s) ScreenSaverScreenPrivatePtr pPriv = (s ? GetScreenPrivate(s) : NULL) -#define New(t) ((t *) xalloc (sizeof (t))) +#define New(t) (xalloc (sizeof (t))) /**************** * ScreenSaverExtensionInit @@ -255,7 +252,7 @@ ScreenSaverExtensionInit(INITARGS) ScreenPtr pScreen; AttrType = CreateNewResourceType(ScreenSaverFreeAttr); - EventType = CreateNewResourceType(ScreenSaverFreeEvents); + SaverEventType = CreateNewResourceType(ScreenSaverFreeEvents); SuspendType = CreateNewResourceType(ScreenSaverFreeSuspend); for (i = 0; i < screenInfo.numScreens; i++) @@ -263,7 +260,7 @@ ScreenSaverExtensionInit(INITARGS) pScreen = screenInfo.screens[i]; SetScreenPrivate (pScreen, NULL); } - if (AttrType && EventType && SuspendType && + if (AttrType && SaverEventType && SuspendType && (extEntry = AddExtension(ScreenSaverName, ScreenSaverNumberEvents, 0, ProcScreenSaverDispatch, SProcScreenSaverDispatch, NULL, StandardMinorOpcode))) @@ -274,8 +271,7 @@ ScreenSaverExtensionInit(INITARGS) } static void -CheckScreenPrivate (pScreen) - ScreenPtr pScreen; +CheckScreenPrivate (ScreenPtr pScreen) { SetupScreen (pScreen); @@ -291,8 +287,7 @@ CheckScreenPrivate (pScreen) } static ScreenSaverScreenPrivatePtr -MakeScreenPrivate (pScreen) - ScreenPtr pScreen; +MakeScreenPrivate (ScreenPtr pScreen) { SetupScreen (pScreen); @@ -311,9 +306,7 @@ MakeScreenPrivate (pScreen) } static unsigned long -getEventMask (pScreen, client) - ScreenPtr pScreen; - ClientPtr client; +getEventMask (ScreenPtr pScreen, ClientPtr client) { SetupScreen(pScreen); ScreenSaverEventPtr pEv; @@ -327,10 +320,7 @@ getEventMask (pScreen, client) } static Bool -setEventMask (pScreen, client, mask) - ScreenPtr pScreen; - ClientPtr client; - unsigned long mask; +setEventMask (ScreenPtr pScreen, ClientPtr client, unsigned long mask) { SetupScreen(pScreen); ScreenSaverEventPtr pEv, *pPrev; @@ -348,7 +338,7 @@ setEventMask (pScreen, client, mask) break; if (mask == 0) { - FreeResource (pEv->resource, EventType); + FreeResource (pEv->resource, SaverEventType); *pPrev = pEv->next; xfree (pEv); CheckScreenPrivate (pScreen); @@ -368,7 +358,7 @@ setEventMask (pScreen, client, mask) pEv->client = client; pEv->screen = pScreen; pEv->resource = FakeClientID (client->index); - if (!AddResource (pEv->resource, EventType, (pointer) pEv)) + if (!AddResource (pEv->resource, SaverEventType, (pointer) pEv)) return FALSE; } pEv->mask = mask; @@ -377,8 +367,7 @@ setEventMask (pScreen, client, mask) } static void -FreeAttrs (pAttr) - ScreenSaverAttrPtr pAttr; +FreeAttrs (ScreenSaverAttrPtr pAttr) { PixmapPtr pPixmap; CursorPtr pCursor; @@ -392,8 +381,7 @@ FreeAttrs (pAttr) } static void -FreeScreenAttr (pAttr) - ScreenSaverAttrPtr pAttr; +FreeScreenAttr (ScreenSaverAttrPtr pAttr) { FreeAttrs (pAttr); xfree (pAttr->values); @@ -401,9 +389,7 @@ FreeScreenAttr (pAttr) } static int -ScreenSaverFreeEvents (value, id) - pointer value; - XID id; +ScreenSaverFreeEvents (pointer value, XID id) { ScreenSaverEventPtr pOld = (ScreenSaverEventPtr)value; ScreenPtr pScreen = pOld->screen; @@ -424,9 +410,7 @@ ScreenSaverFreeEvents (value, id) } static int -ScreenSaverFreeAttr (value, id) - pointer value; - XID id; +ScreenSaverFreeAttr (pointer value, XID id) { ScreenSaverAttrPtr pOldAttr = (ScreenSaverAttrPtr)value; ScreenPtr pScreen = pOldAttr->screen; @@ -487,10 +471,7 @@ ScreenSaverFreeSuspend (pointer value, XID id) } static void -SendScreenSaverNotify (pScreen, state, forced) - ScreenPtr pScreen; - int state; - Bool forced; +SendScreenSaverNotify (ScreenPtr pScreen, int state, Bool forced) { ScreenSaverScreenPrivatePtr pPriv; ScreenSaverEventPtr pEv; @@ -533,8 +514,8 @@ SendScreenSaverNotify (pScreen, state, forced) } static void -SScreenSaverNotifyEvent (from, to) - xScreenSaverNotifyEvent *from, *to; +SScreenSaverNotifyEvent (xScreenSaverNotifyEvent *from, + xScreenSaverNotifyEvent *to) { to->type = from->type; to->state = from->state; @@ -547,16 +528,18 @@ SScreenSaverNotifyEvent (from, to) } static void -UninstallSaverColormap (pScreen) - ScreenPtr pScreen; +UninstallSaverColormap (ScreenPtr pScreen) { SetupScreen(pScreen); ColormapPtr pCmap; + int rc; if (pPriv && pPriv->installedMap != None) { - pCmap = (ColormapPtr) LookupIDByType (pPriv->installedMap, RT_COLORMAP); - if (pCmap) + rc = dixLookupResourceByType((pointer *)&pCmap, pPriv->installedMap, + RT_COLORMAP, serverClient, + DixUninstallAccess); + if (rc == Success) (*pCmap->pScreen->UninstallColormap) (pCmap); pPriv->installedMap = None; CheckScreenPrivate (pScreen); @@ -564,8 +547,7 @@ UninstallSaverColormap (pScreen) } static Bool -CreateSaverWindow (pScreen) - ScreenPtr pScreen; +CreateSaverWindow (ScreenPtr pScreen) { SetupScreen (pScreen); ScreenSaverStuffPtr pSaver; @@ -659,8 +641,7 @@ CreateSaverWindow (pScreen) wantMap = wColormap (pWin); if (wantMap == None) return TRUE; - installedMaps = (Colormap *) xalloc (pScreen->maxInstalledCmaps * - sizeof (Colormap)); + installedMaps = xalloc (pScreen->maxInstalledCmaps * sizeof (Colormap)); numInstalled = (*pWin->drawable.pScreen->ListInstalledColormaps) (pScreen, installedMaps); for (i = 0; i < numInstalled; i++) @@ -672,8 +653,9 @@ CreateSaverWindow (pScreen) if (i < numInstalled) return TRUE; - pCmap = (ColormapPtr) LookupIDByType (wantMap, RT_COLORMAP); - if (!pCmap) + result = dixLookupResourceByType((pointer *)&pCmap, wantMap, RT_COLORMAP, + serverClient, DixInstallAccess); + if (result != Success) return TRUE; pPriv->installedMap = wantMap; @@ -684,8 +666,7 @@ CreateSaverWindow (pScreen) } static Bool -DestroySaverWindow (pScreen) - ScreenPtr pScreen; +DestroySaverWindow (ScreenPtr pScreen) { SetupScreen(pScreen); ScreenSaverStuffPtr pSaver; @@ -706,10 +687,7 @@ DestroySaverWindow (pScreen) } static Bool -ScreenSaverHandle (pScreen, xstate, force) - ScreenPtr pScreen; - int xstate; - Bool force; +ScreenSaverHandle (ScreenPtr pScreen, int xstate, Bool force) { int state = 0; Bool ret = FALSE; @@ -740,8 +718,7 @@ ScreenSaverHandle (pScreen, xstate, force) } static int -ProcScreenSaverQueryVersion (client) - ClientPtr client; +ProcScreenSaverQueryVersion (ClientPtr client) { xScreenSaverQueryVersionReply rep; int n; @@ -761,8 +738,7 @@ ProcScreenSaverQueryVersion (client) } static int -ProcScreenSaverQueryInfo (client) - ClientPtr client; +ProcScreenSaverQueryInfo (ClientPtr client) { REQUEST(xScreenSaverQueryInfoReq); xScreenSaverQueryInfoReply rep; @@ -838,8 +814,7 @@ ProcScreenSaverQueryInfo (client) } static int -ProcScreenSaverSelectInput (client) - ClientPtr client; +ProcScreenSaverSelectInput (ClientPtr client) { REQUEST(xScreenSaverSelectInputReq); DrawablePtr pDraw; @@ -899,7 +874,7 @@ ScreenSaverSetAttributes (ClientPtr client) if (ret != Success) return ret; - len = stuff->length - (sizeof(xScreenSaverSetAttributesReq) >> 2); + len = stuff->length - bytes_to_int32(sizeof(xScreenSaverSetAttributesReq)); if (Ones(stuff->mask) != len) return BadLength; if (!stuff->width || !stuff->height) @@ -1004,7 +979,7 @@ ScreenSaverSetAttributes (ClientPtr client) goto bail; } /* over allocate for override redirect */ - values = (unsigned long *) xalloc ((len + 1) * sizeof (unsigned long)); + values = xalloc ((len + 1) * sizeof (unsigned long)); if (!values) { ret = BadAlloc; @@ -1280,17 +1255,18 @@ ProcScreenSaverSetAttributes (ClientPtr client) PanoramiXRes *backPix = NULL; PanoramiXRes *bordPix = NULL; PanoramiXRes *cmap = NULL; - int i, status = 0, len; + int i, status, len; int pback_offset = 0, pbord_offset = 0, cmap_offset = 0; XID orig_visual, tmp; REQUEST_AT_LEAST_SIZE (xScreenSaverSetAttributesReq); - if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) - return BadDrawable; + status = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (status != Success) + return (status == BadValue) ? BadDrawable : status; - len = stuff->length - (sizeof(xScreenSaverSetAttributesReq) >> 2); + len = stuff->length - bytes_to_int32(sizeof(xScreenSaverSetAttributesReq)); if (Ones(stuff->mask) != len) return BadLength; @@ -1298,9 +1274,11 @@ ProcScreenSaverSetAttributes (ClientPtr client) pback_offset = Ones((Mask)stuff->mask & (CWBackPixmap - 1)); tmp = *((CARD32 *) &stuff[1] + pback_offset); if ((tmp != None) && (tmp != ParentRelative)) { - if(!(backPix = (PanoramiXRes*) SecurityLookupIDByType( - client, tmp, XRT_PIXMAP, DixReadAccess))) - return BadPixmap; + status = dixLookupResourceByType((pointer *)&backPix, tmp, + XRT_PIXMAP, client, + DixReadAccess); + if (status != Success) + return (status == BadValue) ? BadPixmap : status; } } @@ -1308,9 +1286,11 @@ ProcScreenSaverSetAttributes (ClientPtr client) pbord_offset = Ones((Mask)stuff->mask & (CWBorderPixmap - 1)); tmp = *((CARD32 *) &stuff[1] + pbord_offset); if (tmp != CopyFromParent) { - if(!(bordPix = (PanoramiXRes*) SecurityLookupIDByType( - client, tmp, XRT_PIXMAP, DixReadAccess))) - return BadPixmap; + status = dixLookupResourceByType((pointer *)&bordPix, tmp, + XRT_PIXMAP, client, + DixReadAccess); + if (status != Success) + return (status == BadValue) ? BadPixmap : status; } } @@ -1318,9 +1298,11 @@ ProcScreenSaverSetAttributes (ClientPtr client) cmap_offset = Ones((Mask)stuff->mask & (CWColormap - 1)); tmp = *((CARD32 *) &stuff[1] + cmap_offset); if ((tmp != CopyFromParent) && (tmp != None)) { - if(!(cmap = (PanoramiXRes*) SecurityLookupIDByType( - client, tmp, XRT_COLORMAP, DixReadAccess))) - return BadColor; + status = dixLookupResourceByType((pointer *)&cmap, tmp, + XRT_COLORMAP, client, + DixReadAccess); + if (status != Success) + return (status == BadValue) ? BadColor : status; } } @@ -1355,11 +1337,12 @@ ProcScreenSaverUnsetAttributes (ClientPtr client) if(!noPanoramiXExtension) { REQUEST(xScreenSaverUnsetAttributesReq); PanoramiXRes *draw; - int i; + int rc, i; - if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess))) - return BadDrawable; + 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--) { stuff->drawable = draw->info[i].id; @@ -1406,7 +1389,7 @@ 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 = (ScreenSaverSuspensionPtr) xalloc (sizeof (ScreenSaverSuspensionRec)); + this = xalloc (sizeof (ScreenSaverSuspensionRec)); if (!this) return BadAlloc; @@ -1444,8 +1427,7 @@ static DISPATCH_PROC((*NormalVector[])) = { #define NUM_REQUESTS ((sizeof NormalVector) / (sizeof NormalVector[0])) static int -ProcScreenSaverDispatch (client) - ClientPtr client; +ProcScreenSaverDispatch (ClientPtr client) { REQUEST(xReq); @@ -1455,8 +1437,7 @@ ProcScreenSaverDispatch (client) } static int -SProcScreenSaverQueryVersion (client) - ClientPtr client; +SProcScreenSaverQueryVersion (ClientPtr client) { REQUEST(xScreenSaverQueryVersionReq); int n; @@ -1467,8 +1448,7 @@ SProcScreenSaverQueryVersion (client) } static int -SProcScreenSaverQueryInfo (client) - ClientPtr client; +SProcScreenSaverQueryInfo (ClientPtr client) { REQUEST(xScreenSaverQueryInfoReq); int n; @@ -1480,8 +1460,7 @@ SProcScreenSaverQueryInfo (client) } static int -SProcScreenSaverSelectInput (client) - ClientPtr client; +SProcScreenSaverSelectInput (ClientPtr client) { REQUEST(xScreenSaverSelectInputReq); int n; @@ -1494,8 +1473,7 @@ SProcScreenSaverSelectInput (client) } static int -SProcScreenSaverSetAttributes (client) - ClientPtr client; +SProcScreenSaverSetAttributes (ClientPtr client) { REQUEST(xScreenSaverSetAttributesReq); int n; @@ -1515,8 +1493,7 @@ SProcScreenSaverSetAttributes (client) } static int -SProcScreenSaverUnsetAttributes (client) - ClientPtr client; +SProcScreenSaverUnsetAttributes (ClientPtr client) { REQUEST(xScreenSaverUnsetAttributesReq); int n; @@ -1549,8 +1526,7 @@ static DISPATCH_PROC((*SwappedVector[])) = { }; static int -SProcScreenSaverDispatch (client) - ClientPtr client; +SProcScreenSaverDispatch (ClientPtr client) { REQUEST(xReq); |