diff src/video/x11/SDL_x11events.c @ 1783:c546353b1ad4

Fixed bug #203 Disable screensaver and DPMS blanking while SDL app is running.
author Sam Lantinga <slouken@libsdl.org>
date Mon, 08 May 2006 06:38:13 +0000
parents db7e15a99cb3
children 45669d4efd02
line wrap: on
line diff
--- a/src/video/x11/SDL_x11events.c	Mon May 08 06:23:11 2006 +0000
+++ b/src/video/x11/SDL_x11events.c	Mon May 08 06:38:13 2006 +0000
@@ -1118,3 +1118,55 @@
 	X11_InitKeymap();
 }
 
+void X11_SaveScreenSaver(_THIS)
+{
+	int timeout, interval, prefer_blank, allow_exp;
+	XGetScreenSaver(SDL_Display, &timeout, &interval, &prefer_blank, &allow_exp);
+	screensaver_timeout = timeout;
+
+#if SDL_VIDEO_DRIVER_X11_DPMS
+	if ( SDL_X11_HAVE_DPMS ) {
+		int dummy;
+	  	if ( DPMSQueryExtension(SDL_Display, &dummy, &dummy) ) {
+			CARD16 state;
+			DPMSInfo(SDL_Display, &state, &dpms_enabled);
+		}
+	}
+#endif /* SDL_VIDEO_DRIVER_X11_DPMS */
+}
+
+void X11_DisableScreenSaver(_THIS)
+{
+	int timeout, interval, prefer_blank, allow_exp;
+	XGetScreenSaver(SDL_Display, &timeout, &interval, &prefer_blank, &allow_exp);
+	timeout = 0;
+	XSetScreenSaver(SDL_Display, timeout, interval, prefer_blank, allow_exp);
+
+#if SDL_VIDEO_DRIVER_X11_DPMS
+	if ( SDL_X11_HAVE_DPMS ) {
+		int dummy;
+	  	if ( DPMSQueryExtension(SDL_Display, &dummy, &dummy) ) {
+			DPMSDisable(SDL_Display);
+		}
+	}
+#endif /* SDL_VIDEO_DRIVER_X11_DPMS */
+}
+
+void X11_RestoreScreenSaver(_THIS)
+{
+	int timeout, interval, prefer_blank, allow_exp;
+	XGetScreenSaver(SDL_Display, &timeout, &interval, &prefer_blank, &allow_exp);
+	timeout = screensaver_timeout;
+	XSetScreenSaver(SDL_Display, timeout, interval, prefer_blank, allow_exp);
+
+#if SDL_VIDEO_DRIVER_X11_DPMS
+	if ( SDL_X11_HAVE_DPMS ) {
+		int dummy;
+	  	if ( DPMSQueryExtension(SDL_Display, &dummy, &dummy) ) {
+			if ( dpms_enabled ) {
+				DPMSEnable(SDL_Display);
+			}
+		}
+	}
+#endif /* SDL_VIDEO_DRIVER_X11_DPMS */
+}