diff options
author | Ulrich Sibiller <uli42@gmx.de> | 2017-10-21 01:47:40 +0200 |
---|---|---|
committer | Mihai Moldovan <ionic@ionic.de> | 2018-02-07 23:15:57 +0100 |
commit | 4ab18725cd088cbb401ef63e93ef41d8d7c78b2a (patch) | |
tree | d55148c500dde99d2f178e23466af8d18d72e4ee /nx-X11 | |
parent | cbdae3b71bfc654cfc0c81b1ddf51975bcb93146 (diff) | |
download | nx-libs-4ab18725cd088cbb401ef63e93ef41d8d7c78b2a.tar.gz nx-libs-4ab18725cd088cbb401ef63e93ef41d8d7c78b2a.tar.bz2 nx-libs-4ab18725cd088cbb401ef63e93ef41d8d7c78b2a.zip |
Xext: lift screensaver extension to XORG-7_1 state
Diffstat (limited to 'nx-X11')
-rw-r--r-- | nx-X11/include/extensions/saver.h | 4 | ||||
-rw-r--r-- | nx-X11/include/extensions/saverproto.h | 13 | ||||
-rw-r--r-- | nx-X11/programs/Xserver/Xext/saver.c | 149 | ||||
-rw-r--r-- | nx-X11/programs/Xserver/dix/Imakefile | 2 | ||||
-rw-r--r-- | nx-X11/programs/Xserver/dix/globals.c | 4 | ||||
-rw-r--r-- | nx-X11/programs/Xserver/include/globals.h | 4 |
6 files changed, 167 insertions, 9 deletions
diff --git a/nx-X11/include/extensions/saver.h b/nx-X11/include/extensions/saver.h index ea35454b7..e8da62560 100644 --- a/nx-X11/include/extensions/saver.h +++ b/nx-X11/include/extensions/saver.h @@ -1,6 +1,4 @@ /* - * $XConsortium: saver.h,v 1.5 94/04/17 20:59:33 rws Exp $ - * Copyright (c) 1992 X Consortium Permission is hereby granted, free of charge, to any person obtaining a copy @@ -37,7 +35,7 @@ in this Software without prior written authorization from the X Consortium. #define ScreenSaverCycleMask 0x00000002 #define ScreenSaverMajorVersion 1 -#define ScreenSaverMinorVersion 0 +#define ScreenSaverMinorVersion 1 #define ScreenSaverOff 0 #define ScreenSaverOn 1 diff --git a/nx-X11/include/extensions/saverproto.h b/nx-X11/include/extensions/saverproto.h index 17f740f4d..43b168b7f 100644 --- a/nx-X11/include/extensions/saverproto.h +++ b/nx-X11/include/extensions/saverproto.h @@ -1,6 +1,4 @@ /* - * $XConsortium: saverproto.h,v 1.5 94/04/17 20:59:33 keith Exp $ - * Copyright (c) 1992 X Consortium Permission is hereby granted, free of charge, to any person obtaining a copy @@ -26,7 +24,6 @@ in this Software without prior written authorization from the X Consortium. * * Author: Keith Packard, MIT X Consortium */ -/* $XFree86$ */ #ifndef _SAVERPROTO_H_ #define _SAVERPROTO_H_ @@ -136,6 +133,16 @@ typedef struct _ScreenSaverUnsetAttributes { } xScreenSaverUnsetAttributesReq; #define sz_xScreenSaverUnsetAttributesReq 8 +#define X_ScreenSaverSuspend 5 + +typedef struct _ScreenSaverSuspend { + CARD8 reqType; + CARD8 saverReqType; + CARD16 length B16; + Bool suspend B32; +} xScreenSaverSuspendReq; +#define sz_xScreenSaverSuspendReq 8 + typedef struct _ScreenSaverNotify { CARD8 type; /* always eventBase + ScreenSaverNotify */ BYTE state; /* off, on, cycle */ diff --git a/nx-X11/programs/Xserver/Xext/saver.c b/nx-X11/programs/Xserver/Xext/saver.c index 066dffed0..0b79a002b 100644 --- a/nx-X11/programs/Xserver/Xext/saver.c +++ b/nx-X11/programs/Xserver/Xext/saver.c @@ -51,7 +51,10 @@ in this Software without prior written authorization from the X Consortium. #include "panoramiX.h" #include "panoramiXsrv.h" #endif - +#ifdef DPMSExtension +#define DPMS_SERVER +#include <nx-X11/extensions/dpms.h> +#endif #include <stdio.h> @@ -68,12 +71,14 @@ static DISPATCH_PROC(ProcScreenSaverQueryVersion); static DISPATCH_PROC(ProcScreenSaverSelectInput); static DISPATCH_PROC(ProcScreenSaverSetAttributes); static DISPATCH_PROC(ProcScreenSaverUnsetAttributes); +static DISPATCH_PROC(ProcScreenSaverSuspend); static DISPATCH_PROC(SProcScreenSaverDispatch); static DISPATCH_PROC(SProcScreenSaverQueryInfo); static DISPATCH_PROC(SProcScreenSaverQueryVersion); static DISPATCH_PROC(SProcScreenSaverSelectInput); static DISPATCH_PROC(SProcScreenSaverSetAttributes); static DISPATCH_PROC(SProcScreenSaverUnsetAttributes); +static DISPATCH_PROC(SProcScreenSaverSuspend); static Bool ScreenSaverHandle ( ScreenPtr /* pScreen */, @@ -110,6 +115,32 @@ static void ScreenSaverResetProc ( ExtensionEntry * /* extEntry */ ); +static RESTYPE SuspendType; /* resource type for suspension records */ + +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. + */ +typedef struct _ScreenSaverSuspension +{ + ScreenSaverSuspensionPtr next; + ClientPtr pClient; + XID clientResource; + int count; +} ScreenSaverSuspensionRec; + +static int ScreenSaverFreeSuspend( + pointer /*value */, + XID /* id */ +); + /* * each screen has a list of clients requesting * ScreenSaverNotify events. Each client has a resource @@ -227,13 +258,15 @@ ScreenSaverExtensionInit(void) AttrType = CreateNewResourceType(ScreenSaverFreeAttr); EventType = CreateNewResourceType(ScreenSaverFreeEvents); + SuspendType = CreateNewResourceType(ScreenSaverFreeSuspend); ScreenPrivateIndex = AllocateScreenPrivateIndex (); + for (i = 0; i < screenInfo.numScreens; i++) { pScreen = screenInfo.screens[i]; SetScreenPrivate (pScreen, NULL); } - if (AttrType && EventType && ScreenPrivateIndex != -1 && + if (AttrType && EventType && SuspendType && ScreenPrivateIndex != -1 && (extEntry = AddExtension(ScreenSaverName, ScreenSaverNumberEvents, 0, ProcScreenSaverDispatch, SProcScreenSaverDispatch, ScreenSaverResetProc, StandardMinorOpcode))) @@ -427,6 +460,45 @@ ScreenSaverFreeAttr (value, id) return TRUE; } +static int +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; + } + } + + /* Reenable the screensaver if this was the last client suspending it. */ + if (screenSaverSuspended && suspendingClients == NULL) + { + screenSaverSuspended = FALSE; + + /* 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) +#else + if (screenIsSaved != SCREEN_SAVER_ON) +#endif + { + UpdateCurrentTimeIf(); + lastDeviceEventTime = currentTime; + SetScreenSaverTimer(); + } + } + + return Success; +} + static void SendScreenSaverNotify (pScreen, state, forced) ScreenPtr pScreen; @@ -1286,12 +1358,73 @@ ProcScreenSaverUnsetAttributes (ClientPtr client) return ScreenSaverUnsetAttributes(client); } +static int +ProcScreenSaverSuspend (ClientPtr client) +{ + 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) + if (this->pClient == client) + break; + + if (this) + { + if (stuff->suspend == TRUE) + this->count++; + else if (--this->count == 0) + FreeResource (this->clientResource, RT_NONE); + + return Success; + } + + /* If we get to this point, this client isn't suspending the screensaver */ + if (stuff->suspend == FALSE) + return Success; + + /* + * 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. + */ + this = (ScreenSaverSuspensionPtr) malloc (sizeof (ScreenSaverSuspensionRec)); + + if (!this) + return BadAlloc; + + memset(this, 0, sizeof (ScreenSaverSuspensionRec)); + 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; + } + + *prev = this; + if (!screenSaverSuspended) + { + screenSaverSuspended = TRUE; + FreeScreenSaverTimer(); + } + + return (client->noClientException); +} + static DISPATCH_PROC((*NormalVector[])) = { ProcScreenSaverQueryVersion, ProcScreenSaverQueryInfo, ProcScreenSaverSelectInput, ProcScreenSaverSetAttributes, ProcScreenSaverUnsetAttributes, + ProcScreenSaverSuspend, }; #define NUM_REQUESTS ((sizeof NormalVector) / (sizeof NormalVector[0])) @@ -1375,12 +1508,24 @@ SProcScreenSaverUnsetAttributes (client) return ProcScreenSaverUnsetAttributes (client); } +static int +SProcScreenSaverSuspend (ClientPtr client) +{ + REQUEST(xScreenSaverSuspendReq); + + swaps(&stuff->length); + REQUEST_SIZE_MATCH(xScreenSaverSuspendReq); + swapl(&stuff->suspend); + return ProcScreenSaverSuspend (client); +} + static DISPATCH_PROC((*SwappedVector[])) = { SProcScreenSaverQueryVersion, SProcScreenSaverQueryInfo, SProcScreenSaverSelectInput, SProcScreenSaverSetAttributes, SProcScreenSaverUnsetAttributes, + SProcScreenSaverSuspend, }; static int diff --git a/nx-X11/programs/Xserver/dix/Imakefile b/nx-X11/programs/Xserver/dix/Imakefile index 1024de965..ccdae3b82 100644 --- a/nx-X11/programs/Xserver/dix/Imakefile +++ b/nx-X11/programs/Xserver/dix/Imakefile @@ -132,7 +132,7 @@ NormalLibraryTarget(dix,$(OBJS)) LintLibraryTarget(dix,$(SRCS) $(XPSRC)) NormalLintTarget($(SRCS) $(XPSRC)) -SpecialCObjectRule(globals,$(ICONFIGFILES),$(SITE_DEFINES)) +SpecialCObjectRule(globals,$(ICONFIGFILES),$(SITE_DEFINES) $(EXT_DEFINES)) SpecialCObjectRule(main,$(ICONFIGFILES),$(VENDOR_DEFINES)) SpecialCObjectRule(pixmap,$(ICONFIGFILES),$(_NOOP_)) SpecialCObjectRule(privates,$(ICONFIGFILES),$(_NOOP_)) diff --git a/nx-X11/programs/Xserver/dix/globals.c b/nx-X11/programs/Xserver/dix/globals.c index f9fa544ed..6f4774a5c 100644 --- a/nx-X11/programs/Xserver/dix/globals.c +++ b/nx-X11/programs/Xserver/dix/globals.c @@ -127,6 +127,10 @@ int defaultScreenSaverAllowExposures = DEFAULT_SCREEN_SAVER_EXPOSURES; int logoScreenSaver = DEFAULT_LOGO_SCREEN_SAVER; #endif +#ifdef SCREENSAVER +Bool screenSaverSuspended = FALSE; +#endif + char *defaultFontPath = COMPILEDDEFAULTFONTPATH; char *defaultTextFont = COMPILEDDEFAULTFONT; char *defaultCursorFont = COMPILEDCURSORFONT; diff --git a/nx-X11/programs/Xserver/include/globals.h b/nx-X11/programs/Xserver/include/globals.h index 1c4d73e64..c43035cf0 100644 --- a/nx-X11/programs/Xserver/include/globals.h +++ b/nx-X11/programs/Xserver/include/globals.h @@ -11,6 +11,10 @@ extern CARD32 defaultScreenSaverInterval; extern CARD32 ScreenSaverTime; extern CARD32 ScreenSaverInterval; +#ifdef SCREENSAVER +extern Bool screenSaverSuspended; +#endif + extern char *defaultFontPath; extern int monitorResolution; extern Bool loadableFonts; |