Disable the screensaver in DGA mode, which is even more important than X11...
authorSam Lantinga <slouken@libsdl.org>
Mon, 08 May 2006 06:54:20 +0000
changeset 178445669d4efd02
parent 1783 c546353b1ad4
child 1785 dcec47a019e2
Disable the screensaver in DGA mode, which is even more important than X11...
src/video/dga/SDL_dgavideo.c
src/video/dga/SDL_dgavideo.h
src/video/x11/SDL_x11events.c
src/video/x11/SDL_x11events_c.h
src/video/x11/SDL_x11video.c
     1.1 --- a/src/video/dga/SDL_dgavideo.c	Mon May 08 06:38:13 2006 +0000
     1.2 +++ b/src/video/dga/SDL_dgavideo.c	Mon May 08 06:54:20 2006 +0000
     1.3 @@ -41,6 +41,11 @@
     1.4  /* get function pointers... */
     1.5  #include "../x11/SDL_x11dyn.h"
     1.6  
     1.7 +/* Heheh we're using X11 event code */
     1.8 +extern void X11_SaveScreenSaver(Display *display, int *saved_timeout, BOOL *dpms);
     1.9 +extern void X11_DisableScreenSaver(Display *display);
    1.10 +extern void X11_RestoreScreenSaver(Display *display, int saved_timeout, BOOL dpms);
    1.11 +
    1.12  /* Initialization/Query functions */
    1.13  static int DGA_VideoInit(_THIS, SDL_PixelFormat *vformat);
    1.14  static SDL_Rect **DGA_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
    1.15 @@ -387,6 +392,10 @@
    1.16  		return(-1);
    1.17  	}
    1.18  
    1.19 +	/* Save DPMS and screensaver settings */
    1.20 +	X11_SaveScreenSaver(DGA_Display, &screensaver_timeout, &dpms_enabled);
    1.21 +	X11_DisableScreenSaver(DGA_Display);
    1.22 +
    1.23  	/* Query for the list of available video modes */
    1.24  	modes = SDL_NAME(XDGAQueryModes)(DGA_Display, DGA_Screen, &num_modes);
    1.25  	SDL_qsort(modes, num_modes, sizeof *modes, cmpmodes);
    1.26 @@ -1048,7 +1057,6 @@
    1.27  		}
    1.28  #endif /* LOCK_DGA_DISPLAY */
    1.29  
    1.30 -
    1.31  		/* Clean up defined video modes */
    1.32  		for ( i=0; i<NUM_MODELISTS; ++i ) {
    1.33  			if ( SDL_modelist[i] != NULL ) {
    1.34 @@ -1063,6 +1071,9 @@
    1.35  		/* Clean up the memory bucket list */
    1.36  		DGA_FreeHWSurfaces(this);
    1.37  
    1.38 +		/* Restore DPMS and screensaver settings */
    1.39 +		X11_RestoreScreenSaver(DGA_Display, screensaver_timeout, dpms_enabled);
    1.40 +
    1.41  		/* Close up the display */
    1.42  		XCloseDisplay(DGA_Display);
    1.43  	}
     2.1 --- a/src/video/dga/SDL_dgavideo.h	Mon May 08 06:38:13 2006 +0000
     2.2 +++ b/src/video/dga/SDL_dgavideo.h	Mon May 08 06:54:20 2006 +0000
     2.3 @@ -30,6 +30,10 @@
     2.4  #include "SDL_mutex.h"
     2.5  #include "../SDL_sysvideo.h"
     2.6  
     2.7 +#if SDL_VIDEO_DRIVER_X11_DPMS
     2.8 +#include <X11/extensions/dpms.h>
     2.9 +#endif
    2.10 +
    2.11  /* Hidden "this" pointer for the video functions */
    2.12  #define _THIS	SDL_VideoDevice *this
    2.13  
    2.14 @@ -86,6 +90,12 @@
    2.15  #ifdef LOCK_DGA_DISPLAY
    2.16  	SDL_mutex *event_lock;
    2.17  #endif
    2.18 +
    2.19 +	/* Screensaver settings */
    2.20 +	int screensaver_timeout;
    2.21 +#if SDL_VIDEO_DRIVER_X11_DPMS
    2.22 +	BOOL dpms_enabled;
    2.23 +#endif
    2.24  };
    2.25  /* Old variable names */
    2.26  #define DGA_Display		(this->hidden->DGA_Display)
    2.27 @@ -107,5 +117,7 @@
    2.28  #define hw_lock			(this->hidden->hw_lock)
    2.29  #define DGA_event_base		(this->hidden->event_base)
    2.30  #define event_lock		(this->hidden->event_lock)
    2.31 +#define screensaver_timeout	(this->hidden->screensaver_timeout)
    2.32 +#define dpms_enabled		(this->hidden->dpms_enabled)
    2.33  
    2.34  #endif /* _SDL_dgavideo_h */
     3.1 --- a/src/video/x11/SDL_x11events.c	Mon May 08 06:38:13 2006 +0000
     3.2 +++ b/src/video/x11/SDL_x11events.c	Mon May 08 06:54:20 2006 +0000
     3.3 @@ -1118,53 +1118,53 @@
     3.4  	X11_InitKeymap();
     3.5  }
     3.6  
     3.7 -void X11_SaveScreenSaver(_THIS)
     3.8 +void X11_SaveScreenSaver(Display *display, int *saved_timeout, BOOL *dpms)
     3.9  {
    3.10  	int timeout, interval, prefer_blank, allow_exp;
    3.11 -	XGetScreenSaver(SDL_Display, &timeout, &interval, &prefer_blank, &allow_exp);
    3.12 -	screensaver_timeout = timeout;
    3.13 +	XGetScreenSaver(display, &timeout, &interval, &prefer_blank, &allow_exp);
    3.14 +	*saved_timeout = timeout;
    3.15  
    3.16  #if SDL_VIDEO_DRIVER_X11_DPMS
    3.17  	if ( SDL_X11_HAVE_DPMS ) {
    3.18  		int dummy;
    3.19 -	  	if ( DPMSQueryExtension(SDL_Display, &dummy, &dummy) ) {
    3.20 +	  	if ( DPMSQueryExtension(display, &dummy, &dummy) ) {
    3.21  			CARD16 state;
    3.22 -			DPMSInfo(SDL_Display, &state, &dpms_enabled);
    3.23 +			DPMSInfo(display, &state, dpms);
    3.24  		}
    3.25  	}
    3.26  #endif /* SDL_VIDEO_DRIVER_X11_DPMS */
    3.27  }
    3.28  
    3.29 -void X11_DisableScreenSaver(_THIS)
    3.30 +void X11_DisableScreenSaver(Display *display)
    3.31  {
    3.32  	int timeout, interval, prefer_blank, allow_exp;
    3.33 -	XGetScreenSaver(SDL_Display, &timeout, &interval, &prefer_blank, &allow_exp);
    3.34 +	XGetScreenSaver(display, &timeout, &interval, &prefer_blank, &allow_exp);
    3.35  	timeout = 0;
    3.36 -	XSetScreenSaver(SDL_Display, timeout, interval, prefer_blank, allow_exp);
    3.37 +	XSetScreenSaver(display, timeout, interval, prefer_blank, allow_exp);
    3.38  
    3.39  #if SDL_VIDEO_DRIVER_X11_DPMS
    3.40  	if ( SDL_X11_HAVE_DPMS ) {
    3.41  		int dummy;
    3.42 -	  	if ( DPMSQueryExtension(SDL_Display, &dummy, &dummy) ) {
    3.43 -			DPMSDisable(SDL_Display);
    3.44 +	  	if ( DPMSQueryExtension(display, &dummy, &dummy) ) {
    3.45 +			DPMSDisable(display);
    3.46  		}
    3.47  	}
    3.48  #endif /* SDL_VIDEO_DRIVER_X11_DPMS */
    3.49  }
    3.50  
    3.51 -void X11_RestoreScreenSaver(_THIS)
    3.52 +void X11_RestoreScreenSaver(Display *display, int saved_timeout, BOOL dpms)
    3.53  {
    3.54  	int timeout, interval, prefer_blank, allow_exp;
    3.55 -	XGetScreenSaver(SDL_Display, &timeout, &interval, &prefer_blank, &allow_exp);
    3.56 -	timeout = screensaver_timeout;
    3.57 -	XSetScreenSaver(SDL_Display, timeout, interval, prefer_blank, allow_exp);
    3.58 +	XGetScreenSaver(display, &timeout, &interval, &prefer_blank, &allow_exp);
    3.59 +	timeout = saved_timeout;
    3.60 +	XSetScreenSaver(display, timeout, interval, prefer_blank, allow_exp);
    3.61  
    3.62  #if SDL_VIDEO_DRIVER_X11_DPMS
    3.63  	if ( SDL_X11_HAVE_DPMS ) {
    3.64  		int dummy;
    3.65 -	  	if ( DPMSQueryExtension(SDL_Display, &dummy, &dummy) ) {
    3.66 -			if ( dpms_enabled ) {
    3.67 -				DPMSEnable(SDL_Display);
    3.68 +	  	if ( DPMSQueryExtension(display, &dummy, &dummy) ) {
    3.69 +			if ( dpms ) {
    3.70 +				DPMSEnable(display);
    3.71  			}
    3.72  		}
    3.73  	}
     4.1 --- a/src/video/x11/SDL_x11events_c.h	Mon May 08 06:38:13 2006 +0000
     4.2 +++ b/src/video/x11/SDL_x11events_c.h	Mon May 08 06:54:20 2006 +0000
     4.3 @@ -28,6 +28,6 @@
     4.4  extern void X11_PumpEvents(_THIS);
     4.5  extern void X11_SetKeyboardState(Display *display, const char *key_vec);
     4.6  
     4.7 -extern void X11_SaveScreenSaver(_THIS);
     4.8 -extern void X11_DisableScreenSaver(_THIS);
     4.9 -extern void X11_RestoreScreenSaver(_THIS);
    4.10 +extern void X11_SaveScreenSaver(Display *display, int *saved_timeout, BOOL *dpms);
    4.11 +extern void X11_DisableScreenSaver(Display *display);
    4.12 +extern void X11_RestoreScreenSaver(Display *display, int saved_timeout, BOOL dpms);
     5.1 --- a/src/video/x11/SDL_x11video.c	Mon May 08 06:38:13 2006 +0000
     5.2 +++ b/src/video/x11/SDL_x11video.c	Mon May 08 06:54:20 2006 +0000
     5.3 @@ -545,8 +545,8 @@
     5.4  	X11_SaveVidModeGamma(this);
     5.5  
     5.6  	/* Save DPMS and screensaver settings */
     5.7 -	X11_SaveScreenSaver(this);
     5.8 -	X11_DisableScreenSaver(this);
     5.9 +	X11_SaveScreenSaver(SDL_Display, &screensaver_timeout, &dpms_enabled);
    5.10 +	X11_DisableScreenSaver(SDL_Display);
    5.11  
    5.12  	/* See if we have been passed a window to use */
    5.13  	SDL_windowid = SDL_getenv("SDL_WINDOWID");
    5.14 @@ -1375,7 +1375,7 @@
    5.15  		}
    5.16  
    5.17  		/* Restore DPMS and screensaver settings */
    5.18 -		X11_RestoreScreenSaver(this);
    5.19 +		X11_RestoreScreenSaver(SDL_Display, screensaver_timeout, dpms_enabled);
    5.20  
    5.21  		/* Free that blank cursor */
    5.22  		if ( SDL_BlankCursor != NULL ) {