aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/programs
diff options
context:
space:
mode:
Diffstat (limited to 'nx-X11/programs')
-rw-r--r--nx-X11/programs/Xserver/Xext/saver.c149
-rw-r--r--nx-X11/programs/Xserver/dix/Imakefile2
-rw-r--r--nx-X11/programs/Xserver/dix/globals.c4
-rw-r--r--nx-X11/programs/Xserver/include/globals.h4
4 files changed, 156 insertions, 3 deletions
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;