Added an API to enable/disable the screen saver.

The screensaver is disabled by default when using SDL 1.2 compatibility.
Use the new XScreenSaver extension, removed unused DPMS extension.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403487
This commit is contained in:
Sam Lantinga 2009-01-12 06:19:05 +00:00
parent 4bb83c1f39
commit 4ca3bd3da1
16 changed files with 183 additions and 146 deletions

View file

@ -376,6 +376,26 @@ ClearVideoSurface()
SDL_UpdateRect(SDL_PublicSurface, 0, 0, 0, 0);
}
static void
SetupScreenSaver()
{
const char *env;
SDL_bool allow_screensaver;
/* Allow environment override of screensaver disable */
env = SDL_getenv("SDL_VIDEO_ALLOW_SCREENSAVER");
if (env) {
allow_screensaver = SDL_atoi(env) ? SDL_TRUE : SDL_FALSE;
} else {
allow_screensaver = SDL_FALSE;
}
if (allow_screensaver) {
SDL_EnableScreenSaver();
} else {
SDL_DisableScreenSaver();
}
}
int
SDL_ResizeVideoMode(int width, int height, int bpp, Uint32 flags)
{
@ -456,6 +476,7 @@ SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags)
{
SDL_DisplayMode desktop_mode;
SDL_DisplayMode mode;
const char *env;
int window_x = SDL_WINDOWPOS_UNDEFINED;
int window_y = SDL_WINDOWPOS_UNDEFINED;
Uint32 window_flags;
@ -679,6 +700,8 @@ SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags)
ClearVideoSurface();
SetupScreenSaver();
/* We're finally done! */
return SDL_PublicSurface;
}