changeset 4139:568c9b3c0167 SDL-1.2

* Added configure option --enable-screensaver, to allow enabling the screensaver by default. * Use XResetScreenSaver() instead of disabling screensaver entirely. Full discussion summary from Erik on the SDL mailing list: Current behaviour ================= SDL changes the user's display power management settings without permission from the user and without telling the user. The interface that it uses to do so is DPMSDisable/DPMSEnable, which should only ever be used by configuration utilities like KControl, never by normal application programs, let alone by the libraries that they use. Using an interface that is not at all intended for what SDL tries to achieve means that it will not work as it should. Firstly, the power management is completely disabled during the whole lifetime of the SDL program, not only when it should be. Secondly, it makes SDL non-reentrant, meaning that things will break when multiple SDL programs are clients of the same X server simultaneously. Thirdly, no cleanup mechanism ensures that the setting is restored if the client does not do that (for example if it crashes). In addition to that, this interface is broken on xorg, [http://bugs.freedesktop.org/show_bug.cgi?id=13962], so what SDL tries to do does not work at all on that implementation of the X Window System. (The reason that the DPMSEnable works in KControl is that it calls DPMSSetTimeout immediately after, [http://websvn.kde.org/tags/KDE/3.5.9/kdebase/kcontrol/energy/energy.cpp?annotate=774532#l343]). The problems that the current behaviour causes ============================================== 1. Information leak. When the user is away, someone might see what the user has on the display when the user counts on the screensaver preventing this. This does not even require physical access to the workstation, it is enough to see it from a distance. 2. Draining battery. An SDL program that runs on a laptop will quickly drain the battery while the user is away. The system will soon shut down and require recharging before being usable again, while it should in fact have consumed very little energy if the user's settings would have been obeyed. 3. Wasting energy. Even if battery issues are not considered, energy as such is wasted. 4. Display wear. The display may be worn out. The problems that the current behaviour tries to solve ====================================================== 1. Preventing screensaver while playing movies. Many SDL applications are media players. They have reasons to prevent screensavers from being activated while a movie is being played. When a user clicks on the play button it can be interpreted as saying "play this movie, but do not turn off the display while playing it, because I will watch it even though I do not interact with the system". 2. Preventing screensaver when some input bypasses X. Sometimes SDL uses input from another source than the X server, so that the X server is bypassed. This obviously breaks the screensaver handling. SDL tries to work around that. 3. Preventing screensaver when all input bypasses X. There is something called Direct Graphics Access mode, where a program takes control of both the display and the input devices from the X server. This obviously means that the X server can not handle the screensaver alone, since screensaver handling depends on input handling. SDL does not do what it should to help the X server to handle the screensaver. Nor does SDL take care of screeensaver handling itself. SDL simply disables the screensaver completely. How the problems should be solved ================================= The correct way for an application program to prevent the screensaver under X is to call XResetScreenSaver. This was recently discovered and implemented by the mplayer developers, [http://svn.mplayerhq.hu/mplayer?view=rev&revision=25637]. SDL needs to wrap this in an API call (SDL_ResetScreenSaver) and implement it for the other video targets (if they do not have a corresponding call, SDL should do what it takes on that particular target, for example sending fake key events). 1. When a movie is played, the player should reset the screensaver when the animation is advanced to a new frame. The same applies to anything similar, like slideshows. 2. When the X server is handling input, it must handle all input (keyboards, mice, gamepads, ...). This is necessary, not only to be able to handle the screensaver, but also so that it can send the events to the correct (the currently active) client. If there is an input device that the X server can not handle for some reason (such as lack of Plug and Play capability), the program that handles the device as a workaround must simulate what would happen if the X server would have handled the device, by calling XResetScreenSaver when input is received from the device. 3. When the X server is not handling the input, it depends on the program that does to call XResetScreenSaver whenever an input event occurs. Alternatively the program must handle the screensaver countdown internally and call XActivateScreenSaver.
author Sam Lantinga <slouken@libsdl.org>
date Fri, 29 Feb 2008 13:55:44 +0000
parents b1fd24d62e55
children fc69b552ee32
files configure.in docs.html include/SDL_config.h.in include/SDL_config_macosx.h include/SDL_config_win32.h src/video/dga/SDL_dgaevents.c src/video/dga/SDL_dgavideo.c src/video/dga/SDL_dgavideo.h src/video/quartz/SDL_QuartzEvents.m src/video/quartz/SDL_QuartzVideo.m src/video/windib/SDL_dibevents.c src/video/windib/SDL_dibvideo.c src/video/windib/SDL_dibvideo.h src/video/x11/SDL_x11events.c src/video/x11/SDL_x11events_c.h src/video/x11/SDL_x11sym.h src/video/x11/SDL_x11video.c src/video/x11/SDL_x11video.h src/video/xbios/SDL_xbios_centscreen.c
diffstat 19 files changed, 134 insertions(+), 138 deletions(-) [+]
line wrap: on
line diff
--- a/configure.in	Tue Feb 26 10:50:28 2008 +0000
+++ b/configure.in	Fri Feb 29 13:55:44 2008 +0000
@@ -1090,19 +1090,6 @@
             if test x$definitely_enable_video_x11_xrandr = xyes; then
                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XRANDR)
             fi
