2006-11-26 11:13:41 -07:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
Copyright (c) 1992 X Consortium
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
|
|
|
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
|
|
Except as contained in this notice, the name of the X Consortium shall not be
|
|
|
|
used in advertising or otherwise to promote the sale, use or other dealings
|
|
|
|
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
|
|
|
|
|
|
|
|
#include <X11/X.h>
|
|
|
|
#include <X11/Xproto.h>
|
|
|
|
#include "misc.h"
|
|
|
|
#include "os.h"
|
|
|
|
#include "windowstr.h"
|
|
|
|
#include "scrnintstr.h"
|
|
|
|
#include "pixmapstr.h"
|
|
|
|
#include "extnsionst.h"
|
|
|
|
#include "dixstruct.h"
|
|
|
|
#include "resource.h"
|
|
|
|
#include "opaque.h"
|
|
|
|
#include <X11/extensions/saverproto.h>
|
|
|
|
#include "gcstruct.h"
|
|
|
|
#include "cursorstr.h"
|
|
|
|
#include "colormapst.h"
|
2008-11-02 08:26:08 -07:00
|
|
|
#include "xace.h"
|
2013-06-07 11:28:45 -06:00
|
|
|
#include "inputstr.h"
|
2006-11-26 11:13:41 -07:00
|
|
|
#ifdef PANORAMIX
|
|
|
|
#include "panoramiX.h"
|
|
|
|
#include "panoramiXsrv.h"
|
|
|
|
#endif
|
|
|
|
#ifdef DPMSExtension
|
2010-04-13 13:54:46 -06:00
|
|
|
#include <X11/extensions/dpmsconst.h>
|
|
|
|
#endif
|
2010-07-27 13:02:24 -06:00
|
|
|
#include "protocol-versions.h"
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
#include "extinit.h"
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
static int ScreenSaverEventBase = 0;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static Bool ScreenSaverHandle(ScreenPtr /* pScreen */ ,
|
|
|
|
int /* xstate */ ,
|
|
|
|
Bool /* force */
|
|
|
|
);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
static Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
CreateSaverWindow(ScreenPtr /* pScreen */
|
|
|
|
);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
static Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
DestroySaverWindow(ScreenPtr /* pScreen */
|
|
|
|
);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
UninstallSaverColormap(ScreenPtr /* pScreen */
|
|
|
|
);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
CheckScreenPrivate(ScreenPtr /* pScreen */
|
|
|
|
);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void SScreenSaverNotifyEvent(xScreenSaverNotifyEvent * /* from */ ,
|
|
|
|
xScreenSaverNotifyEvent * /* to */
|
|
|
|
);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static RESTYPE SuspendType; /* resource type for suspension records */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
typedef struct _ScreenSaverSuspension *ScreenSaverSuspensionPtr;
|
|
|
|
|
|
|
|
/* List of clients that are suspending the screensaver. */
|
|
|
|
static ScreenSaverSuspensionPtr suspendingClients = NULL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* clientResource is a resource ID that's added when the record is
|
|
|
|
* allocated, so the record is freed and the screensaver resumed when
|
|
|
|
* the client disconnects. count is the number of times the client has
|
|
|
|
* requested the screensaver be suspended.
|
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
typedef struct _ScreenSaverSuspension {
|
|
|
|
ScreenSaverSuspensionPtr next;
|
|
|
|
ClientPtr pClient;
|
|
|
|
XID clientResource;
|
|
|
|
int count;
|
2006-11-26 11:13:41 -07:00
|
|
|
} ScreenSaverSuspensionRec;
|
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
static int ScreenSaverFreeSuspend(void *value, XID id);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* each screen has a list of clients requesting
|
|
|
|
* ScreenSaverNotify events. Each client has a resource
|
|
|
|
* for each screen it selects ScreenSaverNotify input for,
|
|
|
|
* this resource is used to delete the ScreenSaverNotifyRec
|
|
|
|
* entry from the per-screen queue.
|
|
|
|
*/
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static RESTYPE SaverEventType; /* resource type for event masks */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
typedef struct _ScreenSaverEvent *ScreenSaverEventPtr;
|
|
|
|
|
|
|
|
typedef struct _ScreenSaverEvent {
|
2012-06-10 07:21:05 -06:00
|
|
|
ScreenSaverEventPtr next;
|
|
|
|
ClientPtr client;
|
|
|
|
ScreenPtr screen;
|
|
|
|
XID resource;
|
|
|
|
CARD32 mask;
|
2006-11-26 11:13:41 -07:00
|
|
|
} ScreenSaverEventRec;
|
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
static int ScreenSaverFreeEvents(void * value, XID id);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
static Bool setEventMask(ScreenPtr pScreen,
|
|
|
|
ClientPtr client,
|
|
|
|
unsigned long mask);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
static unsigned long getEventMask(ScreenPtr pScreen,
|
|
|
|
ClientPtr client);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* when a client sets the screen saver attributes, a resource is
|
|
|
|
* kept to be freed when the client exits
|
|
|
|
*/
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static RESTYPE AttrType; /* resource type for attributes */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
typedef struct _ScreenSaverAttr {
|
2012-06-10 07:21:05 -06:00
|
|
|
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;
|
2006-11-26 11:13:41 -07:00
|
|
|
} ScreenSaverAttrRec, *ScreenSaverAttrPtr;
|
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
static int ScreenSaverFreeAttr(void *value, XID id);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
static void FreeAttrs(ScreenSaverAttrPtr pAttr);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
static void FreeScreenAttr(ScreenSaverAttrPtr pAttr);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
static void
|
2014-09-27 11:52:59 -06:00
|
|
|
SendScreenSaverNotify(ScreenPtr pScreen,
|
|
|
|
int state,
|
|
|
|
Bool forced);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
typedef struct _ScreenSaverScreenPrivate {
|
2012-06-10 07:21:05 -06:00
|
|
|
ScreenSaverEventPtr events;
|
|
|
|
ScreenSaverAttrPtr attr;
|
|
|
|
Bool hasWindow;
|
|
|
|
Colormap installedMap;
|
2006-11-26 11:13:41 -07:00
|
|
|
} ScreenSaverScreenPrivateRec, *ScreenSaverScreenPrivatePtr;
|
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
static ScreenSaverScreenPrivatePtr MakeScreenPrivate(ScreenPtr pScreen);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
static DevPrivateKeyRec ScreenPrivateKeyRec;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
#define ScreenPrivateKey (&ScreenPrivateKeyRec)
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
#define GetScreenPrivate(s) ((ScreenSaverScreenPrivatePtr) \
|
|
|
|
dixLookupPrivate(&(s)->devPrivates, ScreenPrivateKey))
|
|
|
|
#define SetScreenPrivate(s,v) \
|
|
|
|
dixSetPrivate(&(s)->devPrivates, ScreenPrivateKey, v);
|
2006-11-26 11:13:41 -07:00
|
|
|
#define SetupScreen(s) ScreenSaverScreenPrivatePtr pPriv = (s ? GetScreenPrivate(s) : NULL)
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
#define New(t) (malloc(sizeof (t)))
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
CheckScreenPrivate(ScreenPtr pScreen)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
SetupScreen(pScreen);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (!pPriv)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
if (!pPriv->attr && !pPriv->events &&
|
2012-06-10 07:21:05 -06:00
|
|
|
!pPriv->hasWindow && pPriv->installedMap == None) {
|
|
|
|
free(pPriv);
|
|
|
|
SetScreenPrivate(pScreen, NULL);
|
|
|
|
pScreen->screensaver.ExternalScreenSaver = NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static ScreenSaverScreenPrivatePtr
|
2012-06-10 07:21:05 -06:00
|
|
|
MakeScreenPrivate(ScreenPtr pScreen)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
SetupScreen(pScreen);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (pPriv)
|
2012-06-10 07:21:05 -06:00
|
|
|
return pPriv;
|
|
|
|
pPriv = New(ScreenSaverScreenPrivateRec);
|
2006-11-26 11:13:41 -07:00
|
|
|
if (!pPriv)
|
2012-06-10 07:21:05 -06:00
|
|
|
return 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
pPriv->events = 0;
|
|
|
|
pPriv->attr = 0;
|
|
|
|
pPriv->hasWindow = FALSE;
|
|
|
|
pPriv->installedMap = None;
|
2012-06-10 07:21:05 -06:00
|
|
|
SetScreenPrivate(pScreen, pPriv);
|
2010-12-05 08:36:02 -07:00
|
|
|
pScreen->screensaver.ExternalScreenSaver = ScreenSaverHandle;
|
2006-11-26 11:13:41 -07:00
|
|
|
return pPriv;
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned long
|
2012-06-10 07:21:05 -06:00
|
|
|
getEventMask(ScreenPtr pScreen, ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
SetupScreen(pScreen);
|
2012-06-10 07:21:05 -06:00
|
|
|
ScreenSaverEventPtr pEv;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (!pPriv)
|
2012-06-10 07:21:05 -06:00
|
|
|
return 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
for (pEv = pPriv->events; pEv; pEv = pEv->next)
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pEv->client == client)
|
|
|
|
return pEv->mask;
|
2006-11-26 11:13:41 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
setEventMask(ScreenPtr pScreen, ClientPtr client, unsigned long mask)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
SetupScreen(pScreen);
|
2012-06-10 07:21:05 -06:00
|
|
|
ScreenSaverEventPtr pEv, *pPrev;
|
|
|
|
|
|
|
|
if (getEventMask(pScreen, client) == mask)
|
|
|
|
return TRUE;
|
|
|
|
if (!pPriv) {
|
|
|
|
pPriv = MakeScreenPrivate(pScreen);
|
|
|
|
if (!pPriv)
|
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
for (pPrev = &pPriv->events; (pEv = *pPrev) != 0; pPrev = &pEv->next)
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pEv->client == client)
|
|
|
|
break;
|
|
|
|
if (mask == 0) {
|
|
|
|
FreeResource(pEv->resource, SaverEventType);
|
|
|
|
*pPrev = pEv->next;
|
|
|
|
free(pEv);
|
|
|
|
CheckScreenPrivate(pScreen);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
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);
|
2014-09-27 11:52:59 -06:00
|
|
|
if (!AddResource(pEv->resource, SaverEventType, (void *) pEv))
|
2012-06-10 07:21:05 -06:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
pEv->mask = mask;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
FreeAttrs(ScreenSaverAttrPtr pAttr)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
PixmapPtr pPixmap;
|
|
|
|
CursorPtr pCursor;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if ((pPixmap = pAttr->pBackgroundPixmap) != 0)
|
2012-06-10 07:21:05 -06:00
|
|
|
(*pPixmap->drawable.pScreen->DestroyPixmap) (pPixmap);
|
2006-11-26 11:13:41 -07:00
|
|
|
if ((pPixmap = pAttr->pBorderPixmap) != 0)
|
2012-06-10 07:21:05 -06:00
|
|
|
(*pPixmap->drawable.pScreen->DestroyPixmap) (pPixmap);
|
2006-11-26 11:13:41 -07:00
|
|
|
if ((pCursor = pAttr->pCursor) != 0)
|
2012-06-10 07:21:05 -06:00
|
|
|
FreeCursor(pCursor, (Cursor) 0);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
FreeScreenAttr(ScreenSaverAttrPtr pAttr)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
FreeAttrs(pAttr);
|
2010-12-05 08:36:02 -07:00
|
|
|
free(pAttr->values);
|
|
|
|
free(pAttr);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2014-09-27 11:52:59 -06:00
|
|
|
ScreenSaverFreeEvents(void *value, XID id)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
ScreenSaverEventPtr pOld = (ScreenSaverEventPtr) value;
|
2006-11-26 11:13:41 -07:00
|
|
|
ScreenPtr pScreen = pOld->screen;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
SetupScreen(pScreen);
|
|
|
|
ScreenSaverEventPtr pEv, *pPrev;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (!pPriv)
|
2012-06-10 07:21:05 -06:00
|
|
|
return TRUE;
|
2006-11-26 11:13:41 -07:00
|
|
|
for (pPrev = &pPriv->events; (pEv = *pPrev) != 0; pPrev = &pEv->next)
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pEv == pOld)
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
if (!pEv)
|
2012-06-10 07:21:05 -06:00
|
|
|
return TRUE;
|
2006-11-26 11:13:41 -07:00
|
|
|
*pPrev = pEv->next;
|
2010-12-05 08:36:02 -07:00
|
|
|
free(pEv);
|
2012-06-10 07:21:05 -06:00
|
|
|
CheckScreenPrivate(pScreen);
|
2006-11-26 11:13:41 -07:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2014-09-27 11:52:59 -06:00
|
|
|
ScreenSaverFreeAttr(void *value, XID id)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
ScreenSaverAttrPtr pOldAttr = (ScreenSaverAttrPtr) value;
|
|
|
|
ScreenPtr pScreen = pOldAttr->screen;
|
|
|
|
|
|
|
|
SetupScreen(pScreen);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (!pPriv)
|
2012-06-10 07:21:05 -06:00
|
|
|
return TRUE;
|
2006-11-26 11:13:41 -07:00
|
|
|
if (pPriv->attr != pOldAttr)
|
2012-06-10 07:21:05 -06:00
|
|
|
return TRUE;
|
|
|
|
FreeScreenAttr(pOldAttr);
|
2006-11-26 11:13:41 -07:00
|
|
|
pPriv->attr = NULL;
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pPriv->hasWindow) {
|
|
|
|
dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset);
|
|
|
|
dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverActive);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
CheckScreenPrivate(pScreen);
|
2006-11-26 11:13:41 -07:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2014-09-27 11:52:59 -06:00
|
|
|
ScreenSaverFreeSuspend(void *value, XID id)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
ScreenSaverSuspensionPtr data = (ScreenSaverSuspensionPtr) value;
|
|
|
|
ScreenSaverSuspensionPtr *prev, this;
|
|
|
|
|
|
|
|
/* Unlink and free the suspension record for the client */
|
2012-06-10 07:21:05 -06:00
|
|
|
for (prev = &suspendingClients; (this = *prev); prev = &this->next) {
|
|
|
|
if (this == data) {
|
|
|
|
*prev = this->next;
|
|
|
|
free(this);
|
|
|
|
break;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Reenable the screensaver if this was the last client suspending it. */
|
2012-06-10 07:21:05 -06:00
|
|
|
if (screenSaverSuspended && suspendingClients == NULL) {
|
|
|
|
screenSaverSuspended = FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* The screensaver could be active, since suspending it (by design)
|
|
|
|
doesn't prevent it from being forceably activated */
|
2006-11-26 11:13:41 -07:00
|
|
|
#ifdef DPMSExtension
|
2012-06-10 07:21:05 -06:00
|
|
|
if (screenIsSaved != SCREEN_SAVER_ON && DPMSPowerLevel == DPMSModeOn)
|
2006-11-26 11:13:41 -07:00
|
|
|
#else
|
2012-06-10 07:21:05 -06:00
|
|
|
if (screenIsSaved != SCREEN_SAVER_ON)
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
{
|
2013-06-07 11:28:45 -06:00
|
|
|
DeviceIntPtr dev;
|
2012-06-10 07:21:05 -06:00
|
|
|
UpdateCurrentTimeIf();
|
2013-06-07 11:28:45 -06:00
|
|
|
nt_list_for_each_entry(dev, inputInfo.devices, next)
|
2013-12-08 03:53:01 -07:00
|
|
|
NoticeTime(dev, currentTime);
|
2012-06-10 07:21:05 -06:00
|
|
|
SetScreenSaverTimer();
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
SendScreenSaverNotify(ScreenPtr pScreen, int state, Bool forced)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
ScreenSaverScreenPrivatePtr pPriv;
|
|
|
|
ScreenSaverEventPtr pEv;
|
|
|
|
unsigned long mask;
|
|
|
|
int kind;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
UpdateCurrentTimeIf();
|
2006-11-26 11:13:41 -07:00
|
|
|
mask = ScreenSaverNotifyMask;
|
|
|
|
if (state == ScreenSaverCycle)
|
2012-06-10 07:21:05 -06:00
|
|
|
mask = ScreenSaverCycleMask;
|
2006-11-26 11:13:41 -07:00
|
|
|
pScreen = screenInfo.screens[pScreen->myNum];
|
|
|
|
pPriv = GetScreenPrivate(pScreen);
|
|
|
|
if (!pPriv)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
if (pPriv->attr)
|
2012-06-10 07:21:05 -06:00
|
|
|
kind = ScreenSaverExternal;
|
2006-11-26 11:13:41 -07:00
|
|
|
else if (ScreenSaverBlanking != DontPreferBlanking)
|
2012-06-10 07:21:05 -06:00
|
|
|
kind = ScreenSaverBlanked;
|
2006-11-26 11:13:41 -07:00
|
|
|
else
|
2012-06-10 07:21:05 -06:00
|
|
|
kind = ScreenSaverInternal;
|
|
|
|
for (pEv = pPriv->events; pEv; pEv = pEv->next) {
|
2013-06-07 11:28:45 -06:00
|
|
|
if (pEv->mask & mask) {
|
|
|
|
xScreenSaverNotifyEvent ev = {
|
|
|
|
.type = ScreenSaverNotify + ScreenSaverEventBase,
|
|
|
|
.state = state,
|
|
|
|
.timestamp = currentTime.milliseconds,
|
|
|
|
.root = pScreen->root->drawable.id,
|
|
|
|
.window = pScreen->screensaver.wid,
|
|
|
|
.kind = kind,
|
|
|
|
.forced = forced
|
|
|
|
};
|
|
|
|
WriteEventsToClient(pEv->client, 1, (xEvent *) &ev);
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
SScreenSaverNotifyEvent(xScreenSaverNotifyEvent * from,
|
|
|
|
xScreenSaverNotifyEvent * to)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
to->type = from->type;
|
|
|
|
to->state = from->state;
|
2012-06-10 07:21:05 -06:00
|
|
|
cpswaps(from->sequenceNumber, to->sequenceNumber);
|
|
|
|
cpswapl(from->timestamp, to->timestamp);
|
|
|
|
cpswapl(from->root, to->root);
|
|
|
|
cpswapl(from->window, to->window);
|
2006-11-26 11:13:41 -07:00
|
|
|
to->kind = from->kind;
|
|
|
|
to->forced = from->forced;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
UninstallSaverColormap(ScreenPtr pScreen)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
SetupScreen(pScreen);
|
2012-06-10 07:21:05 -06:00
|
|
|
ColormapPtr pCmap;
|
2010-07-27 13:02:24 -06:00
|
|
|
int rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pPriv && pPriv->installedMap != None) {
|
2014-09-27 11:52:59 -06:00
|
|
|
rc = dixLookupResourceByType((void **) &pCmap, pPriv->installedMap,
|
2012-06-10 07:21:05 -06:00
|
|
|
RT_COLORMAP, serverClient,
|
|
|
|
DixUninstallAccess);
|
|
|
|
if (rc == Success)
|
|
|
|
(*pCmap->pScreen->UninstallColormap) (pCmap);
|
|
|
|
pPriv->installedMap = None;
|
|
|
|
CheckScreenPrivate(pScreen);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
CreateSaverWindow(ScreenPtr pScreen)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
SetupScreen(pScreen);
|
|
|
|
ScreenSaverStuffPtr pSaver;
|
|
|
|
ScreenSaverAttrPtr pAttr;
|
|
|
|
WindowPtr pWin;
|
|
|
|
int result;
|
|
|
|
unsigned long mask;
|
|
|
|
Colormap *installedMaps;
|
|
|
|
int numInstalled;
|
|
|
|
int i;
|
|
|
|
Colormap wantMap;
|
|
|
|
ColormapPtr pCmap;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
pSaver = &pScreen->screensaver;
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pSaver->pWindow) {
|
|
|
|
pSaver->pWindow = NullWindow;
|
|
|
|
FreeResource(pSaver->wid, RT_NONE);
|
|
|
|
if (pPriv) {
|
|
|
|
UninstallSaverColormap(pScreen);
|
|
|
|
pPriv->hasWindow = FALSE;
|
|
|
|
CheckScreenPrivate(pScreen);
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!pPriv || !(pAttr = pPriv->attr))
|
2012-06-10 07:21:05 -06:00
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
pPriv->installedMap = None;
|
|
|
|
|
|
|
|
if (GrabInProgress && GrabInProgress != pAttr->client->index)
|
2012-06-10 07:21:05 -06:00
|
|
|
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);
|
2006-11-26 11:13:41 -07:00
|
|
|
if (!pWin)
|
2012-06-10 07:21:05 -06:00
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (!AddResource(pWin->drawable.id, RT_WINDOW, pWin))
|
2012-06-10 07:21:05 -06:00
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
mask = 0;
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pAttr->pBackgroundPixmap) {
|
|
|
|
pWin->backgroundState = BackgroundPixmap;
|
|
|
|
pWin->background.pixmap = pAttr->pBackgroundPixmap;
|
|
|
|
pAttr->pBackgroundPixmap->refcnt++;
|
|
|
|
mask |= CWBackPixmap;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pAttr->pBorderPixmap) {
|
|
|
|
pWin->borderIsPixel = FALSE;
|
|
|
|
pWin->border.pixmap = pAttr->pBorderPixmap;
|
|
|
|
pAttr->pBorderPixmap->refcnt++;
|
|
|
|
mask |= CWBorderPixmap;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pAttr->pCursor) {
|
2013-09-28 09:36:30 -06:00
|
|
|
CursorPtr cursor;
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!pWin->optional)
|
|
|
|
if (!MakeWindowOptional(pWin)) {
|
|
|
|
FreeResource(pWin->drawable.id, RT_NONE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2013-09-28 09:36:30 -06:00
|
|
|
cursor = RefCursor(pAttr->pCursor);
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pWin->optional->cursor)
|
|
|
|
FreeCursor(pWin->optional->cursor, (Cursor) 0);
|
2013-09-28 09:36:30 -06:00
|
|
|
pWin->optional->cursor = cursor;
|
2012-06-10 07:21:05 -06:00
|
|
|
pWin->cursorIsNone = FALSE;
|
|
|
|
CheckWindowOptionalNeed(pWin);
|
|
|
|
mask |= CWCursor;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
if (mask)
|
2012-06-10 07:21:05 -06:00
|
|
|
(*pScreen->ChangeWindowAttributes) (pWin, mask);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (pAttr->colormap != None)
|
2012-06-10 07:21:05 -06:00
|
|
|
(void) ChangeWindowAttributes(pWin, CWColormap, &pAttr->colormap,
|
|
|
|
serverClient);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
MapWindow(pWin, serverClient);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
pPriv->hasWindow = TRUE;
|
|
|
|
pSaver->pWindow = pWin;
|
|
|
|
|
|
|
|
/* check and install our own colormap if it isn't installed now */
|
2012-06-10 07:21:05 -06:00
|
|
|
wantMap = wColormap(pWin);
|
2006-11-26 11:13:41 -07:00
|
|
|
if (wantMap == None)
|
2012-06-10 07:21:05 -06:00
|
|
|
return TRUE;
|
|
|
|
installedMaps = malloc(pScreen->maxInstalledCmaps * sizeof(Colormap));
|
2006-11-26 11:13:41 -07:00
|
|
|
numInstalled = (*pWin->drawable.pScreen->ListInstalledColormaps)
|
2012-06-10 07:21:05 -06:00
|
|
|
(pScreen, installedMaps);
|
|
|
|
for (i = 0; i < numInstalled; i++)
|
|
|
|
if (installedMaps[i] == wantMap)
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
free((char *) installedMaps);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (i < numInstalled)
|
2012-06-10 07:21:05 -06:00
|
|
|
return TRUE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
result = dixLookupResourceByType((void **) &pCmap, wantMap, RT_COLORMAP,
|
2012-06-10 07:21:05 -06:00
|
|
|
serverClient, DixInstallAccess);
|
2010-07-27 13:02:24 -06:00
|
|
|
if (result != Success)
|
2012-06-10 07:21:05 -06:00
|
|
|
return TRUE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
pPriv->installedMap = wantMap;
|
|
|
|
|
|
|
|
(*pCmap->pScreen->InstallColormap) (pCmap);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
DestroySaverWindow(ScreenPtr pScreen)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
SetupScreen(pScreen);
|
2012-06-10 07:21:05 -06:00
|
|
|
ScreenSaverStuffPtr pSaver;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (!pPriv || !pPriv->hasWindow)
|
2012-06-10 07:21:05 -06:00
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
pSaver = &pScreen->screensaver;
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pSaver->pWindow) {
|
|
|
|
pSaver->pWindow = NullWindow;
|
|
|
|
FreeResource(pSaver->wid, RT_NONE);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
pPriv->hasWindow = FALSE;
|
2012-06-10 07:21:05 -06:00
|
|
|
CheckScreenPrivate(pScreen);
|
|
|
|
UninstallSaverColormap(pScreen);
|
2006-11-26 11:13:41 -07:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
ScreenSaverHandle(ScreenPtr pScreen, int xstate, Bool force)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
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;
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
#ifdef PANORAMIX
|
2012-06-10 07:21:05 -06:00
|
|
|
if (noPanoramiXExtension || !pScreen->myNum)
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
SendScreenSaverNotify(pScreen, state, force);
|
2006-11-26 11:13:41 -07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcScreenSaverQueryVersion(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2013-06-07 11:28:45 -06:00
|
|
|
xScreenSaverQueryVersionReply rep = {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = 0,
|
|
|
|
.majorVersion = SERVER_SAVER_MAJOR_VERSION,
|
|
|
|
.minorVersion = SERVER_SAVER_MINOR_VERSION
|
|
|
|
};
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
REQUEST_SIZE_MATCH(xScreenSaverQueryVersionReq);
|
2013-06-07 11:28:45 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
if (client->swapped) {
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&rep.sequenceNumber);
|
|
|
|
swapl(&rep.length);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(client, sizeof(xScreenSaverQueryVersionReply), &rep);
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcScreenSaverQueryInfo(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xScreenSaverQueryInfoReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
xScreenSaverQueryInfoReply rep;
|
|
|
|
int rc;
|
|
|
|
ScreenSaverStuffPtr pSaver;
|
|
|
|
DrawablePtr pDraw;
|
|
|
|
CARD32 lastInput;
|
|
|
|
ScreenSaverScreenPrivatePtr pPriv;
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xScreenSaverQueryInfoReq);
|
2007-11-24 10:55:21 -07:00
|
|
|
rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0,
|
2012-06-10 07:21:05 -06:00
|
|
|
DixGetAttrAccess);
|
2008-11-02 08:26:08 -07:00
|
|
|
if (rc != Success)
|
2012-06-10 07:21:05 -06:00
|
|
|
return rc;
|
2008-11-02 08:26:08 -07:00
|
|
|
rc = XaceHook(XACE_SCREENSAVER_ACCESS, client, pDraw->pScreen,
|
2012-06-10 07:21:05 -06:00
|
|
|
DixGetAttrAccess);
|
2007-11-24 10:55:21 -07:00
|
|
|
if (rc != Success)
|
2012-06-10 07:21:05 -06:00
|
|
|
return rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
pSaver = &pDraw->pScreen->screensaver;
|
2012-06-10 07:21:05 -06:00
|
|
|
pPriv = GetScreenPrivate(pDraw->pScreen);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
UpdateCurrentTime();
|
2013-12-08 03:53:01 -07:00
|
|
|
lastInput = GetTimeInMillis() - LastEventTime(XIAllDevices).milliseconds;
|
2013-06-07 11:28:45 -06:00
|
|
|
|
|
|
|
rep = (xScreenSaverQueryInfoReply) {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = 0,
|
|
|
|
.window = pSaver->wid
|
|
|
|
};
|
2012-06-10 07:21:05 -06:00
|
|
|
if (screenIsSaved != SCREEN_SAVER_OFF) {
|
|
|
|
rep.state = ScreenSaverOn;
|
|
|
|
if (ScreenSaverTime)
|
|
|
|
rep.tilOrSince = lastInput - ScreenSaverTime;
|
|
|
|
else
|
|
|
|
rep.tilOrSince = 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else {
|
|
|
|
if (ScreenSaverTime) {
|
|
|
|
rep.state = ScreenSaverOff;
|
|
|
|
if (ScreenSaverTime < lastInput)
|
|
|
|
rep.tilOrSince = 0;
|
|
|
|
else
|
|
|
|
rep.tilOrSince = ScreenSaverTime - lastInput;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rep.state = ScreenSaverDisabled;
|
|
|
|
rep.tilOrSince = 0;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
rep.idle = lastInput;
|
2012-06-10 07:21:05 -06:00
|
|
|
rep.eventMask = getEventMask(pDraw->pScreen, client);
|
2006-11-26 11:13:41 -07:00
|
|
|
if (pPriv && pPriv->attr)
|
2012-06-10 07:21:05 -06:00
|
|
|
rep.kind = ScreenSaverExternal;
|
2006-11-26 11:13:41 -07:00
|
|
|
else if (ScreenSaverBlanking != DontPreferBlanking)
|
2012-06-10 07:21:05 -06:00
|
|
|
rep.kind = ScreenSaverBlanked;
|
2006-11-26 11:13:41 -07:00
|
|
|
else
|
2012-06-10 07:21:05 -06:00
|
|
|
rep.kind = ScreenSaverInternal;
|
|
|
|
if (client->swapped) {
|
|
|
|
swaps(&rep.sequenceNumber);
|
|
|
|
swapl(&rep.length);
|
|
|
|
swapl(&rep.window);
|
|
|
|
swapl(&rep.tilOrSince);
|
|
|
|
swapl(&rep.idle);
|
|
|
|
swapl(&rep.eventMask);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(client, sizeof(xScreenSaverQueryInfoReply), &rep);
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcScreenSaverSelectInput(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xScreenSaverSelectInputReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
DrawablePtr pDraw;
|
|
|
|
int rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
REQUEST_SIZE_MATCH(xScreenSaverSelectInputReq);
|
|
|
|
rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0,
|
|
|
|
DixGetAttrAccess);
|
2007-11-24 10:55:21 -07:00
|
|
|
if (rc != Success)
|
2012-06-10 07:21:05 -06:00
|
|
|
return rc;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
|
|
|
rc = XaceHook(XACE_SCREENSAVER_ACCESS, client, pDraw->pScreen,
|
2012-06-10 07:21:05 -06:00
|
|
|
DixSetAttrAccess);
|
2008-11-02 08:26:08 -07:00
|
|
|
if (rc != Success)
|
2012-06-10 07:21:05 -06:00
|
|
|
return rc;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!setEventMask(pDraw->pScreen, client, stuff->eventMask))
|
|
|
|
return BadAlloc;
|
2006-11-26 11:13:41 -07:00
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
ScreenSaverSetAttributes(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xScreenSaverSetAttributesReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
DrawablePtr pDraw;
|
|
|
|
WindowPtr pParent;
|
|
|
|
ScreenPtr pScreen;
|
2006-11-26 11:13:41 -07:00
|
|
|
ScreenSaverScreenPrivatePtr pPriv = 0;
|
2012-06-10 07:21:05 -06:00
|
|
|
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);
|
2007-11-24 10:55:21 -07:00
|
|
|
ret = dixLookupDrawable(&pDraw, stuff->drawable, client, 0,
|
2012-06-10 07:21:05 -06:00
|
|
|
DixGetAttrAccess);
|
2007-11-24 10:55:21 -07:00
|
|
|
if (ret != Success)
|
2012-06-10 07:21:05 -06:00
|
|
|
return ret;
|
2006-11-26 11:13:41 -07:00
|
|
|
pScreen = pDraw->pScreen;
|
2010-12-05 08:36:02 -07:00
|
|
|
pParent = pScreen->root;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
ret = XaceHook(XACE_SCREENSAVER_ACCESS, client, pScreen, DixSetAttrAccess);
|
|
|
|
if (ret != Success)
|
2012-06-10 07:21:05 -06:00
|
|
|
return ret;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
len = stuff->length - bytes_to_int32(sizeof(xScreenSaverSetAttributesReq));
|
2006-11-26 11:13:41 -07:00
|
|
|
if (Ones(stuff->mask) != len)
|
|
|
|
return BadLength;
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!stuff->width || !stuff->height) {
|
|
|
|
client->errorValue = 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
return BadValue;
|
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
switch (class = stuff->c_class) {
|
2006-11-26 11:13:41 -07:00
|
|
|
case CopyFromParent:
|
|
|
|
case InputOnly:
|
|
|
|
case InputOutput:
|
2012-06-10 07:21:05 -06:00
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
default:
|
2012-06-10 07:21:05 -06:00
|
|
|
client->errorValue = class;
|
|
|
|
return BadValue;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
bw = stuff->borderWidth;
|
|
|
|
depth = stuff->depth;
|
|
|
|
visual = stuff->visualID;
|
|
|
|
|
|
|
|
/* copied directly from CreateWindow */
|
|
|
|
|
|
|
|
if (class == CopyFromParent)
|
2012-06-10 07:21:05 -06:00
|
|
|
class = pParent->drawable.class;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((class != InputOutput) && (class != InputOnly)) {
|
|
|
|
client->errorValue = class;
|
|
|
|
return BadValue;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((class != InputOnly) && (pParent->drawable.class == InputOnly))
|
|
|
|
return BadMatch;
|
|
|
|
|
|
|
|
if ((class == InputOnly) && ((bw != 0) || (depth != 0)))
|
|
|
|
return BadMatch;
|
|
|
|
|
|
|
|
if ((class == InputOutput) && (depth == 0))
|
|
|
|
depth = pParent->drawable.depth;
|
|
|
|
ancwopt = pParent->optional;
|
|
|
|
if (!ancwopt)
|
2012-06-10 07:21:05 -06:00
|
|
|
ancwopt = FindWindowWithOptional(pParent)->optional;
|
2006-11-26 11:13:41 -07:00
|
|
|
if (visual == CopyFromParent)
|
2012-06-10 07:21:05 -06:00
|
|
|
visual = ancwopt->visual;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/* Find out if the depth and visual are acceptable for this Screen */
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((visual != ancwopt->visual) || (depth != pParent->drawable.depth)) {
|
|
|
|
fOK = FALSE;
|
|
|
|
for (idepth = 0; idepth < pScreen->numDepths; idepth++) {
|
2013-06-07 11:28:45 -06:00
|
|
|
pDepth = (DepthPtr) &pScreen->allowedDepths[idepth];
|
2012-06-10 07:21:05 -06:00
|
|
|
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;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (((stuff->mask & (CWBorderPixmap | CWBorderPixel)) == 0) &&
|
2012-06-10 07:21:05 -06:00
|
|
|
(class != InputOnly) && (depth != pParent->drawable.depth)) {
|
2006-11-26 11:13:41 -07:00
|
|
|
return BadMatch;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (((stuff->mask & CWColormap) == 0) &&
|
2012-06-10 07:21:05 -06:00
|
|
|
(class != InputOnly) &&
|
|
|
|
((visual != ancwopt->visual) || (ancwopt->colormap == None))) {
|
|
|
|
return BadMatch;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* end of errors from CreateWindow */
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
pPriv = GetScreenPrivate(pScreen);
|
|
|
|
if (pPriv && pPriv->attr) {
|
|
|
|
if (pPriv->attr->client != client)
|
|
|
|
return BadAccess;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!pPriv) {
|
|
|
|
pPriv = MakeScreenPrivate(pScreen);
|
|
|
|
if (!pPriv)
|
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
pAttr = New(ScreenSaverAttrRec);
|
|
|
|
if (!pAttr) {
|
|
|
|
ret = BadAlloc;
|
|
|
|
goto bail;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
/* over allocate for override redirect */
|
2012-06-10 07:21:05 -06:00
|
|
|
pAttr->values = values = malloc((len + 1) * sizeof(unsigned long));
|
|
|
|
if (!values) {
|
|
|
|
ret = BadAlloc;
|
|
|
|
goto bail;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
pAttr->screen = pScreen;
|
|
|
|
pAttr->client = client;
|
|
|
|
pAttr->x = stuff->x;
|
|
|
|
pAttr->y = stuff->y;
|
|
|
|
pAttr->width = stuff->width;
|
|
|
|
pAttr->height = stuff->height;
|
|
|
|
pAttr->borderWidth = stuff->borderWidth;
|
|
|
|
pAttr->class = stuff->c_class;
|
|
|
|
pAttr->depth = depth;
|
|
|
|
pAttr->visual = visual;
|
|
|
|
pAttr->colormap = None;
|
|
|
|
pAttr->pCursor = NullCursor;
|
|
|
|
pAttr->pBackgroundPixmap = NullPixmap;
|
|
|
|
pAttr->pBorderPixmap = NullPixmap;
|
|
|
|
/*
|
|
|
|
* go through the mask, checking the values,
|
|
|
|
* looking up pixmaps and cursors and hold a reference
|
|
|
|
* to them.
|
|
|
|
*/
|
|
|
|
pAttr->mask = tmask = stuff->mask | CWOverrideRedirect;
|
|
|
|
pVlist = (unsigned int *) (stuff + 1);
|
|
|
|
while (tmask) {
|
2012-06-10 07:21:05 -06:00
|
|
|
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 =
|
2014-09-27 11:52:59 -06:00
|
|
|
dixLookupResourceByType((void **) &pPixmap, pixID,
|
2012-06-10 07:21:05 -06:00
|
|
|
RT_PIXMAP, client, DixReadAccess);
|
|
|
|
if (ret == Success) {
|
|
|
|
if ((pPixmap->drawable.depth != depth) ||
|
|
|
|
(pPixmap->drawable.pScreen != pScreen)) {
|
2006-11-26 11:13:41 -07:00
|
|
|
ret = BadMatch;
|
2012-06-10 07:21:05 -06:00
|
|
|
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 =
|
2014-09-27 11:52:59 -06:00
|
|
|
dixLookupResourceByType((void **) &pPixmap, pixID,
|
2012-06-10 07:21:05 -06:00
|
|
|
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:
|
|
|
|
*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:
|
2006-11-26 11:13:41 -07:00
|
|
|
*values++ = (CARD32) *pVlist;
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
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;
|
2014-09-27 11:52:59 -06:00
|
|
|
ret = dixLookupResourceByType((void **) &pCmap, cmap, RT_COLORMAP,
|
2012-06-10 07:21:05 -06:00
|
|
|
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 {
|
2014-09-27 11:52:59 -06:00
|
|
|
ret = dixLookupResourceByType((void **) &pCursor, cursorID,
|
2012-06-10 07:21:05 -06:00
|
|
|
RT_CURSOR, client, DixUseAccess);
|
|
|
|
if (ret != Success) {
|
|
|
|
client->errorValue = cursorID;
|
|
|
|
goto PatchUp;
|
|
|
|
}
|
2013-09-28 09:36:30 -06:00
|
|
|
pAttr->pCursor = RefCursor(pCursor);
|
2012-06-10 07:21:05 -06:00
|
|
|
pAttr->mask &= ~CWCursor;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ret = BadValue;
|
|
|
|
client->errorValue = stuff->mask;
|
|
|
|
goto PatchUp;
|
|
|
|
}
|
|
|
|
pVlist++;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
if (pPriv->attr)
|
2012-06-10 07:21:05 -06:00
|
|
|
FreeScreenAttr(pPriv->attr);
|
2006-11-26 11:13:41 -07:00
|
|
|
pPriv->attr = pAttr;
|
2012-06-10 07:21:05 -06:00
|
|
|
pAttr->resource = FakeClientID(client->index);
|
2014-09-27 11:52:59 -06:00
|
|
|
if (!AddResource(pAttr->resource, AttrType, (void *) pAttr))
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadAlloc;
|
2006-11-26 11:13:41 -07:00
|
|
|
return Success;
|
2012-06-10 07:21:05 -06:00
|
|
|
PatchUp:
|
|
|
|
FreeAttrs(pAttr);
|
|
|
|
bail:
|
|
|
|
CheckScreenPrivate(pScreen);
|
|
|
|
if (pAttr)
|
|
|
|
free(pAttr->values);
|
2010-12-05 08:36:02 -07:00
|
|
|
free(pAttr);
|
2006-11-26 11:13:41 -07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
ScreenSaverUnsetAttributes(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xScreenSaverSetAttributesReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
DrawablePtr pDraw;
|
|
|
|
ScreenSaverScreenPrivatePtr pPriv;
|
|
|
|
int rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
REQUEST_SIZE_MATCH(xScreenSaverUnsetAttributesReq);
|
2007-11-24 10:55:21 -07:00
|
|
|
rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0,
|
2012-06-10 07:21:05 -06:00
|
|
|
DixGetAttrAccess);
|
2007-11-24 10:55:21 -07:00
|
|
|
if (rc != Success)
|
2012-06-10 07:21:05 -06:00
|
|
|
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);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcScreenSaverSetAttributes(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
#ifdef PANORAMIX
|
2012-06-10 07:21:05 -06:00
|
|
|
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);
|
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
status = dixLookupResourceByClass((void **) &draw, stuff->drawable,
|
2012-06-10 07:21:05 -06:00
|
|
|
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)) {
|
2014-09-27 11:52:59 -06:00
|
|
|
status = dixLookupResourceByType((void **) &backPix, tmp,
|
2012-06-10 07:21:05 -06:00
|
|
|
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) {
|
2014-09-27 11:52:59 -06:00
|
|
|
status = dixLookupResourceByType((void **) &bordPix, tmp,
|
2012-06-10 07:21:05 -06:00
|
|
|
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)) {
|
2014-09-27 11:52:59 -06:00
|
|
|
status = dixLookupResourceByType((void **) &cmap, tmp,
|
2012-06-10 07:21:05 -06:00
|
|
|
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;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return ScreenSaverSetAttributes(client);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcScreenSaverUnsetAttributes(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
#ifdef PANORAMIX
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!noPanoramiXExtension) {
|
|
|
|
REQUEST(xScreenSaverUnsetAttributesReq);
|
|
|
|
PanoramiXRes *draw;
|
|
|
|
int rc, i;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
rc = dixLookupResourceByClass((void **) &draw, stuff->drawable,
|
2012-06-10 07:21:05 -06:00
|
|
|
XRC_DRAWABLE, client, DixWriteAccess);
|
|
|
|
if (rc != Success)
|
|
|
|
return (rc == BadValue) ? BadDrawable : rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = PanoramiXNumScreens - 1; i > 0; i--) {
|
2006-11-26 11:13:41 -07:00
|
|
|
stuff->drawable = draw->info[i].id;
|
|
|
|
ScreenSaverUnsetAttributes(client);
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
stuff->drawable = draw->info[0].id;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return ScreenSaverUnsetAttributes(client);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcScreenSaverSuspend(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
ScreenSaverSuspensionPtr *prev, this;
|
|
|
|
|
|
|
|
REQUEST(xScreenSaverSuspendReq);
|
|
|
|
REQUEST_SIZE_MATCH(xScreenSaverSuspendReq);
|
|
|
|
|
|
|
|
/* Check if this client is suspending the screensaver */
|
|
|
|
for (prev = &suspendingClients; (this = *prev); prev = &this->next)
|
2012-06-10 07:21:05 -06:00
|
|
|
if (this->pClient == client)
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (this) {
|
|
|
|
if (stuff->suspend == TRUE)
|
|
|
|
this->count++;
|
|
|
|
else if (--this->count == 0)
|
|
|
|
FreeResource(this->clientResource, RT_NONE);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* If we get to this point, this client isn't suspending the screensaver */
|
|
|
|
if (stuff->suspend == FALSE)
|
2012-06-10 07:21:05 -06:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocate a suspension record for the client, and stop the screensaver
|
|
|
|
* if it isn't already suspended by another client. We attach a resource ID
|
|
|
|
* to the record, so the screensaver will be reenabled and the record freed
|
|
|
|
* if the client disconnects without reenabling it first.
|
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
this = malloc(sizeof(ScreenSaverSuspensionRec));
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (!this)
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadAlloc;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
this->next = NULL;
|
|
|
|
this->pClient = client;
|
|
|
|
this->count = 1;
|
|
|
|
this->clientResource = FakeClientID(client->index);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
if (!AddResource(this->clientResource, SuspendType, (void *) this)) {
|
2012-06-10 07:21:05 -06:00
|
|
|
free(this);
|
|
|
|
return BadAlloc;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
*prev = this;
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!screenSaverSuspended) {
|
|
|
|
screenSaverSuspended = TRUE;
|
|
|
|
FreeScreenSaverTimer();
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static int (*NormalVector[]) (ClientPtr /* client */ ) = {
|
|
|
|
ProcScreenSaverQueryVersion,
|
|
|
|
ProcScreenSaverQueryInfo,
|
|
|
|
ProcScreenSaverSelectInput,
|
|
|
|
ProcScreenSaverSetAttributes,
|
|
|
|
ProcScreenSaverUnsetAttributes, ProcScreenSaverSuspend,};
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
#define NUM_REQUESTS ((sizeof NormalVector) / (sizeof NormalVector[0]))
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcScreenSaverDispatch(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xReq);
|
|
|
|
|
|
|
|
if (stuff->data < NUM_REQUESTS)
|
2012-06-10 07:21:05 -06:00
|
|
|
return (*NormalVector[stuff->data]) (client);
|
2006-11-26 11:13:41 -07:00
|
|
|
return BadRequest;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
SProcScreenSaverQueryVersion(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xScreenSaverQueryVersionReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->length);
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST_SIZE_MATCH(xScreenSaverQueryVersionReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
return ProcScreenSaverQueryVersion(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
SProcScreenSaverQueryInfo(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xScreenSaverQueryInfoReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->length);
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST_SIZE_MATCH(xScreenSaverQueryInfoReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swapl(&stuff->drawable);
|
|
|
|
return ProcScreenSaverQueryInfo(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
SProcScreenSaverSelectInput(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xScreenSaverSelectInputReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->length);
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST_SIZE_MATCH(xScreenSaverSelectInputReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swapl(&stuff->drawable);
|
|
|
|
swapl(&stuff->eventMask);
|
|
|
|
return ProcScreenSaverSelectInput(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
SProcScreenSaverSetAttributes(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xScreenSaverSetAttributesReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->length);
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST_AT_LEAST_SIZE(xScreenSaverSetAttributesReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swapl(&stuff->drawable);
|
|
|
|
swaps(&stuff->x);
|
|
|
|
swaps(&stuff->y);
|
|
|
|
swaps(&stuff->width);
|
|
|
|
swaps(&stuff->height);
|
|
|
|
swaps(&stuff->borderWidth);
|
|
|
|
swapl(&stuff->visualID);
|
|
|
|
swapl(&stuff->mask);
|
2006-11-26 11:13:41 -07:00
|
|
|
SwapRestL(stuff);
|
2012-06-10 07:21:05 -06:00
|
|
|
return ProcScreenSaverSetAttributes(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
SProcScreenSaverUnsetAttributes(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xScreenSaverUnsetAttributesReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->length);
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST_SIZE_MATCH(xScreenSaverUnsetAttributesReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swapl(&stuff->drawable);
|
|
|
|
return ProcScreenSaverUnsetAttributes(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
SProcScreenSaverSuspend(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xScreenSaverSuspendReq);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->length);
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST_SIZE_MATCH(xScreenSaverSuspendReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
return ProcScreenSaverSuspend(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static int (*SwappedVector[]) (ClientPtr /* client */ ) = {
|
|
|
|
SProcScreenSaverQueryVersion,
|
|
|
|
SProcScreenSaverQueryInfo,
|
|
|
|
SProcScreenSaverSelectInput,
|
|
|
|
SProcScreenSaverSetAttributes,
|
|
|
|
SProcScreenSaverUnsetAttributes, SProcScreenSaverSuspend,};
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
SProcScreenSaverDispatch(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xReq);
|
|
|
|
|
|
|
|
if (stuff->data < NUM_REQUESTS)
|
2012-06-10 07:21:05 -06:00
|
|
|
return (*SwappedVector[stuff->data]) (client);
|
2006-11-26 11:13:41 -07:00
|
|
|
return BadRequest;
|
|
|
|
}
|
2011-11-05 07:32:40 -06:00
|
|
|
|
|
|
|
void
|
2013-06-07 11:28:45 -06:00
|
|
|
ScreenSaverExtensionInit(void)
|
2011-11-05 07:32:40 -06:00
|
|
|
{
|
|
|
|
ExtensionEntry *extEntry;
|
2012-06-10 07:21:05 -06:00
|
|
|
int i;
|
|
|
|
ScreenPtr pScreen;
|
2011-11-05 07:32:40 -06:00
|
|
|
|
|
|
|
if (!dixRegisterPrivateKey(&ScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2011-11-05 07:32:40 -06:00
|
|
|
|
|
|
|
AttrType = CreateNewResourceType(ScreenSaverFreeAttr, "SaverAttr");
|
2012-06-10 07:21:05 -06:00
|
|
|
SaverEventType = CreateNewResourceType(ScreenSaverFreeEvents, "SaverEvent");
|
|
|
|
SuspendType = CreateNewResourceType(ScreenSaverFreeSuspend, "SaverSuspend");
|
|
|
|
|
|
|
|
for (i = 0; i < screenInfo.numScreens; i++) {
|
|
|
|
pScreen = screenInfo.screens[i];
|
|
|
|
SetScreenPrivate(pScreen, NULL);
|
2011-11-05 07:32:40 -06:00
|
|
|
}
|
|
|
|
if (AttrType && SaverEventType && SuspendType &&
|
2012-06-10 07:21:05 -06:00
|
|
|
(extEntry = AddExtension(ScreenSaverName, ScreenSaverNumberEvents, 0,
|
|
|
|
ProcScreenSaverDispatch,
|
|
|
|
SProcScreenSaverDispatch, NULL,
|
|
|
|
StandardMinorOpcode))) {
|
|
|
|
ScreenSaverEventBase = extEntry->eventBase;
|
|
|
|
EventSwapVector[ScreenSaverEventBase] =
|
|
|
|
(EventSwapPtr) SScreenSaverNotifyEvent;
|
2011-11-05 07:32:40 -06:00
|
|
|
}
|
|
|
|
}
|