* Added configure option --enable-screensaver, to allow enabling the screensaver by default. SDL-1.2
authorSam Lantinga <slouken@libsdl.org>
Fri, 29 Feb 2008 13:55:44 +0000
branchSDL-1.2
changeset 4139568c9b3c0167
parent 4138 b1fd24d62e55
child 4140 fc69b552ee32
* 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.
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
     1.1 --- a/configure.in	Tue Feb 26 10:50:28 2008 +0000
     1.2 +++ b/configure.in	Fri Feb 29 13:55:44 2008 +0000
     1.3 @@ -1090,19 +1090,6 @@
     1.4              if test x$definitely_enable_video_x11_xrandr = xyes; then
     1.5                  AC_DEFINE(SDL_VIDEO_DRIVER_X11_XRANDR)
     1.6              fi
     1.7 -            AC_ARG_ENABLE(video-x11-dpms,
     1.8 -AC_HELP_STRING([--enable-video-x11-dpms], [enable X11 DPMS extension [[default=yes]]]),
     1.9 -                            , enable_video_x11_dpms=yes)
    1.10 -            if test x$enable_video_x11_dpms = xyes; then
    1.11 -                AC_CHECK_HEADER(X11/extensions/dpms.h,
    1.12 -                                have_dpms_h_hdr=yes,
    1.13 -                                have_dpms_h_hdr=no,
    1.14 -                                [#include <X11/Xlib.h>
    1.15 -                                ])
    1.16 -                if test x$have_dpms_h_hdr = xyes; then
    1.17 -                    AC_DEFINE(SDL_VIDEO_DRIVER_X11_DPMS)
    1.18 -                fi
    1.19 -            fi
    1.20          fi
    1.21      fi
    1.22  }
    1.23 @@ -1673,6 +1660,13 @@
    1.24      fi
    1.25  }
    1.26  
    1.27 +AC_ARG_ENABLE(screensaver,
    1.28 +AC_HELP_STRING([--enable-screensaver], [enable screensaver by default while any SDL application is running [[default=no]]]),
    1.29 +              , enable_screensaver=no)
    1.30 +if test x$enable_screensaver = xno; then
    1.31 +    AC_DEFINE(SDL_VIDEO_DISABLE_SCREENSAVER)
    1.32 +fi
    1.33 +
    1.34  dnl See if we can use the new unified event interface in Linux 2.4
    1.35  CheckInputEvents()
    1.36  {
     2.1 --- a/docs.html	Tue Feb 26 10:50:28 2008 +0000
     2.2 +++ b/docs.html	Fri Feb 29 13:55:44 2008 +0000
     2.3 @@ -14,6 +14,45 @@
     2.4  
     2.5  <H2> <A HREF="docs/index.html">API Documentation</A> </H2>
     2.6  
     2.7 +<H2> SDL 1.2.14 Release Notes </H2>
     2.8 +<P>
     2.9 +SDL 1.2.14 is a minor bug fix release.
    2.10 +</P>
    2.11 +
    2.12 +<H3> General Notes </H3>
    2.13 +
    2.14 +<BLOCKQUOTE>
    2.15 +<P>
    2.16 +</P>
    2.17 +</BLOCKQUOTE>
    2.18 +
    2.19 +<H3> Unix Notes </H3>
    2.20 +
    2.21 +<BLOCKQUOTE>
    2.22 +<P>
    2.23 +	Added configure option --enable-screensaver, to allow enabling the screensaver by default.
    2.24 +</P>
    2.25 +<P>
    2.26 +	Use XResetScreenSaver() instead of disabling screensaver entirely.
    2.27 +</P>
    2.28 +</BLOCKQUOTE>
    2.29 +
    2.30 +<H3> Windows Notes </H3>
    2.31 +
    2.32 +<BLOCKQUOTE>
    2.33 +<P>
    2.34 +</P>
    2.35 +</BLOCKQUOTE>
    2.36 +
    2.37 +<H3> Mac OS X Notes </H3>
    2.38 +
    2.39 +<BLOCKQUOTE>
    2.40 +<P>
    2.41 +</P>
    2.42 +</BLOCKQUOTE>
    2.43 +
    2.44 +<IMG SRC="docs/images/rainbow.gif" ALT="[separator]" WIDTH="100%">
    2.45 +
    2.46  <H2> SDL 1.2.13 Release Notes </H2>
    2.47  <P>
    2.48  SDL 1.2.13 is a minor bug fix release.
     3.1 --- a/include/SDL_config.h.in	Tue Feb 26 10:50:28 2008 +0000
     3.2 +++ b/include/SDL_config.h.in	Fri Feb 29 13:55:44 2008 +0000
     3.3 @@ -279,7 +279,6 @@
     3.4  #undef SDL_VIDEO_DRIVER_WSCONS
     3.5  #undef SDL_VIDEO_DRIVER_X11
     3.6  #undef SDL_VIDEO_DRIVER_X11_DGAMOUSE
     3.7 -#undef SDL_VIDEO_DRIVER_X11_DPMS
     3.8  #undef SDL_VIDEO_DRIVER_X11_DYNAMIC
     3.9  #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT
    3.10  #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR
    3.11 @@ -298,6 +297,9 @@
    3.12  #undef SDL_VIDEO_OPENGL_OSMESA
    3.13  #undef SDL_VIDEO_OPENGL_OSMESA_DYNAMIC
    3.14  
    3.15 +/* Disable screensaver */
    3.16 +#undef SDL_VIDEO_DISABLE_SCREENSAVER
    3.17 +
    3.18  /* Enable assembly routines */
    3.19  #undef SDL_ASSEMBLY_ROUTINES
    3.20  #undef SDL_HERMES_BLITTERS
     4.1 --- a/include/SDL_config_macosx.h	Tue Feb 26 10:50:28 2008 +0000
     4.2 +++ b/include/SDL_config_macosx.h	Fri Feb 29 13:55:44 2008 +0000
     4.3 @@ -126,6 +126,9 @@
     4.4  /* Enable OpenGL support */
     4.5  #define SDL_VIDEO_OPENGL	1
     4.6  
     4.7 +/* Disable screensaver */
     4.8 +#define SDL_VIDEO_DISABLE_SCREENSAVER	1
     4.9 +
    4.10  /* Enable assembly routines */
    4.11  #define SDL_ASSEMBLY_ROUTINES	1
    4.12  #ifdef __ppc__
     5.1 --- a/include/SDL_config_win32.h	Tue Feb 26 10:50:28 2008 +0000
     5.2 +++ b/include/SDL_config_win32.h	Fri Feb 29 13:55:44 2008 +0000
     5.3 @@ -172,6 +172,9 @@
     5.4  #define SDL_VIDEO_OPENGL_WGL	1
     5.5  #endif
     5.6  
     5.7 +/* Disable screensaver */
     5.8 +#define SDL_VIDEO_DISABLE_SCREENSAVER	1
     5.9 +
    5.10  /* Enable assembly routines (Win64 doesn't have inline asm) */
    5.11  #ifndef _WIN64
    5.12  #define SDL_ASSEMBLY_ROUTINES	1
     6.1 --- a/src/video/dga/SDL_dgaevents.c	Tue Feb 26 10:50:28 2008 +0000
     6.2 +++ b/src/video/dga/SDL_dgaevents.c	Fri Feb 29 13:55:44 2008 +0000
     6.3 @@ -137,9 +137,21 @@
     6.4  {
     6.5  	/* Keep processing pending events */
     6.6  	LOCK_DISPLAY();
     6.7 +
     6.8 +	/* Update activity every five seconds to prevent screensaver. --ryan. */
     6.9 +	if (!allow_screensaver) {
    6.10 +		static Uint32 screensaverTicks;
    6.11 +		Uint32 nowTicks = SDL_GetTicks();
    6.12 +		if ((nowTicks - screensaverTicks) > 5000) {
    6.13 +			XResetScreenSaver(DGA_Display);
    6.14 +			screensaverTicks = nowTicks;
    6.15 +		}
    6.16 +	}
    6.17 +
    6.18  	while ( X11_Pending(DGA_Display) ) {
    6.19  		DGA_DispatchEvent(this);
    6.20  	}
    6.21 +
    6.22  	UNLOCK_DISPLAY();
    6.23  }
    6.24  
     7.1 --- a/src/video/dga/SDL_dgavideo.c	Tue Feb 26 10:50:28 2008 +0000
     7.2 +++ b/src/video/dga/SDL_dgavideo.c	Fri Feb 29 13:55:44 2008 +0000
     7.3 @@ -43,11 +43,6 @@
     7.4  
     7.5  /*#define DGA_DEBUG*/
     7.6  
     7.7 -/* Heheh we're using X11 event code */
     7.8 -extern void X11_SaveScreenSaver(Display *display, int *saved_timeout, BOOL *dpms);
     7.9 -extern void X11_DisableScreenSaver(Display *display);
    7.10 -extern void X11_RestoreScreenSaver(Display *display, int saved_timeout, BOOL dpms);
    7.11 -
    7.12  /* Initialization/Query functions */
    7.13  static int DGA_VideoInit(_THIS, SDL_PixelFormat *vformat);
    7.14  static SDL_Rect **DGA_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
    7.15 @@ -333,6 +328,7 @@
    7.16  
    7.17  static int DGA_VideoInit(_THIS, SDL_PixelFormat *vformat)
    7.18  {
    7.19 +	const char *env;
    7.20  	const char *display;
    7.21  	int event_base, error_base;
    7.22  	int major_version, minor_version;
    7.23 @@ -401,9 +397,17 @@
    7.24  		return(-1);
    7.25  	}
    7.26  
    7.27 -	/* Save DPMS and screensaver settings */
    7.28 -	X11_SaveScreenSaver(DGA_Display, &screensaver_timeout, &dpms_enabled);
    7.29 -	X11_DisableScreenSaver(DGA_Display);
    7.30 +	/* Allow environment override of screensaver disable. */
    7.31 +	env = SDL_getenv("SDL_VIDEO_ALLOW_SCREENSAVER");
    7.32 +	if ( env ) {
    7.33 +		allow_screensaver = SDL_atoi(env);
    7.34 +	} else {
    7.35 +#ifdef SDL_VIDEO_DISABLE_SCREENSAVER
    7.36 +		allow_screensaver = 0;
    7.37 +#else
    7.38 +		allow_screensaver = 1;
    7.39 +#endif
    7.40 +	}
    7.41  
    7.42  	/* Query for the list of available video modes */
    7.43  	modes = SDL_NAME(XDGAQueryModes)(DGA_Display, DGA_Screen, &num_modes);
    7.44 @@ -1091,9 +1095,6 @@
    7.45  		/* Clean up the memory bucket list */
    7.46  		DGA_FreeHWSurfaces(this);
    7.47  
    7.48 -		/* Restore DPMS and screensaver settings */
    7.49 -		X11_RestoreScreenSaver(DGA_Display, screensaver_timeout, dpms_enabled);
    7.50 -
    7.51  		/* Close up the display */
    7.52  		XCloseDisplay(DGA_Display);
    7.53  	}
     8.1 --- a/src/video/dga/SDL_dgavideo.h	Tue Feb 26 10:50:28 2008 +0000
     8.2 +++ b/src/video/dga/SDL_dgavideo.h	Fri Feb 29 13:55:44 2008 +0000
     8.3 @@ -32,10 +32,6 @@
     8.4  #include "SDL_mutex.h"
     8.5  #include "../SDL_sysvideo.h"
     8.6  
     8.7 -#if SDL_VIDEO_DRIVER_X11_DPMS
     8.8 -#include <X11/extensions/dpms.h>
     8.9 -#endif
    8.10 -
    8.11  /* Hidden "this" pointer for the video functions */
    8.12  #define _THIS	SDL_VideoDevice *this
    8.13  
    8.14 @@ -94,9 +90,9 @@
    8.15  #endif
    8.16  
    8.17  	/* Screensaver settings */
    8.18 -	int screensaver_timeout;
    8.19 -	BOOL dpms_enabled;
    8.20 +	int allow_screensaver;
    8.21  };
    8.22 +
    8.23  /* Old variable names */
    8.24  #define DGA_Display		(this->hidden->DGA_Display)
    8.25  #define DGA_Screen		DefaultScreen(DGA_Display)
    8.26 @@ -117,7 +113,6 @@
    8.27  #define hw_lock			(this->hidden->hw_lock)
    8.28  #define DGA_event_base		(this->hidden->event_base)
    8.29  #define event_lock		(this->hidden->event_lock)
    8.30 -#define screensaver_timeout	(this->hidden->screensaver_timeout)
    8.31 -#define dpms_enabled		(this->hidden->dpms_enabled)
    8.32 +#define allow_screensaver	(this->hidden->allow_screensaver)
    8.33  
    8.34  #endif /* _SDL_dgavideo_h */
     9.1 --- a/src/video/quartz/SDL_QuartzEvents.m	Tue Feb 26 10:50:28 2008 +0000
     9.2 +++ b/src/video/quartz/SDL_QuartzEvents.m	Fri Feb 29 13:55:44 2008 +0000
     9.3 @@ -717,8 +717,6 @@
     9.4  
     9.5  void QZ_PumpEvents (_THIS)
     9.6  {
     9.7 -    static Uint32 screensaverTicks = 0;
     9.8 -    Uint32 nowTicks;
     9.9      CGMouseDelta dx, dy;
    9.10  
    9.11      NSDate *distantPast;
    9.12 @@ -731,7 +729,8 @@
    9.13  
    9.14      /* Update activity every five seconds to prevent screensaver. --ryan. */
    9.15      if (!allow_screensaver) {
    9.16 -        nowTicks = SDL_GetTicks();
    9.17 +        static Uint32 screensaverTicks;
    9.18 +        Uint32 nowTicks = SDL_GetTicks();
    9.19          if ((nowTicks - screensaverTicks) > 5000)
    9.20          {
    9.21              UpdateSystemActivity(UsrActivity);
    10.1 --- a/src/video/quartz/SDL_QuartzVideo.m	Tue Feb 26 10:50:28 2008 +0000
    10.2 +++ b/src/video/quartz/SDL_QuartzVideo.m	Fri Feb 29 13:55:44 2008 +0000
    10.3 @@ -188,8 +188,17 @@
    10.4      mode_list  = CGDisplayAvailableModes (display_id);
    10.5      palette    = CGPaletteCreateDefaultColorPalette ();
    10.6  
    10.7 +    /* Allow environment override of screensaver disable. */
    10.8      env = SDL_getenv("SDL_VIDEO_ALLOW_SCREENSAVER");
    10.9 -    allow_screensaver = ( env && SDL_atoi(env) ) ? YES : NO;
   10.10 +    if ( env ) {
   10.11 +        allow_screensaver = SDL_atoi(env);
   10.12 +    } else {
   10.13 +#ifdef SDL_VIDEO_DISABLE_SCREENSAVER
   10.14 +        allow_screensaver = 0;
   10.15 +#else
   10.16 +        allow_screensaver = 1;
   10.17 +#endif
   10.18 +    }
   10.19  
   10.20      /* Gather some information that is useful to know about the display */
   10.21      CFNumberGetValue (CFDictionaryGetValue (save_mode, kCGDisplayBitsPerPixel),
    11.1 --- a/src/video/windib/SDL_dibevents.c	Tue Feb 26 10:50:28 2008 +0000
    11.2 +++ b/src/video/windib/SDL_dibevents.c	Fri Feb 29 13:55:44 2008 +0000
    11.3 @@ -227,7 +227,7 @@
    11.4  		case WM_SYSCOMMAND: {
    11.5  			const DWORD val = (DWORD) (wParam & 0xFFF0);
    11.6  			if ((val == SC_SCREENSAVE) || (val == SC_MONITORPOWER)) {
    11.7 -				if (!this->hidden->allow_screensaver) {
    11.8 +				if (!allow_screensaver) {
    11.9  					/* Note that this doesn't stop anything on Vista
   11.10  					   if the screensaver has a password. */
   11.11  					return(0);
    12.1 --- a/src/video/windib/SDL_dibvideo.c	Tue Feb 26 10:50:28 2008 +0000
    12.2 +++ b/src/video/windib/SDL_dibvideo.c	Fri Feb 29 13:55:44 2008 +0000
    12.3 @@ -396,7 +396,15 @@
    12.4  
    12.5  	/* Allow environment override of screensaver disable. */
    12.6  	env = SDL_getenv("SDL_VIDEO_ALLOW_SCREENSAVER");
    12.7 -	this->hidden->allow_screensaver = ( (env && SDL_atoi(env)) ? 1 : 0 );
    12.8 +	if ( env ) {
    12.9 +		allow_screensaver = SDL_atoi(env);
   12.10 +	} else {
   12.11 +#ifdef SDL_VIDEO_DISABLE_SCREENSAVER
   12.12 +		allow_screensaver = 0;
   12.13 +#else
   12.14 +		allow_screensaver = 1;
   12.15 +#endif
   12.16 +	}
   12.17  
   12.18  	/* We're done! */
   12.19  	return(0);
    13.1 --- a/src/video/windib/SDL_dibvideo.h	Tue Feb 26 10:50:28 2008 +0000
    13.2 +++ b/src/video/windib/SDL_dibvideo.h	Fri Feb 29 13:55:44 2008 +0000
    13.3 @@ -43,8 +43,6 @@
    13.4      LOGPALETTE *screen_logpal;
    13.5      BOOL grab_palette;
    13.6  
    13.7 -    int allow_screensaver;
    13.8 -
    13.9  #define NUM_MODELISTS	4		/* 8, 16, 24, and 32 bits-per-pixel */
   13.10      int SDL_nummodes[NUM_MODELISTS];
   13.11      SDL_Rect **SDL_modelist[NUM_MODELISTS];
   13.12 @@ -56,6 +54,9 @@
   13.13  	int supportRotation; /* for Pocket PC devices */
   13.14  	DWORD origRotation; /* for Pocket PC devices */
   13.15  #endif
   13.16 +
   13.17 +    /* Screensaver settings */
   13.18 +    int allow_screensaver;
   13.19  };
   13.20  /* Old variable names */
   13.21  #define screen_bmp		(this->hidden->screen_bmp)
   13.22 @@ -64,5 +65,6 @@
   13.23  #define grab_palette		(this->hidden->grab_palette)
   13.24  #define SDL_nummodes		(this->hidden->SDL_nummodes)
   13.25  #define SDL_modelist		(this->hidden->SDL_modelist)
   13.26 +#define allow_screensaver	(this->hidden->allow_screensaver)
   13.27  
   13.28  #endif /* _SDL_dibvideo_h */
    14.1 --- a/src/video/x11/SDL_x11events.c	Tue Feb 26 10:50:28 2008 +0000
    14.2 +++ b/src/video/x11/SDL_x11events.c	Fri Feb 29 13:55:44 2008 +0000
    14.3 @@ -920,6 +920,16 @@
    14.4  {
    14.5  	int pending;
    14.6  
    14.7 +	/* Update activity every five seconds to prevent screensaver. --ryan. */
    14.8 +	if (!allow_screensaver) {
    14.9 +		static Uint32 screensaverTicks;
   14.10 +		Uint32 nowTicks = SDL_GetTicks();
   14.11 +		if ((nowTicks - screensaverTicks) > 5000) {
   14.12 +			XResetScreenSaver(SDL_Display);
   14.13 +			screensaverTicks = nowTicks;
   14.14 +		}
   14.15 +	}
   14.16 +
   14.17  	/* Keep processing pending events */
   14.18  	pending = 0;
   14.19  	while ( X11_Pending(SDL_Display) ) {
   14.20 @@ -1389,67 +1399,3 @@
   14.21  	X11_InitKeymap();
   14.22  }
   14.23  
   14.24 -void X11_SaveScreenSaver(Display *display, int *saved_timeout, BOOL *dpms)
   14.25 -{
   14.26 -	int timeout, interval, prefer_blank, allow_exp;
   14.27 -	XGetScreenSaver(display, &timeout, &interval, &prefer_blank, &allow_exp);
   14.28 -	*saved_timeout = timeout;
   14.29 -
   14.30 -#if SDL_VIDEO_DRIVER_X11_DPMS
   14.31 -	if ( SDL_X11_HAVE_DPMS ) {
   14.32 -		int dummy;
   14.33 -	  	if ( DPMSQueryExtension(display, &dummy, &dummy) ) {
   14.34 -			CARD16 state;
   14.35 -			DPMSInfo(display, &state, dpms);
   14.36 -		}
   14.37 -	}
   14.38 -#else
   14.39 -	*dpms = 0;
   14.40 -#endif /* SDL_VIDEO_DRIVER_X11_DPMS */
   14.41 -}
   14.42 -
   14.43 -void X11_DisableScreenSaver(_THIS, Display *display)
   14.44 -{
   14.45 -	int timeout, interval, prefer_blank, allow_exp;
   14.46 -
   14.47 -	if (this->hidden->allow_screensaver) {
   14.48 -		return;
   14.49 -	}
   14.50 -
   14.51 -	XGetScreenSaver(display, &timeout, &interval, &prefer_blank, &allow_exp);
   14.52 -	timeout = 0;
   14.53 -	XSetScreenSaver(display, timeout, interval, prefer_blank, allow_exp);
   14.54 -
   14.55 -#if SDL_VIDEO_DRIVER_X11_DPMS
   14.56 -	if ( SDL_X11_HAVE_DPMS ) {
   14.57 -		int dummy;
   14.58 -	  	if ( DPMSQueryExtension(display, &dummy, &dummy) ) {
   14.59 -			DPMSDisable(display);
   14.60 -		}
   14.61 -	}
   14.62 -#endif /* SDL_VIDEO_DRIVER_X11_DPMS */
   14.63 -}
   14.64 -
   14.65 -void X11_RestoreScreenSaver(_THIS, Display *display, int saved_timeout, BOOL dpms)
   14.66 -{
   14.67 -	int timeout, interval, prefer_blank, allow_exp;
   14.68 -
   14.69 -	if (this->hidden->allow_screensaver) {
   14.70 -		return;
   14.71 -	}
   14.72 -
   14.73 -	XGetScreenSaver(display, &timeout, &interval, &prefer_blank, &allow_exp);
   14.74 -	timeout = saved_timeout;
   14.75 -	XSetScreenSaver(display, timeout, interval, prefer_blank, allow_exp);
   14.76 -
   14.77 -#if SDL_VIDEO_DRIVER_X11_DPMS
   14.78 -	if ( SDL_X11_HAVE_DPMS ) {
   14.79 -		int dummy;
   14.80 -	  	if ( DPMSQueryExtension(display, &dummy, &dummy) ) {
   14.81 -			if ( dpms ) {
   14.82 -				DPMSEnable(display);
   14.83 -			}
   14.84 -		}
   14.85 -	}
   14.86 -#endif /* SDL_VIDEO_DRIVER_X11_DPMS */
   14.87 -}
    15.1 --- a/src/video/x11/SDL_x11events_c.h	Tue Feb 26 10:50:28 2008 +0000
    15.2 +++ b/src/video/x11/SDL_x11events_c.h	Fri Feb 29 13:55:44 2008 +0000
    15.3 @@ -27,7 +27,3 @@
    15.4  extern void X11_InitOSKeymap(_THIS);
    15.5  extern void X11_PumpEvents(_THIS);
    15.6  extern void X11_SetKeyboardState(Display *display, const char *key_vec);
    15.7 -
    15.8 -extern void X11_SaveScreenSaver(Display *display, int *saved_timeout, BOOL *dpms);
    15.9 -extern void X11_DisableScreenSaver(_THIS, Display *display);
   15.10 -extern void X11_RestoreScreenSaver(_THIS, Display *display, int saved_timeout, BOOL dpms);
    16.1 --- a/src/video/x11/SDL_x11sym.h	Tue Feb 26 10:50:28 2008 +0000
    16.2 +++ b/src/video/x11/SDL_x11sym.h	Fri Feb 29 13:55:44 2008 +0000
    16.3 @@ -56,7 +56,6 @@
    16.4  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)
    16.5  SDL_X11_SYM(XModifierKeymap*,XGetModifierMapping,(Display* a),(a),return)
    16.6  SDL_X11_SYM(int,XGetPointerControl,(Display* a,int* b,int* c,int* d),(a,b,c,d),return)
    16.7 -SDL_X11_SYM(int,XGetScreenSaver,(Display* a,int* b,int* c,int* d, int* e),(a,b,c,d,e),return)
    16.8  SDL_X11_SYM(XVisualInfo*,XGetVisualInfo,(Display* a,long b,XVisualInfo* c,int* d),(a,b,c,d),return)
    16.9  SDL_X11_SYM(XWMHints*,XGetWMHints,(Display* a,Window b),(a,b),return)
   16.10  SDL_X11_SYM(Status,XGetWindowAttributes,(Display* a,Window b,XWindowAttributes* c),(a,b,c),return)
   16.11 @@ -85,13 +84,13 @@
   16.12  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)
   16.13  SDL_X11_SYM(int,XRaiseWindow,(Display* a,Window b),(a,b),return)
   16.14  SDL_X11_SYM(int,XReparentWindow,(Display* a,Window b,Window c,int d,int e),(a,b,c,d,e),return)
   16.15 +SDL_X11_SYM(int,XResetScreenSaver,(Display* a),(a),return)
   16.16  SDL_X11_SYM(int,XResizeWindow,(Display* a,Window b,unsigned int c,unsigned int d),(a,b,c,d),return)
   16.17  SDL_X11_SYM(int,XSelectInput,(Display* a,Window b,long c),(a,b,c),return)
   16.18  SDL_X11_SYM(Status,XSendEvent,(Display* a,Window b,Bool c,long d,XEvent* e),(a,b,c,d,e),return)
   16.19  SDL_X11_SYM(int,XSetClassHint,(Display* a,Window b,XClassHint* c),(a,b,c),return)
   16.20  SDL_X11_SYM(XErrorHandler,XSetErrorHandler,(XErrorHandler a),(a),return)
   16.21  SDL_X11_SYM(XIOErrorHandler,XSetIOErrorHandler,(XIOErrorHandler a),(a),return)
   16.22 -SDL_X11_SYM(int,XSetScreenSaver,(Display* a,int b,int c,int d,int e),(a,b,c,d,e),return)
   16.23  SDL_X11_SYM(int,XSetTransientForHint,(Display* a,Window b,Window c),(a,b,c),return)
   16.24  SDL_X11_SYM(int,XSetWMHints,(Display* a,Window b,XWMHints* c),(a,b,c),return)
   16.25  SDL_X11_SYM(void,XSetTextProperty,(Display* a,Window b,XTextProperty* c,Atom d),(a,b,c,d),)
   16.26 @@ -192,14 +191,5 @@
   16.27  SDL_X11_SYM(void,XRRFreeScreenConfigInfo,(XRRScreenConfiguration *config),(config),)
   16.28  #endif
   16.29  
   16.30 -/* DPMS support */
   16.31 -#if SDL_VIDEO_DRIVER_X11_DPMS
   16.32 -SDL_X11_MODULE(DPMS)
   16.33 -SDL_X11_SYM(Status,DPMSQueryExtension,(Display *dpy,int *major_versionp,int *minor_versionp),(dpy,major_versionp,minor_versionp),return)
   16.34 -SDL_X11_SYM(Status,DPMSInfo,(Display *dpy,CARD16 *state,BOOL *onoff),(dpy,state,onoff),return)
   16.35 -SDL_X11_SYM(Status,DPMSEnable,(Display *dpy),(dpy),return)
   16.36 -SDL_X11_SYM(Status,DPMSDisable,(Display *dpy),(dpy),return)
   16.37 -#endif
   16.38 -
   16.39  /* end of SDL_x11sym.h ... */
   16.40  
    17.1 --- a/src/video/x11/SDL_x11video.c	Tue Feb 26 10:50:28 2008 +0000
    17.2 +++ b/src/video/x11/SDL_x11video.c	Fri Feb 29 13:55:44 2008 +0000
    17.3 @@ -556,7 +556,7 @@
    17.4  
    17.5  static int X11_VideoInit(_THIS, SDL_PixelFormat *vformat)
    17.6  {
    17.7 -	const char *env = NULL;
    17.8 +	const char *env;
    17.9  	char *display;
   17.10  	int i;
   17.11  
   17.12 @@ -669,11 +669,15 @@
   17.13  
   17.14  	/* Allow environment override of screensaver disable. */
   17.15  	env = SDL_getenv("SDL_VIDEO_ALLOW_SCREENSAVER");
   17.16 -	this->hidden->allow_screensaver = ( (env && SDL_atoi(env)) ? 1 : 0 );
   17.17 -
   17.18 -	/* Save DPMS and screensaver settings */
   17.19 -	X11_SaveScreenSaver(SDL_Display, &screensaver_timeout, &dpms_enabled);
   17.20 -	X11_DisableScreenSaver(this, SDL_Display);
   17.21 +	if ( env ) {
   17.22 +		allow_screensaver = SDL_atoi(env);
   17.23 +	} else {
   17.24 +#ifdef SDL_VIDEO_DISABLE_SCREENSAVER
   17.25 +		allow_screensaver = 0;
   17.26 +#else
   17.27 +		allow_screensaver = 1;
   17.28 +#endif
   17.29 +	}
   17.30  
   17.31  	/* See if we have been passed a window to use */
   17.32  	SDL_windowid = SDL_getenv("SDL_WINDOWID");
   17.33 @@ -1506,9 +1510,6 @@
   17.34  			X11_SwapVidModeGamma(this);
   17.35  		}
   17.36  
   17.37 -		/* Restore DPMS and screensaver settings */
   17.38 -		X11_RestoreScreenSaver(this, SDL_Display, screensaver_timeout, dpms_enabled);
   17.39 -
   17.40  		/* Free that blank cursor */
   17.41  		if ( SDL_BlankCursor != NULL ) {
   17.42  			this->FreeWMCursor(this, SDL_BlankCursor);
    18.1 --- a/src/video/x11/SDL_x11video.h	Tue Feb 26 10:50:28 2008 +0000
    18.2 +++ b/src/video/x11/SDL_x11video.h	Fri Feb 29 13:55:44 2008 +0000
    18.3 @@ -46,9 +46,6 @@
    18.4  #if SDL_VIDEO_DRIVER_X11_XME
    18.5  #include "../Xext/extensions/xme.h"
    18.6  #endif
    18.7 -#if SDL_VIDEO_DRIVER_X11_DPMS
    18.8 -#include <X11/extensions/dpms.h>
    18.9 -#endif
   18.10  
   18.11  #include "SDL_x11dyn.h"
   18.12  
   18.13 @@ -139,8 +136,6 @@
   18.14      int use_xme;
   18.15      int currently_fullscreen;
   18.16  
   18.17 -    int allow_screensaver;
   18.18 -
   18.19      /* Automatic mode switching support (entering/leaving fullscreen) */
   18.20      Uint32 switch_waiting;
   18.21      Uint32 switch_time;
   18.22 @@ -158,8 +153,7 @@
   18.23      short *iconcolors;		/* List of colors used by the icon */
   18.24  
   18.25      /* Screensaver settings */
   18.26 -    int screensaver_timeout;
   18.27 -    BOOL dpms_enabled;
   18.28 +    int allow_screensaver;
   18.29  };
   18.30  
   18.31  /* Old variable names */
   18.32 @@ -210,8 +204,8 @@
   18.33  #define gamma_saved		(this->hidden->gamma_saved)
   18.34  #define gamma_changed		(this->hidden->gamma_changed)
   18.35  #define SDL_iconcolors		(this->hidden->iconcolors)
   18.36 -#define screensaver_timeout	(this->hidden->screensaver_timeout)
   18.37 -#define dpms_enabled		(this->hidden->dpms_enabled)
   18.38 +#define allow_screensaver	(this->hidden->allow_screensaver)
   18.39 +
   18.40  /* Some versions of XFree86 have bugs - detect if this is one of them */
   18.41  #define BUGGY_XFREE86(condition, buggy_version) \
   18.42  ((SDL_strcmp(ServerVendor(SDL_Display), "The XFree86 Project, Inc") == 0) && \
    19.1 --- a/src/video/xbios/SDL_xbios_centscreen.c	Tue Feb 26 10:50:28 2008 +0000
    19.2 +++ b/src/video/xbios/SDL_xbios_centscreen.c	Fri Feb 29 13:55:44 2008 +0000
    19.3 @@ -85,10 +85,12 @@
    19.4  	newmode.plan = planes;
    19.5  	Vwrite(0, &newmode, &curmode);
    19.6  
    19.7 +#ifdef SDL_VIDEO_DISABLE_SCREENSAVER
    19.8  	/* Disable screensaver */
    19.9  	Vread(&newmode);
   19.10  	newmode.mode &= ~(CSCREEN_SAVER|CSCREEN_ENERGYSTAR);
   19.11  	Vwrite(0, &newmode, &curmode);
   19.12 +#endif /* SDL_VIDEO_DISABLE_SCREENSAVER */
   19.13  }
   19.14  
   19.15  void SDL_XBIOS_CentscreenRestore(_THIS, int prev_handle)