include/SDL_config.h.in
author Sam Lantinga <slouken@libsdl.org>
Fri, 29 Feb 2008 13:55:44 +0000
branchSDL-1.2
changeset 4139 568c9b3c0167
parent 4109 cd2ab40f1219
child 4159 a1b03ba2fcd0
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,
[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.
     1 /*
     2     SDL - Simple DirectMedia Layer
     3     Copyright (C) 1997-2006 Sam Lantinga
     4 
     5     This library is free software; you can redistribute it and/or
     6     modify it under the terms of the GNU Lesser General Public
     7     License as published by the Free Software Foundation; either
     8     version 2.1 of the License, or (at your option) any later version.
     9 
    10     This library is distributed in the hope that it will be useful,
    11     but WITHOUT ANY WARRANTY; without even the implied warranty of
    12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    13     Lesser General Public License for more details.
    14 
    15     You should have received a copy of the GNU Lesser General Public
    16     License along with this library; if not, write to the Free Software
    17     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    18 
    19     Sam Lantinga
    20     slouken@libsdl.org
    21 */
    22 
    23 #ifndef _SDL_config_h
    24 #define _SDL_config_h
    25 
    26 /* This is a set of defines to configure the SDL features */
    27 
    28 /* General platform specific identifiers */
    29 #include "SDL_platform.h"
    30 
    31 /* Make sure that this isn't included by Visual C++ */
    32 #ifdef _MSC_VER
    33 #error You should copy include/SDL_config.h.default to include/SDL_config.h
    34 #endif
    35 
    36 /* C language features */
    37 #undef const
    38 #undef inline
    39 #undef volatile
    40 
    41 /* C datatypes */
    42 #undef size_t
    43 #undef int8_t
    44 #undef uint8_t
    45 #undef int16_t
    46 #undef uint16_t
    47 #undef int32_t
    48 #undef uint32_t
    49 #undef int64_t
    50 #undef uint64_t
    51 #undef uintptr_t
    52 #undef SDL_HAS_64BIT_TYPE
    53 
    54 /* Endianness */
    55 #undef SDL_BYTEORDER
    56 
    57 /* Comment this if you want to build without any C library requirements */
    58 #undef HAVE_LIBC
    59 #if HAVE_LIBC
    60 
    61 /* Useful headers */
    62 #undef HAVE_ALLOCA_H
    63 #undef HAVE_SYS_TYPES_H
    64 #undef HAVE_STDIO_H
    65 #undef STDC_HEADERS
    66 #undef HAVE_STDLIB_H
    67 #undef HAVE_STDARG_H
    68 #undef HAVE_MALLOC_H
    69 #undef HAVE_MEMORY_H
    70 #undef HAVE_STRING_H
    71 #undef HAVE_STRINGS_H
    72 #undef HAVE_INTTYPES_H
    73 #undef HAVE_STDINT_H
    74 #undef HAVE_CTYPE_H
    75 #undef HAVE_MATH_H
    76 #undef HAVE_ICONV_H
    77 #undef HAVE_SIGNAL_H
    78 #undef HAVE_ALTIVEC_H
    79 
    80 /* C library functions */
    81 #undef HAVE_MALLOC
    82 #undef HAVE_CALLOC
    83 #undef HAVE_REALLOC
    84 #undef HAVE_FREE
    85 #undef HAVE_ALLOCA
    86 #ifndef _WIN32 /* Don't use C runtime versions of these on Windows */
    87 #undef HAVE_GETENV
    88 #undef HAVE_PUTENV
    89 #undef HAVE_UNSETENV
    90 #endif
    91 #undef HAVE_QSORT
    92 #undef HAVE_ABS
    93 #undef HAVE_BCOPY
    94 #undef HAVE_MEMSET
    95 #undef HAVE_MEMCPY
    96 #undef HAVE_MEMMOVE
    97 #undef HAVE_MEMCMP
    98 #undef HAVE_STRLEN
    99 #undef HAVE_STRLCPY
   100 #undef HAVE_STRLCAT
   101 #undef HAVE_STRDUP
   102 #undef HAVE__STRREV
   103 #undef HAVE__STRUPR
   104 #undef HAVE__STRLWR
   105 #undef HAVE_INDEX
   106 #undef HAVE_RINDEX
   107 #undef HAVE_STRCHR
   108 #undef HAVE_STRRCHR
   109 #undef HAVE_STRSTR
   110 #undef HAVE_ITOA
   111 #undef HAVE__LTOA
   112 #undef HAVE__UITOA
   113 #undef HAVE__ULTOA
   114 #undef HAVE_STRTOL
   115 #undef HAVE_STRTOUL
   116 #undef HAVE__I64TOA
   117 #undef HAVE__UI64TOA
   118 #undef HAVE_STRTOLL
   119 #undef HAVE_STRTOULL
   120 #undef HAVE_STRTOD
   121 #undef HAVE_ATOI
   122 #undef HAVE_ATOF
   123 #undef HAVE_STRCMP
   124 #undef HAVE_STRNCMP
   125 #undef HAVE__STRICMP
   126 #undef HAVE_STRCASECMP
   127 #undef HAVE__STRNICMP
   128 #undef HAVE_STRNCASECMP
   129 #undef HAVE_SSCANF
   130 #undef HAVE_SNPRINTF
   131 #undef HAVE_VSNPRINTF
   132 #undef HAVE_ICONV
   133 #undef HAVE_SIGACTION
   134 #undef HAVE_SETJMP
   135 #undef HAVE_NANOSLEEP
   136 #undef HAVE_CLOCK_GETTIME
   137 #undef HAVE_DLVSYM
   138 #undef HAVE_GETPAGESIZE
   139 #undef HAVE_MPROTECT
   140 
   141 #else
   142 /* We may need some replacement for stdarg.h here */
   143 #include <stdarg.h>
   144 #endif /* HAVE_LIBC */
   145 
   146 /* Allow disabling of core subsystems */
   147 #undef SDL_AUDIO_DISABLED
   148 #undef SDL_CDROM_DISABLED
   149 #undef SDL_CPUINFO_DISABLED
   150 #undef SDL_EVENTS_DISABLED
   151 #undef SDL_FILE_DISABLED
   152 #undef SDL_JOYSTICK_DISABLED
   153 #undef SDL_LOADSO_DISABLED
   154 #undef SDL_THREADS_DISABLED
   155 #undef SDL_TIMERS_DISABLED
   156 #undef SDL_VIDEO_DISABLED
   157 
   158 /* Enable various audio drivers */
   159 #undef SDL_AUDIO_DRIVER_ALSA
   160 #undef SDL_AUDIO_DRIVER_ALSA_DYNAMIC
   161 #undef SDL_AUDIO_DRIVER_ARTS
   162 #undef SDL_AUDIO_DRIVER_ARTS_DYNAMIC
   163 #undef SDL_AUDIO_DRIVER_BAUDIO
   164 #undef SDL_AUDIO_DRIVER_BSD
   165 #undef SDL_AUDIO_DRIVER_COREAUDIO
   166 #undef SDL_AUDIO_DRIVER_DART
   167 #undef SDL_AUDIO_DRIVER_DC
   168 #undef SDL_AUDIO_DRIVER_DISK
   169 #undef SDL_AUDIO_DRIVER_DUMMY
   170 #undef SDL_AUDIO_DRIVER_DMEDIA
   171 #undef SDL_AUDIO_DRIVER_DSOUND
   172 #undef SDL_AUDIO_DRIVER_PULSE
   173 #undef SDL_AUDIO_DRIVER_PULSE_DYNAMIC
   174 #undef SDL_AUDIO_DRIVER_ESD
   175 #undef SDL_AUDIO_DRIVER_ESD_DYNAMIC
   176 #undef SDL_AUDIO_DRIVER_MINT
   177 #undef SDL_AUDIO_DRIVER_MMEAUDIO
   178 #undef SDL_AUDIO_DRIVER_NAS
   179 #undef SDL_AUDIO_DRIVER_OSS
   180 #undef SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H
   181 #undef SDL_AUDIO_DRIVER_PAUD
   182 #undef SDL_AUDIO_DRIVER_QNXNTO
   183 #undef SDL_AUDIO_DRIVER_SNDMGR
   184 #undef SDL_AUDIO_DRIVER_SUNAUDIO
   185 #undef SDL_AUDIO_DRIVER_WAVEOUT
   186 
   187 /* Enable various cdrom drivers */
   188 #undef SDL_CDROM_AIX
   189 #undef SDL_CDROM_BEOS
   190 #undef SDL_CDROM_BSDI
   191 #undef SDL_CDROM_DC
   192 #undef SDL_CDROM_DUMMY
   193 #undef SDL_CDROM_FREEBSD
   194 #undef SDL_CDROM_LINUX
   195 #undef SDL_CDROM_MACOS
   196 #undef SDL_CDROM_MACOSX
   197 #undef SDL_CDROM_MINT
   198 #undef SDL_CDROM_OPENBSD
   199 #undef SDL_CDROM_OS2
   200 #undef SDL_CDROM_OSF
   201 #undef SDL_CDROM_QNX
   202 #undef SDL_CDROM_WIN32
   203 
   204 /* Enable various input drivers */
   205 #undef SDL_INPUT_LINUXEV
   206 #undef SDL_INPUT_TSLIB
   207 #undef SDL_JOYSTICK_BEOS
   208 #undef SDL_JOYSTICK_DC
   209 #undef SDL_JOYSTICK_DUMMY
   210 #undef SDL_JOYSTICK_IOKIT
   211 #undef SDL_JOYSTICK_LINUX
   212 #undef SDL_JOYSTICK_MACOS
   213 #undef SDL_JOYSTICK_MINT
   214 #undef SDL_JOYSTICK_OS2
   215 #undef SDL_JOYSTICK_RISCOS
   216 #undef SDL_JOYSTICK_WINMM
   217 #undef SDL_JOYSTICK_USBHID
   218 #undef SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H
   219 
   220 /* Enable various shared object loading systems */
   221 #undef SDL_LOADSO_BEOS
   222 #undef SDL_LOADSO_DLCOMPAT
   223 #undef SDL_LOADSO_DLOPEN
   224 #undef SDL_LOADSO_DUMMY
   225 #undef SDL_LOADSO_LDG
   226 #undef SDL_LOADSO_MACOS
   227 #undef SDL_LOADSO_OS2
   228 #undef SDL_LOADSO_WIN32
   229 
   230 /* Enable various threading systems */
   231 #undef SDL_THREAD_BEOS
   232 #undef SDL_THREAD_DC
   233 #undef SDL_THREAD_OS2
   234 #undef SDL_THREAD_PTH
   235 #undef SDL_THREAD_PTHREAD
   236 #undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX
   237 #undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP
   238 #undef SDL_THREAD_SPROC
   239 #undef SDL_THREAD_WIN32
   240 
   241 /* Enable various timer systems */
   242 #undef SDL_TIMER_BEOS
   243 #undef SDL_TIMER_DC
   244 #undef SDL_TIMER_DUMMY
   245 #undef SDL_TIMER_MACOS
   246 #undef SDL_TIMER_MINT
   247 #undef SDL_TIMER_OS2
   248 #undef SDL_TIMER_RISCOS
   249 #undef SDL_TIMER_UNIX
   250 #undef SDL_TIMER_WIN32
   251 #undef SDL_TIMER_WINCE
   252 
   253 /* Enable various video drivers */
   254 #undef SDL_VIDEO_DRIVER_AALIB
   255 #undef SDL_VIDEO_DRIVER_BWINDOW
   256 #undef SDL_VIDEO_DRIVER_DC
   257 #undef SDL_VIDEO_DRIVER_DDRAW
   258 #undef SDL_VIDEO_DRIVER_DGA
   259 #undef SDL_VIDEO_DRIVER_DIRECTFB
   260 #undef SDL_VIDEO_DRIVER_DRAWSPROCKET
   261 #undef SDL_VIDEO_DRIVER_DUMMY
   262 #undef SDL_VIDEO_DRIVER_FBCON
   263 #undef SDL_VIDEO_DRIVER_GAPI
   264 #undef SDL_VIDEO_DRIVER_GEM
   265 #undef SDL_VIDEO_DRIVER_GGI
   266 #undef SDL_VIDEO_DRIVER_IPOD
   267 #undef SDL_VIDEO_DRIVER_NANOX
   268 #undef SDL_VIDEO_DRIVER_OS2FS
   269 #undef SDL_VIDEO_DRIVER_PHOTON
   270 #undef SDL_VIDEO_DRIVER_PICOGUI
   271 #undef SDL_VIDEO_DRIVER_PS2GS
   272 #undef SDL_VIDEO_DRIVER_QTOPIA
   273 #undef SDL_VIDEO_DRIVER_QUARTZ
   274 #undef SDL_VIDEO_DRIVER_RISCOS
   275 #undef SDL_VIDEO_DRIVER_SVGALIB
   276 #undef SDL_VIDEO_DRIVER_TOOLBOX
   277 #undef SDL_VIDEO_DRIVER_VGL
   278 #undef SDL_VIDEO_DRIVER_WINDIB
   279 #undef SDL_VIDEO_DRIVER_WSCONS
   280 #undef SDL_VIDEO_DRIVER_X11
   281 #undef SDL_VIDEO_DRIVER_X11_DGAMOUSE
   282 #undef SDL_VIDEO_DRIVER_X11_DYNAMIC
   283 #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT
   284 #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR
   285 #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER
   286 #undef SDL_VIDEO_DRIVER_X11_VIDMODE
   287 #undef SDL_VIDEO_DRIVER_X11_XINERAMA
   288 #undef SDL_VIDEO_DRIVER_X11_XME
   289 #undef SDL_VIDEO_DRIVER_X11_XRANDR
   290 #undef SDL_VIDEO_DRIVER_X11_XV
   291 #undef SDL_VIDEO_DRIVER_XBIOS
   292 
   293 /* Enable OpenGL support */
   294 #undef SDL_VIDEO_OPENGL
   295 #undef SDL_VIDEO_OPENGL_GLX
   296 #undef SDL_VIDEO_OPENGL_WGL
   297 #undef SDL_VIDEO_OPENGL_OSMESA
   298 #undef SDL_VIDEO_OPENGL_OSMESA_DYNAMIC
   299 
   300 /* Disable screensaver */
   301 #undef SDL_VIDEO_DISABLE_SCREENSAVER
   302 
   303 /* Enable assembly routines */
   304 #undef SDL_ASSEMBLY_ROUTINES
   305 #undef SDL_HERMES_BLITTERS
   306 #undef SDL_ALTIVEC_BLITTERS
   307 
   308 #endif /* _SDL_config_h */