diff src/SDL_compat.c @ 3025:54fac87e1f34

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.
author Sam Lantinga <slouken@libsdl.org>
date Mon, 12 Jan 2009 06:19:05 +0000
parents e4a469d6ddab
children 1c4a059966bd
line wrap: on
line diff
--- a/src/SDL_compat.c	Sun Jan 11 23:56:19 2009 +0000
+++ b/src/SDL_compat.c	Mon Jan 12 06:19:05 2009 +0000
@@ -376,6 +376,26 @@
     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_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 @@
 
     ClearVideoSurface();
 
+    SetupScreenSaver();
+
     /* We're finally done! */
     return SDL_PublicSurface;
 }