author Sam Lantinga <>
Fri, 29 Feb 2008 13:55:44 +0000
changeset 4139 568c9b3c0167
parent 4123 9d90d7765fa7
child 4141 8b10a6efad41
permissions -rw-r--r--
* 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,
[], 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,

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,
[]. 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.
     1 <HTML>
     2 <HEAD><TITLE>SDL Stable Release</TITLE></HEAD>
     3 <BODY BGCOLOR="#FFEBCD" TEXT="#000000">
     5 <IMG SRC="docs/images/rainbow.gif" ALT="[separator]" WIDTH="100%">
     6 <P>
     7 This source is stable, and is fully tested on all supported platforms.<br>
     8 Please send bug reports or questions to the SDL mailing list:<br>
     9 <a href=""
    10         ></a><br>
    11 The latest stable release may be found on the
    12 	<a href="">SDL website</A>.
    13 </P>
    15 <H2> <A HREF="docs/index.html">API Documentation</A> </H2>
    17 <H2> SDL 1.2.14 Release Notes </H2>
    18 <P>
    19 SDL 1.2.14 is a minor bug fix release.
    20 </P>
    22 <H3> General Notes </H3>
    25 <P>
    26 </P>
    27 </BLOCKQUOTE>
    29 <H3> Unix Notes </H3>
    32 <P>
    33 	Added configure option --enable-screensaver, to allow enabling the screensaver by default.
    34 </P>
    35 <P>
    36 	Use XResetScreenSaver() instead of disabling screensaver entirely.
    37 </P>
    38 </BLOCKQUOTE>
    40 <H3> Windows Notes </H3>
    43 <P>
    44 </P>
    45 </BLOCKQUOTE>
    47 <H3> Mac OS X Notes </H3>
    50 <P>
    51 </P>
    52 </BLOCKQUOTE>
    54 <IMG SRC="docs/images/rainbow.gif" ALT="[separator]" WIDTH="100%">
    56 <H2> SDL 1.2.13 Release Notes </H2>
    57 <P>
    58 SDL 1.2.13 is a minor bug fix release.
    59 </P>
    61 <H3> General Notes </H3>
    64 <P>
    65 	Fixed link error when building with Intel Compiler 10.
    66 </P>
    67 <P>
    68 	Removed stray C++ comment from public headers.
    69 </P>
    70 </BLOCKQUOTE>
    72 <H3> Unix Notes </H3>
    75 <P>
    76 	Fixed crash in SDL_SoftStretch() on secure operating systems.
    77 </P>
    78 <P>
    79 	Fixed undefined symbol on X11 implementations without UTF-8 support.
    80 </P>
    81 <P>
    82 	Worked around BadAlloc error when using XVideo on the XFree86 Intel Integrated Graphics driver.
    83 </P>
    84 <P>
    85 	Scan for all joysticks on Linux instead of stopping at one that was removed.
    86 </P>
    87 <P>
    88 	Fixed use of sdl-config arguments in sdl.m4
    89 </P>
    90 </BLOCKQUOTE>
    92 <H3> Windows Notes </H3>
    95 <P>
    96 	Fixed crash when a video driver reports higher than 32 bpp video modes.
    97 </P>
    98 <P>
    99 	Fixed restoring the desktop after setting a 24-bit OpenGL video mode.
   100 </P>
   101 <P>
   102 	Fixed window titles on Windows 95/98/ME.
   103 </P>
   104 <P>
   105 	Added SDL_BUTTON_X1 and SDL_BUTTON_X2 constants for extended mouse buttons.
   106 </P>
   107 <P>
   108 	Added support for quoted command line arguments.
   109 </P>
   110 </BLOCKQUOTE>
   112 <H3> Mac OS X Notes </H3>
   115 <P>
   116 	SDL now builds on Mac OS X 10.5 (Leopard).
   117 </P>
   118 <P>
   119 	Fixed high frequency crash involving text input.
   120 </P>
   121 <P>
   122 	Fixed beeping when the escape key is pressed and UNICODE translation is enabled.
   123 </P>
   124 <P>
   125 	Improved trackpad scrolling support.
   126 </P>
   127 <P>
   128 	Fixed joystick hat reporting for certain joysticks.
   129 </P>
   130 </BLOCKQUOTE>
   132 <IMG SRC="docs/images/rainbow.gif" ALT="[separator]" WIDTH="100%">
   134 <H2> SDL 1.2.12 Release Notes </H2>
   135 <P>
   136 SDL 1.2.12 is a minor bug fix release.
   137 </P>
   139 <H3> General Notes </H3>
   142 <P>
   143 	Added support for the PulseAudio sound server:
   144 </P>
   145 <P>
   146 	Added SDL_VIDEO_ALLOW_SCREENSAVER to override SDL's disabling of the screensaver on Mac OS X, Windows, and X11.
   147 </P>
   148 <P>
   149 	Fixed buffer overrun crash when resampling audio rates.
   150 </P>
   151 <P>
   152 	Fixed audio bug where converting to mono was doubling the volume.
   153 </P>
   154 <P>
   155 	Fixed off-by-one error in the C implementation of SDL_revcpy()
   156 </P>
   157 <P>
   158 	Fixed compiling with Sun Studio.
   159 </P>
   160 <P>
   161 	Support for AmigaOS has been removed from the main SDL code.
   162 </P>
   163 <P>
   164 	Support for Nokia 9210 "EPOC" driver has been removed from the main SDL code.
   165 </P>
   166 <P>
   167 	Unofficial support for the S60/SymbianOS platform has been added.
   168 </P>
   169 <P>
   170 	Unofficial support for the Nintendo DS platform has been added.
   171 </P>
   172 <P>
   173 	Reenabled MMX assembly for YUV overlay processing (GNU C Compiler only).
   174 </P>
   175 </BLOCKQUOTE>
   177 <H3> Unix Notes </H3>
   180 <P>
   181 	Fixed detection of X11 DGA mouse support.
   182 </P>
   183 <P>
   184 	Improved XIM support for asian character sets.
   185 </P>
   186 <P>
   187 	The GFX_Display has been added to the X11 window information in SDL_syswm.h.
   188 </P>
   189 <P>
   190 	Fixed PAGE_SIZE compile error in the fbcon video driver on newer Linux kernels.
   191 </P>
   192 <P>
   193 	Fixed hang or crash at startup if aRts can't access the hardware.
   194 </P>
   195 <P>
   196 	Fixed relative mouse mode when the cursor starts outside the X11 window.
   197 </P>
   198 <P>
   199 	Fixed accidental free of stack memory in X11 mouse acceleration code.
   200 </P>
   201 <P>
   202 	Closed minor memory leak in XME code.
   203 </P>
   204 <P>
   205 	Fixed TEXTRELs in the library to resolve some PIC issues.
   206 </P>
   207 </BLOCKQUOTE>
   209 <H3> Windows Notes </H3>
   212 <P>
   213 	The GDI video driver makes better use of the palette in 8-bit modes.
   214 </P>
   215 <P>
   216 	The windib driver now supports more mouse buttons with WM_XBUTTON events.
   217 </P>
   218 <P>
   219 	On Windows, SDL_SetVideoMode() will re-create the window instead of failing if the multisample settings are changed.
   220 </P>
   221 <P>
   222 	Added support for UTF-8 window titles on Windows.
   223 </P>
   224 <P>
   225 	Fixed joystick detection on Windows.
   226 </P>
   227 <P>
   228 	Improved performance with Win32 file I/O.
   229 </P>
   230 <P>
   231 	Fixed HBITMAP leak in GAPI driver.
   232 </P>
   233 </BLOCKQUOTE>
   235 <H3> Mac OS X Notes </H3>
   238 <P>
   239 	Added support for multi-axis controllers like 3Dconnxion's SpaceNavigator on Mac OS X.
   240 </P>
   241 <P>
   242 	Fixed YUV overlay crash inside Quicktime on Intel Mac OS X.
   243 </P>
   244 <P>
   245 	Fixed blitting alignment in Altivec alpha blit functions.
   246 </P>
   247 <P>
   248 	Keys F13, F14, and F15 are now usable on Apple keyboards under Mac OS X.
   249 </P>
   250 <P>
   251 	Fixed joystick calibration code on Mac OS X.
   252 </P>
   253 <P>
   254 	Fixed mouse jitter when multiple motion events are queued up in Mac OS X.
   255 </P>
   256 <P>
   257 	Fixed changing the cursor in fullscreen mode on Mac OS X.
   258 </P>
   259 </BLOCKQUOTE>
   261 <H3> Mac OS Classic Notes </H3>
   264 <P>
   265 	Added support for gamma ramps to both toolbox and DrawSprocket video drivers.
   266 </P>
   267 </BLOCKQUOTE>
   269 <H3> BeOS Notes </H3>
   272 <P>
   273 	Implemented mouse grabbing and mouse relative mode on BeOS.
   274 </P>
   275 </BLOCKQUOTE>
   277 <IMG SRC="docs/images/rainbow.gif" ALT="[separator]" WIDTH="100%">
   279 <H2> SDL 1.2.11 Release Notes </H2>
   280 <P>
   281 SDL 1.2.11 is a minor bug fix release.
   282 </P>
   284 <H3> Unix Notes </H3>
   287 <P>
   288 	Dynamic X11 loading is only enabled with gcc 4 supporting -fvisibility=hidden.  This fixes crashes related to symbol collisions, and allows building on Solaris and IRIX.
   289 </P>
   290 <P>
   291 	Fixed building SDL with Xinerama disabled.
   292 </P>
   293 <P>
   294 	Fixed DRI OpenGL library loading, using RTLD_GLOBAL in dlopen().
   295 </P>
   296 <P>
   297 	Added pkgconfig configuration support.
   298 </P>
   299 </BLOCKQUOTE>
   301 <H3> Windows Notes </H3>
   304 <P>
   305 	Setting SDL_GL_SWAP_CONTROL now works with Windows OpenGL.
   306 </P>
   307 <P>
   308 	The Win32 window positioning code works properly for windows with menus.
   309 </P>
   310 <P>
   311 	DirectSound audio quality has been improved on certain sound cards.
   312 </P>
   313 <P>
   314 	Fixed 5.1 audio channel ordering on Windows and Mac OS X.
   315 </P>
   316 <P>
   317 	Plugged a couple of minor memory leaks in the windib video driver.
   318 </P>
   319 <P>
   320 	Fixed type collision with stdint.h when building with gcc on Win32.
   321 </P>
   322 <P>
   323 	Fixed building with the Digital Mars Compiler on Win32.
   324 </P>
   325 </BLOCKQUOTE>
   327 <H3> Mac OS X Notes </H3>
   330 <P>
   331 	The Quartz video driver supports 32x32 cursors on Mac OS X 10.3 and above.
   332 </P>
   333 </BLOCKQUOTE>
   335 <IMG SRC="docs/images/rainbow.gif" ALT="[separator]" WIDTH="100%">
   337 <H2> SDL 1.2.10 Release Notes </H2>
   338 <P>
   339 SDL 1.2.10 is a major release, featuring a revamp of the build system and many API improvements and bug fixes.
   340 </P>
   341 <H3> API enhancements </H3>
   342 <UL>
   343 <LI>
   344 	If SDL_OpenAudio() is passed zero for the desired format
   345 	fields, the following environment variables will be used
   346 	to fill them in:
   347 <pre><code>
   352 </code></pre>
   353 	If an environment variable is not specified, it will be set
   354 	to a reasonable default value.
   355 <LI>
   356 	SDL_SetVideoMode() now accepts 0 for width or height and will use
   357 	the current video mode (or the desktop mode if no mode has been set.)
   358 <LI>
   359 	Added current_w and current_h to the SDL_VideoInfo structure,
   360 	which is set to the desktop resolution during video intialization,
   361 	and then set to the current resolution when a video mode is set.
   362 <LI>
   363 	SDL_GL_LoadLibrary() will load the system default OpenGL library
   364 	if it is passed NULL as a parameter.
   365 <LI>
   366 	Added SDL_GL_SWAP_CONTROL to wait for vsync in OpenGL applications.
   367 <LI>
   368 	Added SDL_GL_ACCELERATED_VISUAL to guarantee hardware acceleration.
   369 <LI>
   370 	SDL_WM_SetCaption() now officially takes UTF-8 title and icon strings, and displays international characters on supported platforms.
   371 <LI>
   372 	Added SDL_GetKeyRepeat() to query the key repeat settings.
   373 <LI>
   374 	Added the "dummy" audio driver, which can be used to emulate audio
   375 	output without a sound card.
   376 <LI>
   377 	Added SDL_config.h, with defaults for various build environments.
   378 </UL>
   380 <H3> General Notes </H3>
   383 <P>
   384 	The SDL website now has an <A HREF="">RSS feed</A>!
   385 <P>
   386 	The SDL development source code is now managed with <A HREF="">Subversion</A>.
   387 <P>
   388 	SDL now uses the Bugzilla <A HREF="">bug tracking system</A>, hosted by
   389 <P>
   390 	SDL is licensed under version 2.1 of the GNU Lesser General Public License.
   391 <P>
   392 	The entire build system has been revamped to make it much more portable, including versions of C library functions to make it possible to run SDL on a minimal embedded environment.  See README.Porting in the SDL source distribution for information on how to port SDL to a new platform.
   393 <P>
   394 	SDL_opengl.h has been updated with the latest glext.h from <A HREF=""></A>
   395 <P>
   396 	Alex Volkov contributed highly optimized RGB <-> RGBA blitters.
   397 </BLOCKQUOTE>
   399 <H3> Unix Notes </H3>
   402 <P>
   403 	The X11 libraries are dynamically loaded at runtime by default.  This allows the distributed version of SDL to run on systems without X11 libraries installed.
   404 <P>
   405 	The XiG XME extension code is now included in the X11 video driver by default.
   406 <P>
   407 	XRandR support for video mode switching has been added to the X11 driver, but is disabled because of undesired interactions with window managers.  You can enable this by setting the environment variable SDL_VIDEO_X11_XRANDR to 1.
   408 <P>
   409 	Xinerama multi-head displays are properly handled now, and the SDL_VIDEO_FULLSCREEN_HEAD environment variable can be used to select the screen used for fullscreen video modes.  Note that changing the video modes only works on screen 0.
   410 <P>
   411 	XVidMode video modes are now sorted so they maintain the refresh rates specified in the X11 configuration file.
   412 <P>
   413 	SDL windows are no longer transparent in X11 compositing systems like XGL.
   414 <P>
   415 	The mouse is properly released by the X11 video driver if the fullscreen window loses focus.
   416 <P>
   417 	The X11 input driver now uses XIM to handle international input.
   418 <P>
   419 	The screensaver and DPMS monitor blanking are disabled while SDL games are running under the X11 and DGA video drivers.  This behavior will be formalized and selectable in SDL 1.3.
   420 <P>
   421 	Fixed a bug preventing stereo OpenGL contexts from being selected on the X11 driver.
   422 <P>
   423 	The DGA video driver now waits for pending blits involving surfaces before they are freed.  This prevents display oddities when using SDL_DisplayFormat() to convert many images.
   424 <P>
   425 	The framebuffer console video driver now has a parser for /etc/fb.modes for improved video mode handling.
   426 <P>
   427 	The framebuffer console video driver now allows asynchronous VT switching, and restores the full contents of the screen when switched back.
   428 <P>
   429 	The framebuffer console now uses CTRL-ALT-FN to switch virtual terminals, to avoid collisions with application key bindings.
   430 <P>
   431 	The framebuffer console input driver correctly sets IMPS/2 mode for wheel mice.  It also properly detects when gpm is in IMPS/2 protocol mode, or passing raw protocol from an IMPS/2 mouse.
   432 <P>
   433 	The SVGAlib video driver now has support for banked (non-linear) video modes.
   434 <P>
   435 	A video driver for OpenBSD on the Sharp Zaurus has been contributed by Staffan Ulfberg.  See the file README.wscons in the SDL source distribution for details.
   436 <P>
   437 	Many patches have been incorporated from *BSD ports.
   438 </BLOCKQUOTE>
   440 <H3> Windows Notes </H3>
   443 <P>
   444 	The "windib" video driver is the default now, to prevent problems with certain laptops, 64-bit Windows, and Windows Vista.  The DirectX driver is still available, and can be selected by setting the environment variable SDL_VIDEODRIVER to "directx".
   445 <P>
   446 	SDL has been ported to 64-bit Windows.
   447 <P>
   448 	Dmitry Yakimov contributed a GAPI video driver for Windows CE.
   449 <P>
   450 	The default fullscreen refresh rate has been increased to match the desktop refresh rate, when using equivalent resolutions.  A full API for querying and selecting refresh rates is planned for SDL 1.3.
   451 <P>
   452 	Dialog boxes are now shown when SDL is in windowed OpenGL mode.
   453 <P>
   454 	The SDL window is recreated when necessary to maintain OpenGL context attributes, when switching between windowed and fullscreen modes.
   455 <P>
   456 	An SDL_VIDEORESIZE event is properly sent when the SDL window is maximized and restored.
   457 <P>
   458 	Window positions are retained when switching between fullscreen and windowed modes.
   459 <P>
   460 	ToUnicode() is used, when available, for improved handling of international keyboard input.
   461 <P>
   462 	The PrtScrn is now treated normally with both key down and key up events.
   463 <P>
   464 	Pressing ALT-F4 now delivers an SDL_QUIT event to SDL applications.
   465 <P>
   466 	Joystick names are now correct for joysticks which have been unplugged and then plugged back in since booting.
   467 <P>
   468 	An MCI error when playing the last track on a CD-ROM has been fixed.
   469 <P>
   470 	OpenWatcom projects for building SDL have been provided by Marc Peter.
   471 </BLOCKQUOTE>
   473 <H3> Mac OS X Notes </H3>
   476 <P>
   477 	SDL now supports building Universal binaries, both through Xcode projects and when using configure/make.  See README.MacOSX in the SDL source archive for details.
   478 <P>
   479 	The X11 video driver with GLX support can be built on Mac OS X, if the X11 development SDK is installed.
   480 <P>
   481 	Transitions between fullscreen resolutions and windowed mode now use a much faster asynchronous fade to hide desktop flicker.
   482 <P>
   483 	Icons set with SDL_WM_SetIcon() now have the proper colors on Intel Macs.
   484 </BLOCKQUOTE>
   486 <H3> OS/2 Notes </H3>
   489 <P>
   490 	Projects for building SDL on OS/2 with OpenWatcom have been contributed by Doodle.  See the file README.OS2 in the SDL source distribution for details.
   491 </BLOCKQUOTE>
   493 <IMG SRC="docs/images/rainbow.gif" ALT="[separator]" WIDTH="100%">
   495 </BODY>
   496 </HTML>