-            AC_ARG_ENABLE(video-x11-dpms,
-AC_HELP_STRING([--enable-video-x11-dpms], [enable X11 DPMS extension [[default=yes]]]),
-                            , enable_video_x11_dpms=yes)
-            if test x$enable_video_x11_dpms = xyes; then
-                AC_CHECK_HEADER(X11/extensions/dpms.h,
-                                have_dpms_h_hdr=yes,
-                                have_dpms_h_hdr=no,
-                                [#include <X11/Xlib.h>
-                                ])
-                if test x$have_dpms_h_hdr = xyes; then
-                    AC_DEFINE(SDL_VIDEO_DRIVER_X11_DPMS)
-                fi
-            fi
         fi
     fi
 }
@@ -1673,6 +1660,13 @@
     fi
 }
 
+AC_ARG_ENABLE(screensaver,
+AC_HELP_STRING([--enable-screensaver], [enable screensaver by default while any SDL application is running [[default=no]]]),
+              , enable_screensaver=no)
+if test x$enable_screensaver = xno; then
+    AC_DEFINE(SDL_VIDEO_DISABLE_SCREENSAVER)
+fi
+
 dnl See if we can use the new unified event interface in Linux 2.4
 CheckInputEvents()
 {
--- a/docs.html	Tue Feb 26 10:50:28 2008 +0000
+++ b/docs.html	Fri Feb 29 13:55:44 2008 +0000
@@ -14,6 +14,45 @@
 
 <H2> <A HREF="docs/index.html">API Documentation</A> </H2>
 
+<H2> SDL 1.2.14 Release Notes </H2>
+<P>
+SDL 1.2.14 is a minor bug fix release.
+</P>
+
+<H3> General Notes </H3>
+
+<BLOCKQUOTE>
+<P>
+</P>
+</BLOCKQUOTE>
+
+<H3> Unix Notes </H3>
+
+<BLOCKQUOTE>
+<P>
+	Added configure option --enable-screensaver, to allow enabling the screensaver by default.
+</P>
+<P>
+	Use XResetScreenSaver() instead of disabling screensaver entirely.
+</P>
+</BLOCKQUOTE>
+
+<H3> Windows Notes </H3>
+
+<BLOCKQUOTE>
+<P>
+</P>
+</BLOCKQUOTE>
+
+<H3> Mac OS X Notes </H3>
+
+<BLOCKQUOTE>
+<P>
+</P>
+</BLOCKQUOTE>
+
+<IMG SRC="docs/images/rainbow.gif" ALT="[separator]" WIDTH="100%">
+
 <H2> SDL 1.2.13 Release Notes </H2>
 <P>
 SDL 1.2.13 is a minor bug fix release.
--- a/include/SDL_config.h.in	Tue Feb 26 10:50:28 2008 +0000
+++ b/include/SDL_config.h.in	Fri Feb 29 13:55:44 2008 +0000
@@ -279,7 +279,6 @@
 #undef SDL_VIDEO_DRIVER_WSCONS
 #undef SDL_VIDEO_DRIVER_X11
 #undef SDL_VIDEO_DRIVER_X11_DGAMOUSE
-#undef SDL_VIDEO_DRIVER_X11_DPMS
 #undef SDL_VIDEO_DRIVER_X11_DYNAMIC
 #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT
 #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR
@@ -298,6 +297,9 @@
 #undef SDL_VIDEO_OPENGL_OSMESA
 #undef SDL_VIDEO_OPENGL_OSMESA_DYNAMIC
 
+/* Disable screensaver */
+#undef SDL_VIDEO_DISABLE_SCREENSAVER
+
 /* Enable assembly routines */
 #undef SDL_ASSEMBLY_ROUTINES
 #undef SDL_HERMES_BLITTERS
--- a/include/SDL_config_macosx.h	Tue Feb 26 10:50:28 2008 +0000
+++ b/include/SDL_config_macosx.h	Fri Feb 29 13:55:44 2008 +0000
@@ -126,6 +126,9 @@
 /* Enable OpenGL support */
 #define SDL_VIDEO_OPENGL	1
 
+/* Disable screensaver */
+#define SDL_VIDEO_DISABLE_SCREENSAVER	1
+
 /* Enable assembly routines */
 #define SDL_ASSEMBLY_ROUTINES	1
 #ifdef __ppc__
--- a/include/SDL_config_win32.h	Tue Feb 26 10:50:28 2008 +0000
+++ b/include/SDL_config_win32.h	Fri Feb 29 13:55:44 2008 +0000
@@ -172,6 +172,9 @@
 #define SDL_VIDEO_OPENGL_WGL	1
 #endif
 
+/* Disable screensaver */
+#define SDL_VIDEO_DISABLE_SCREENSAVER	1
+
 /* Enable assembly routines (Win64 doesn't have inline asm) */
 #ifndef _WIN64
 #define SDL_ASSEMBLY_ROUTINES	1
--- a/src/video/dga/SDL_dgaevents.c	Tue Feb 26 10:50:28 2008 +0000
+++ b/src/video/dga/SDL_dgaevents.c	Fri Feb 29 13:55:44 2008 +0000
@@ -137,9 +137,21 @@
 {
 	/* Keep processing pending events */
 	LOCK_DISPLAY();
+
+	/* Update activity every five seconds to prevent screensaver. --ryan. */
+	if (!allow_screensaver) {
+		static Uint32 screensaverTicks;
+		Uint32 nowTicks = SDL_GetTicks();
+		if ((nowTicks - screensaverTicks) > 5000) {
+			XResetScreenSaver(DGA_Display);
+			screensaverTicks = nowTicks;
+		}
+	}
+
 	while ( X11_Pending(DGA_Display) ) {
 		DGA_DispatchEvent(this);
 	}
+
 	UNLOCK_DISPLAY();
 }
 
--- a/src/video/dga/SDL_dgavideo.c	Tue Feb 26 10:50:28 2008 +0000
+++ b/src/video/dga/SDL_dgavideo.c	Fri Feb 29 13:55:44 2008 +0000
@@ -43,11 +43,6 @@
 
 /*#define DGA_DEBUG*/
 
-/* Heheh we're using X11 event code */
-extern void X11_SaveScreenSaver(Display *display, int *saved_timeout, BOOL *dpms);
-extern void X11_DisableScreenSaver(Display *display);
-extern void X11_RestoreScreenSaver(Display *display, int saved_timeout, BOOL dpms);
-
 /* Initialization/Query functions */
 static int DGA_VideoInit(_THIS, SDL_PixelFormat *vformat);
 static SDL_Rect **DGA_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
@@ -333,6 +328,7 @@
 
 static int DGA_VideoInit(_THIS, SDL_PixelFormat *vformat)
 {
+	const char *env;
 	const char *display;
 	int event_base, error_base;
 	int major_version, minor_version;
@@ -401,9 +397,17 @@
 		return(-1);
 	}
 
-	/* Save DPMS and screensaver settings */
-	X11_SaveScreenSaver(DGA_Display, &screensaver_timeout, &dpms_enabled);
-	X11_DisableScreenSaver(DGA_Display);
+	/* Allow environment override of screensaver disable. */
+	env = SDL_getenv("SDL_VIDEO_ALLOW_SCREENSAVER");
+	if ( env ) {
+		allow_screensaver = SDL_atoi(env);
+	} else {
+#ifdef SDL_VIDEO_DISABLE_SCREENSAVER
+		allow_screensaver = 0;
+#else
+		allow_screensaver = 1;
+#endif
+	}
 
 	/* Query for the list of available video modes */
 	modes = SDL_NAME(XDGAQueryModes)(DGA_Display, DGA_Screen, &num_modes);
@@ -1091,9 +1095,6 @@
 		/* Clean up the memory bucket list */
 		DGA_FreeHWSurfaces(this);
 
-		/* Restore DPMS and screensaver settings */
-		X11_RestoreScreenSaver(DGA_Display, screensaver_timeout, dpms_enabled);
-
 		/* Close up the display */
 		XCloseDisplay(DGA_Display);
 	}
