1.1 --- a/include/SDL_hints.h Thu Feb 27 22:06:41 2014 -0500
1.2 +++ b/include/SDL_hints.h Fri Feb 28 14:23:41 2014 -0800
1.3 @@ -129,6 +129,17 @@
1.4 #define SDL_HINT_RENDER_VSYNC "SDL_RENDER_VSYNC"
1.5
1.6 /**
1.7 + * \brief A variable controlling whether the screensaver is enabled.
1.8 + *
1.9 + * This variable can be set to the following values:
1.10 + * "0" - Disable screensaver
1.11 + * "1" - Enable screensaver
1.12 + *
1.13 + * By default SDL will disable the screensaver.
1.14 + */
1.15 +#define SDL_HINT_VIDEO_ALLOW_SCREENSAVER "SDL_VIDEO_ALLOW_SCREENSAVER"
1.16 +
1.17 +/**
1.18 * \brief A variable controlling whether the X11 VidMode extension should be used.
1.19 *
1.20 * This variable can be set to the following values:
2.1 --- a/src/video/SDL_video.c Thu Feb 27 22:06:41 2014 -0500
2.2 +++ b/src/video/SDL_video.c Fri Feb 28 14:23:41 2014 -0800
2.3 @@ -421,8 +421,10 @@
2.4 SDL_VideoInit(const char *driver_name)
2.5 {
2.6 SDL_VideoDevice *video;
2.7 + const char *hint;
2.8 int index;
2.9 int i;
2.10 + SDL_bool allow_screensaver;
2.11
2.12 /* Check to make sure we don't overwrite '_this' */
2.13 if (_this != NULL) {
2.14 @@ -510,7 +512,15 @@
2.15 joystick, or passively watching a movie. Things that use SDL but
2.16 function more like a normal desktop app should explicitly reenable the
2.17 screensaver. */
2.18 - SDL_DisableScreenSaver();
2.19 + hint = SDL_GetHint(SDL_HINT_VIDEO_ALLOW_SCREENSAVER);
2.20 + if (hint) {
2.21 + allow_screensaver = SDL_atoi(hint) ? SDL_TRUE : SDL_FALSE;
2.22 + } else {
2.23 + allow_screensaver = SDL_FALSE;
2.24 + }
2.25 + if (!allow_screensaver) {
2.26 + SDL_DisableScreenSaver();
2.27 + }
2.28
2.29 /* If we don't use a screen keyboard, turn on text input by default,
2.30 otherwise programs that expect to get text events without enabling