[X2Go-Commits] [nx-libs] 01/09: Xext: lift screensaver extension to XORG-7_1 state

git-admin at x2go.org git-admin at x2go.org
Thu Feb 8 21:49:14 CET 2018


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch 3.6.x
in repository nx-libs.

commit 4ab18725cd088cbb401ef63e93ef41d8d7c78b2a
Author: Ulrich Sibiller <uli42 at gmx.de>
Date:   Sat Oct 21 01:47:40 2017 +0200

    Xext: lift screensaver extension to XORG-7_1 state
---
 nx-X11/include/extensions/saver.h         |   4 +-
 nx-X11/include/extensions/saverproto.h    |  13 ++-
 nx-X11/programs/Xserver/Xext/saver.c      | 149 +++++++++++++++++++++++++++++-
 nx-X11/programs/Xserver/dix/Imakefile     |   2 +-
 nx-X11/programs/Xserver/dix/globals.c     |   4 +
 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 ea35454..e8da625 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 17f740f..43b168b 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 066dffe..0b79a00 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 1024de9..ccdae3b 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 f9fa544..6f4774a 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 1c4d73e..c43035c 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;

--
Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/nx-libs.git


More information about the x2go-commits mailing list