--- a/src/video/dga/SDL_dgavideo.h	Tue Feb 26 10:50:28 2008 +0000
+++ b/src/video/dga/SDL_dgavideo.h	Fri Feb 29 13:55:44 2008 +0000
@@ -32,10 +32,6 @@
 #include "SDL_mutex.h"
 #include "../SDL_sysvideo.h"
 
-#if SDL_VIDEO_DRIVER_X11_DPMS
-#include <X11/extensions/dpms.h>
-#endif
-
 /* Hidden "this" pointer for the video functions */
 #define _THIS	SDL_VideoDevice *this
 
@@ -94,9 +90,9 @@
 #endif
 
 	/* Screensaver settings */
-	int screensaver_timeout;
-	BOOL dpms_enabled;
+	int allow_screensaver;
 };
+
 /* Old variable names */
 #define DGA_Display		(this->hidden->DGA_Display)
 #define DGA_Screen		DefaultScreen(DGA_Display)
@@ -117,7 +113,6 @@
 #define hw_lock			(this->hidden->hw_lock)
 #define DGA_event_base		(this->hidden->event_base)
 #define event_lock		(this->hidden->event_lock)
-#define screensaver_timeout	(this->hidden->screensaver_timeout)
-#define dpms_enabled		(this->hidden->dpms_enabled)
+#define allow_screensaver	(this->hidden->allow_screensaver)
 
 #endif /* _SDL_dgavideo_h */
