aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/Xext/saver.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2009-09-09 05:23:48 +0000
committermarha <marha@users.sourceforge.net>2009-09-09 05:23:48 +0000
commit81f91c615982e50bb62708201569c33a3cd3d973 (patch)
tree4f32ecc48a3b7b5e76642f3792338263c53879bd /xorg-server/Xext/saver.c
parentb571a562410f565af2bdde52d9f7f9a23ffae04f (diff)
parenta915739887477b28d924ecc8417ee107d125bd6c (diff)
downloadvcxsrv-81f91c615982e50bb62708201569c33a3cd3d973.tar.gz
vcxsrv-81f91c615982e50bb62708201569c33a3cd3d973.tar.bz2
vcxsrv-81f91c615982e50bb62708201569c33a3cd3d973.zip
svn merge https://vcxsrv.svn.sourceforge.net/svnroot/vcxsrv/branches/released .
Diffstat (limited to 'xorg-server/Xext/saver.c')
-rw-r--r--xorg-server/Xext/saver.c164
1 files changed, 70 insertions, 94 deletions
diff --git a/xorg-server/Xext/saver.c b/xorg-server/Xext/saver.c
index c9b2eb3f8..22eb0fe2b 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>
#else
@@ -60,8 +58,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>
@@ -150,7 +147,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;
@@ -243,7 +240,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
@@ -261,7 +258,7 @@ ScreenSaverExtensionInit(INITARGS)
ScreenPtr pScreen;
AttrType = CreateNewResourceType(ScreenSaverFreeAttr);
- EventType = CreateNewResourceType(ScreenSaverFreeEvents);
+ SaverEventType = CreateNewResourceType(ScreenSaverFreeEvents);
SuspendType = CreateNewResourceType(ScreenSaverFreeSuspend);
for (i = 0; i < screenInfo.numScreens; i++)
@@ -269,7 +266,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)))
@@ -280,8 +277,7 @@ ScreenSaverExtensionInit(INITARGS)
}
static void
-CheckScreenPrivate (pScreen)
- ScreenPtr pScreen;
+CheckScreenPrivate (ScreenPtr pScreen)
{
SetupScreen (pScreen);
@@ -297,8 +293,7 @@ CheckScreenPrivate (pScreen)
}
static ScreenSaverScreenPrivatePtr
-MakeScreenPrivate (pScreen)
- ScreenPtr pScreen;
+MakeScreenPrivate (ScreenPtr pScreen)
{
SetupScreen (pScreen);
@@ -317,9 +312,7 @@ MakeScreenPrivate (pScreen)
}
static unsigned long
-getEventMask (pScreen, client)
- ScreenPtr pScreen;
- ClientPtr client;
+getEventMask (ScreenPtr pScreen, ClientPtr client)
{
SetupScreen(pScreen);
ScreenSaverEventPtr pEv;
@@ -333,10 +326,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;
@@ -354,7 +344,7 @@ setEventMask (pScreen, client, mask)
break;
if (mask == 0)
{
- FreeResource (pEv->resource, EventType);
+ FreeResource (pEv->resource, SaverEventType);
*pPrev = pEv->next;
xfree (pEv);
CheckScreenPrivate (pScreen);
@@ -374,7 +364,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;
@@ -383,8 +373,7 @@ setEventMask (pScreen, client, mask)
}
static void
-FreeAttrs (pAttr)
- ScreenSaverAttrPtr pAttr;
+FreeAttrs (ScreenSaverAttrPtr pAttr)
{
PixmapPtr pPixmap;
CursorPtr pCursor;
@@ -398,8 +387,7 @@ FreeAttrs (pAttr)
}
static void
-FreeScreenAttr (pAttr)
- ScreenSaverAttrPtr pAttr;
+FreeScreenAttr (ScreenSaverAttrPtr pAttr)
{
FreeAttrs (pAttr);
xfree (pAttr->values);
@@ -407,9 +395,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;
@@ -430,9 +416,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;
@@ -493,10 +477,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;
@@ -539,8 +520,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;
@@ -553,16 +534,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);
@@ -570,8 +553,7 @@ UninstallSaverColormap (pScreen)
}
static Bool
-CreateSaverWindow (pScreen)
- ScreenPtr pScreen;
+CreateSaverWindow (ScreenPtr pScreen)
{
SetupScreen (pScreen);
ScreenSaverStuffPtr pSaver;
@@ -665,8 +647,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++)
@@ -678,8 +659,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;
@@ -690,8 +672,7 @@ CreateSaverWindow (pScreen)
}
static Bool
-DestroySaverWindow (pScreen)
- ScreenPtr pScreen;
+DestroySaverWindow (ScreenPtr pScreen)
{
SetupScreen(pScreen);
ScreenSaverStuffPtr pSaver;
@@ -712,10 +693,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;
@@ -746,8 +724,7 @@ ScreenSaverHandle (pScreen, xstate, force)
}
static int
-ProcScreenSaverQueryVersion (client)
- ClientPtr client;
+ProcScreenSaverQueryVersion (ClientPtr client)
{
xScreenSaverQueryVersionReply rep;
int n;
@@ -767,8 +744,7 @@ ProcScreenSaverQueryVersion (client)
}
static int
-ProcScreenSaverQueryInfo (client)
- ClientPtr client;
+ProcScreenSaverQueryInfo (ClientPtr client)
{
REQUEST(xScreenSaverQueryInfoReq);
xScreenSaverQueryInfoReply rep;
@@ -844,8 +820,7 @@ ProcScreenSaverQueryInfo (client)
}
static int
-ProcScreenSaverSelectInput (client)
- ClientPtr client;
+ProcScreenSaverSelectInput (ClientPtr client)
{
REQUEST(xScreenSaverSelectInputReq);
DrawablePtr pDraw;
@@ -905,7 +880,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)
@@ -1010,7 +985,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;
@@ -1286,17 +1261,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;
@@ -1304,9 +1280,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;
}
}
@@ -1314,9 +1292,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;
}
}
@@ -1324,9 +1304,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;
}
}
@@ -1361,11 +1343,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;
@@ -1412,7 +1395,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;
@@ -1450,8 +1433,7 @@ static DISPATCH_PROC((*NormalVector[])) = {
#define NUM_REQUESTS ((sizeof NormalVector) / (sizeof NormalVector[0]))
static int
-ProcScreenSaverDispatch (client)
- ClientPtr client;
+ProcScreenSaverDispatch (ClientPtr client)
{
REQUEST(xReq);
@@ -1461,8 +1443,7 @@ ProcScreenSaverDispatch (client)
}
static int
-SProcScreenSaverQueryVersion (client)
- ClientPtr client;
+SProcScreenSaverQueryVersion (ClientPtr client)
{
REQUEST(xScreenSaverQueryVersionReq);
int n;
@@ -1473,8 +1454,7 @@ SProcScreenSaverQueryVersion (client)
}
static int
-SProcScreenSaverQueryInfo (client)
- ClientPtr client;
+SProcScreenSaverQueryInfo (ClientPtr client)
{
REQUEST(xScreenSaverQueryInfoReq);
int n;
@@ -1486,8 +1466,7 @@ SProcScreenSaverQueryInfo (client)
}
static int
-SProcScreenSaverSelectInput (client)
- ClientPtr client;
+SProcScreenSaverSelectInput (ClientPtr client)
{
REQUEST(xScreenSaverSelectInputReq);
int n;
@@ -1500,8 +1479,7 @@ SProcScreenSaverSelectInput (client)
}
static int
-SProcScreenSaverSetAttributes (client)
- ClientPtr client;
+SProcScreenSaverSetAttributes (ClientPtr client)
{
REQUEST(xScreenSaverSetAttributesReq);
int n;
@@ -1521,8 +1499,7 @@ SProcScreenSaverSetAttributes (client)
}
static int
-SProcScreenSaverUnsetAttributes (client)
- ClientPtr client;
+SProcScreenSaverUnsetAttributes (ClientPtr client)
{
REQUEST(xScreenSaverUnsetAttributesReq);
int n;
@@ -1555,8 +1532,7 @@ static DISPATCH_PROC((*SwappedVector[])) = {
};
static int
-SProcScreenSaverDispatch (client)
- ClientPtr client;
+SProcScreenSaverDispatch (ClientPtr client)
{
REQUEST(xReq);