--- a/src/video/quartz/SDL_QuartzEvents.m	Tue Feb 26 10:50:28 2008 +0000
+++ b/src/video/quartz/SDL_QuartzEvents.m	Fri Feb 29 13:55:44 2008 +0000
@@ -717,8 +717,6 @@
 
 void QZ_PumpEvents (_THIS)
 {
-    static Uint32 screensaverTicks = 0;
-    Uint32 nowTicks;
     CGMouseDelta dx, dy;
 
     NSDate *distantPast;
@@ -731,7 +729,8 @@
 
     /* Update activity every five seconds to prevent screensaver. --ryan. */
     if (!allow_screensaver) {
-        nowTicks = SDL_GetTicks();
+        static Uint32 screensaverTicks;
+        Uint32 nowTicks = SDL_GetTicks();
         if ((nowTicks - screensaverTicks) > 5000)
         {
             UpdateSystemActivity(UsrActivity);
--- a/src/video/quartz/SDL_QuartzVideo.m	Tue Feb 26 10:50:28 2008 +0000
+++ b/src/video/quartz/SDL_QuartzVideo.m	Fri Feb 29 13:55:44 2008 +0000
@@ -188,8 +188,17 @@
     mode_list  = CGDisplayAvailableModes (display_id);
     palette    = CGPaletteCreateDefaultColorPalette ();
 
+    /* Allow environment override of screensaver disable. */
     env = SDL_getenv("SDL_VIDEO_ALLOW_SCREENSAVER");
-    allow_screensaver = ( env && SDL_atoi(env) ) ? YES : NO;
+    if ( env ) {
+        allow_screensaver = SDL_atoi(env);
+    } else {
+#ifdef SDL_VIDEO_DISABLE_SCREENSAVER
+        allow_screensaver = 0;
+#else
+        allow_screensaver = 1;
+#endif
+    }
 
     /* Gather some information that is useful to know about the display */
     CFNumberGetValue (CFDictionaryGetValue (save_mode, kCGDisplayBitsPerPixel),
--- a/src/video/windib/SDL_dibevents.c	Tue Feb 26 10:50:28 2008 +0000
+++ b/src/video/windib/SDL_dibevents.c	Fri Feb 29 13:55:44 2008 +0000
@@ -227,7 +227,7 @@
 		case WM_SYSCOMMAND: {
 			const DWORD val = (DWORD) (wParam & 0xFFF0);
 			if ((val == SC_SCREENSAVE) || (val == SC_MONITORPOWER)) {
-				if (!this->hidden->allow_screensaver) {
+				if (!allow_screensaver) {
 					/* Note that this doesn't stop anything on Vista
 					   if the screensaver has a password. */
 					return(0);
--- a/src/video/windib/SDL_dibvideo.c	Tue Feb 26 10:50:28 2008 +0000
+++ b/src/video/windib/SDL_dibvideo.c	Fri Feb 29 13:55:44 2008 +0000
@@ -396,7 +396,15 @@
 
 	/* Allow environment override of screensaver disable. */
 	env = SDL_getenv("SDL_VIDEO_ALLOW_SCREENSAVER");
-	this->hidden->allow_screensaver = ( (env && SDL_atoi(env)) ? 1 : 0 );
+	if ( env ) {
+		allow_screensaver = SDL_atoi(env);
+	} else {
+#ifdef SDL_VIDEO_DISABLE_SCREENSAVER
+		allow_screensaver = 0;
+#else
+		allow_screensaver = 1;
+#endif
+	}
 
 	/* We're done! */
 	return(0);
--- a/src/video/windib/SDL_dibvideo.h	Tue Feb 26 10:50:28 2008 +0000
+++ b/src/video/windib/SDL_dibvideo.h	Fri Feb 29 13:55:44 2008 +0000
@@ -43,8 +43,6 @@
     LOGPALETTE *screen_logpal;
     BOOL grab_palette;
 
-    int allow_screensaver;
-
 #define NUM_MODELISTS	4		/* 8, 16, 24, and 32 bits-per-pixel */
     int SDL_nummodes[NUM_MODELISTS];
     SDL_Rect **SDL_modelist[NUM_MODELISTS];
@@ -56,6 +54,9 @@
 	int supportRotation; /* for Pocket PC devices */
 	DWORD origRotation; /* for Pocket PC devices */
 #endif
+
+    /* Screensaver settings */
+    int allow_screensaver;
 };
 /* Old variable names */
 #define screen_bmp		(this->hidden->screen_bmp)
@@ -64,5 +65,6 @@
 #define grab_palette		(this->hidden->grab_palette)
 #define SDL_nummodes		(this->hidden->SDL_nummodes)
 #define SDL_modelist		(this->hidden->SDL_modelist)
+#define allow_screensaver	(this->hidden->allow_screensaver)
 
 #endif /* _SDL_dibvideo_h */
--- a/src/video/x11/SDL_x11events.c	Tue Feb 26 10:50:28 2008 +0000
+++ b/src/video/x11/SDL_x11events.c	Fri Feb 29 13:55:44 2008 +0000
@@ -920,6 +920,16 @@
 {
 	int pending;
 
+	/* Update activity every five seconds to prevent screensaver. --ryan. */
+	if (!allow_screensaver) {
+		static Uint32 screensaverTicks;
+		Uint32 nowTicks = SDL_GetTicks();
+		if ((nowTicks - screensaverTicks) > 5000) {
+			XResetScreenSaver(SDL_Display);
+			screensaverTicks = nowTicks;
+		}
+	}
+
 	/* Keep processing pending events */
 	pending = 0;
 	while ( X11_Pending(SDL_Display) ) {
@@ -1389,67 +1399,3 @@
 	X11_InitKeymap();
 }
 
-void X11_SaveScreenSaver(Display *display, int *saved_timeout, BOOL *dpms)
-{
-	int timeout, interval, prefer_blank, allow_exp;
-	XGetScreenSaver(display, &timeout, &interval, &prefer_blank, &allow_exp);
-	*saved_timeout = timeout;
-
-#if SDL_VIDEO_DRIVER_X11_DPMS
-	if ( SDL_X11_HAVE_DPMS ) {
-		int dummy;
-	  	if ( DPMSQueryExtension(display, &dummy, &dummy) ) {
-			CARD16 state;
-			DPMSInfo(display, &state, dpms);
-		}
-	}
-#else
-	*dpms = 0;
-#endif /* SDL_VIDEO_DRIVER_X11_DPMS */
-}
-
-void X11_DisableScreenSaver(_THIS, Display *display)
-{
-	int timeout, interval, prefer_blank, allow_exp;
-
-	if (this->hidden->allow_screensaver) {
-		return;
-	}
-
-	XGetScreenSaver(display, &timeout, &interval, &prefer_blank, &allow_exp);
-	timeout = 0;
-	XSetScreenSaver(display, timeout, interval, prefer_blank, allow_exp);
-
-#if SDL_VIDEO_DRIVER_X11_DPMS
-	if ( SDL_X11_HAVE_DPMS ) {
-		int dummy;
-	  	if ( DPMSQueryExtension(display, &dummy, &dummy) ) {
-			DPMSDisable(display);
-		}
-	}
-#endif /* SDL_VIDEO_DRIVER_X11_DPMS */
-}
-
-void X11_RestoreScreenSaver(_THIS, Display *display, int saved_timeout, BOOL dpms)
-{
-	int timeout, interval, prefer_blank, allow_exp;
-
-	if (this->hidden->allow_screensaver) {
-		return;
-	}
-
-	XGetScreenSaver(display, &timeout, &interval, &prefer_blank, &allow_exp);
-	timeout = saved_timeout;
-	XSetScreenSaver(display, timeout, interval, prefer_blank, allow_exp);
-
-#if SDL_VIDEO_DRIVER_X11_DPMS
-	if ( SDL_X11_HAVE_DPMS ) {
-		int dummy;
-	  	if ( DPMSQueryExtension(display, &dummy, &dummy) ) {
-			if ( dpms ) {
-				DPMSEnable(display);
-			}
-		}
-	}
-#endif /* SDL_VIDEO_DRIVER_X11_DPMS */
-}
--- a/src/video/x11/SDL_x11events_c.h	Tue Feb 26 10:50:28 2008 +0000
+++ b/src/video/x11/SDL_x11events_c.h	Fri Feb 29 13:55:44 2008 +0000
@@ -27,7 +27,3 @@
 extern void X11_InitOSKeymap(_THIS);
 extern void X11_PumpEvents(_THIS);
 extern void X11_SetKeyboardState(Display *display, const char *key_vec);
-
-extern void X11_SaveScreenSaver(Display *display, int *saved_timeout, BOOL *dpms);
-extern void X11_DisableScreenSaver(_THIS, Display *display);
-extern void X11_RestoreScreenSaver(_THIS, Display *display, int saved_timeout, BOOL dpms);
--- a/src/video/x11/SDL_x11sym.h	Tue Feb 26 10:50:28 2008 +0000
+++ b/src/video/x11/SDL_x11sym.h	Fri Feb 29 13:55:44 2008 +0000
@@ -56,7 +56,6 @@
 SDL_X11_SYM(int,XGetErrorDatabaseText,(Display* a,_Xconst char* b,_Xconst char* c,_Xconst char* d,char* e,int f),(a,b,c,d,e,f),return)
 SDL_X11_SYM(XModifierKeymap*,XGetModifierMapping,(Display* a),(a),return)
 SDL_X11_SYM(int,XGetPointerControl,(Display* a,int* b,int* c,int* d),(a,b,c,d),return)
-SDL_X11_SYM(int,XGetScreenSaver,(Display* a,int* b,int* c,int* d, int* e),(a,b,c,d,e),return)
 SDL_X11_SYM(XVisualInfo*,XGetVisualInfo,(Display* a,long b,XVisualInfo* c,int* d),(a,b,c,d),return)
 SDL_X11_SYM(XWMHints*,XGetWMHints,(Display* a,Window b),(a,b),return)
 SDL_X11_SYM(Status,XGetWindowAttributes,(Display* a,Window b,XWindowAttributes* c),(a,b,c),return)
@@ -85,13 +84,13 @@
 SDL_X11_SYM(Bool,XQueryPointer,(Display* a,Window b,Window* c,Window* d,int* e,int* f,int* g,int* h,unsigned int* i),(a,b,c,d,e,f,g,h,i),return)
 SDL_X11_SYM(int,XRaiseWindow,(Display* a,Window b),(a,b),return)
 SDL_X11_SYM(int,XReparentWindow,(Display* a,Window b,Window c,int d,int e),(a,b,c,d,e),return)
+SDL_X11_SYM(int,XResetScreenSaver,(Display* a),(a),return)
 SDL_X11_SYM(int,XResizeWindow,(Display* a,Window b,unsigned int c,unsigned int d),(a,b,c,d),return)
 SDL_X11_SYM(int,XSelectInput,(Display* a,Window b,long c),(a,b,c),return)
 SDL_X11_SYM(Status,XSendEvent,(Display* a,Window b,Bool c,long d,XEvent* e),(a,b,c,d,e),return)
 SDL_X11_SYM(int,XSetClassHint,(Display* a,Window b,XClassHint* c),(a,b,c),return)
 SDL_X11_SYM(XErrorHandler,XSetErrorHandler,(XErrorHandler a),(a),return)
 SDL_X11_SYM(XIOErrorHandler,XSetIOErrorHandler,(XIOErrorHandler a),(a),return)
-SDL_X11_SYM(int,XSetScreenSaver,(Display* a,int b,int c,int d,int e),(a,b,c,d,e),return)
 SDL_X11_SYM(int,XSetTransientForHint,(Display* a,Window b,Window c),(a,b,c),return)
 SDL_X11_SYM(int,XSetWMHints,(Display* a,Window b,XWMHints* c),(a,b,c),return)
 SDL_X11_SYM(void,XSetTextProperty,(Display* a,Window b,XTextProperty* c,Atom d),(a,b,c,d),)
@@ -192,14 +191,5 @@
 SDL_X11_SYM(void,XRRFreeScreenConfigInfo,(XRRScreenConfiguration *config),(config),)
 #endif
 
-/* DPMS support */
-#if SDL_VIDEO_DRIVER_X11_DPMS
-SDL_X11_MODULE(DPMS)
-SDL_X11_SYM(Status,DPMSQueryExtension,(Display *dpy,int *major_versionp,int *minor_versionp),(dpy,major_versionp,minor_versionp),return)
-SDL_X11_SYM(Status,DPMSInfo,(Display *dpy,CARD16 *state,BOOL *onoff),(dpy,state,onoff),return)
-SDL_X11_SYM(Status,DPMSEnable,(Display *dpy),(dpy),return)
-SDL_X11_SYM(Status,DPMSDisable,(Display *dpy),(dpy),return)
-#endif
-
 /* end of SDL_x11sym.h ... */
 
--- a/src/video/x11/SDL_x11video.c	Tue Feb 26 10:50:28 2008 +0000
+++ b/src/video/x11/SDL_x11video.c	Fri Feb 29 13:55:44 2008 +0000
@@ -556,7 +556,7 @@
 
 static int X11_VideoInit(_THIS, SDL_PixelFormat *vformat)
 {
-	const char *env = NULL;
+	const char *env;
 	char *display;
 	int i;
 
@@ -669,11 +669,15 @@
 
 	/* Allow environment override of screensaver disable. */
 	env = SDL_getenv("SDL_VIDEO_ALLOW_SCREENSAVER");
-	this->hidden->allow_screensaver = ( (env && SDL_atoi(env)) ? 1 : 0 );
-
-	/* Save DPMS and screensaver settings */
-	X11_SaveScreenSaver(SDL_Display, &screensaver_timeout, &dpms_enabled);
-	X11_DisableScreenSaver(this, SDL_Display);
+	if ( env ) {
+		allow_screensaver = SDL_atoi(env);
+	} else {
+#ifdef SDL_VIDEO_DISABLE_SCREENSAVER
+		allow_screensaver = 0;
+#else
+		allow_screensaver = 1;
+#endif
+	}
 
 	/* See if we have been passed a window to use */
 	SDL_windowid = SDL_getenv("SDL_WINDOWID");
@@ -1506,9 +1510,6 @@
 			X11_SwapVidModeGamma(this);
 		}
 
-		/* Restore DPMS and screensaver settings */
-		X11_RestoreScreenSaver(this, SDL_Display, screensaver_timeout, dpms_enabled);
-
 		/* Free that blank cursor */
 		if ( SDL_BlankCursor != NULL ) {
 			this->FreeWMCursor(this, SDL_BlankCursor);
--- a/src/video/x11/SDL_x11video.h	Tue Feb 26 10:50:28 2008 +0000
+++ b/src/video/x11/SDL_x11video.h	Fri Feb 29 13:55:44 2008 +0000
@@ -46,9 +46,6 @@
 #if SDL_VIDEO_DRIVER_X11_XME
 #include "../Xext/extensions/xme.h"
 #endif
-#if SDL_VIDEO_DRIVER_X11_DPMS
-#include <X11/extensions/dpms.h>
-#endif
 
 #include "SDL_x11dyn.h"
 
@@ -139,8 +136,6 @@
     int use_xme;
     int currently_fullscreen;
 
-    int allow_screensaver;
-
     /* Automatic mode switching support (entering/leaving fullscreen) */
     Uint32 switch_waiting;
     Uint32 switch_time;
@@ -158,8 +153,7 @@
     short *iconcolors;		/* List of colors used by the icon */
 
     /* Screensaver settings */
-    int screensaver_timeout;
-    BOOL dpms_enabled;
+    int allow_screensaver;
 };
 
 /* Old variable names */
@@ -210,8 +204,8 @@
 #define gamma_saved		(this->hidden->gamma_saved)
 #define gamma_changed		(this->hidden->gamma_changed)
 #define SDL_iconcolors		(this->hidden->iconcolors)
-#define screensaver_timeout	(this->hidden->screensaver_timeout)
-#define dpms_enabled		(this->hidden->dpms_enabled)
+#define allow_screensaver	(this->hidden->allow_screensaver)
+
 /* Some versions of XFree86 have bugs - detect if this is one of them */
 #define BUGGY_XFREE86(condition, buggy_version) \
 ((SDL_strcmp(ServerVendor(SDL_Display), "The XFree86 Project, Inc") == 0) && \
--- a/src/video/xbios/SDL_xbios_centscreen.c	Tue Feb 26 10:50:28 2008 +0000
+++ b/src/video/xbios/SDL_xbios_centscreen.c	Fri Feb 29 13:55:44 2008 +0000
@@ -85,10 +85,12 @@
 	newmode.plan = planes;
 	Vwrite(0, &newmode, &curmode);
 
+#ifdef SDL_VIDEO_DISABLE_SCREENSAVER
 	/* Disable screensaver */
 	Vread(&newmode);
 	newmode.mode &= ~(CSCREEN_SAVER|CSCREEN_ENERGYSTAR);
 	Vwrite(0, &newmode, &curmode);
+#endif /* SDL_VIDEO_DISABLE_SCREENSAVER */
 }
 
 void SDL_XBIOS_CentscreenRestore(_THIS, int prev_handle)