windib target can now control screensaver with SDL_VIDEO_ALLOW_SCREENSAVER. SDL-1.2
authorRyan C. Gordon <icculus@icculus.org>
Tue, 26 Jun 2007 20:02:40 +0000
branchSDL-1.2
changeset 3981b0d021cf41b6
parent 3980 5368d56af4da
child 3982 0a0f8cccc77c
windib target can now control screensaver with SDL_VIDEO_ALLOW_SCREENSAVER.

Fixes Bugzilla #415.
src/video/windib/SDL_dibevents.c
src/video/windib/SDL_dibvideo.c
src/video/windib/SDL_dibvideo.h
     1.1 --- a/src/video/windib/SDL_dibevents.c	Tue Jun 26 00:57:09 2007 +0000
     1.2 +++ b/src/video/windib/SDL_dibevents.c	Tue Jun 26 20:02:40 2007 +0000
     1.3 @@ -225,9 +225,14 @@
     1.4  
     1.5  #if defined(SC_SCREENSAVE) && defined(SC_MONITORPOWER)
     1.6  		case WM_SYSCOMMAND: {
     1.7 -			if ((wParam&0xFFF0)==SC_SCREENSAVE ||
     1.8 -				(wParam&0xFFF0)==SC_MONITORPOWER)
     1.9 +			const DWORD val = (DWORD) (wParam & 0xFFF0);
    1.10 +			if ((val == SC_SCREENSAVE) || (val == SC_MONITORPOWER)) {
    1.11 +				if (!this->hidden->allow_screensaver) {
    1.12 +					/* Note that this doesn't stop anything on Vista
    1.13 +					   if the screensaver has a password. */
    1.14  					return(0);
    1.15 +				}
    1.16 +			}
    1.17  		}
    1.18  		/* Fall through to default processing */
    1.19  #endif /* SC_SCREENSAVE && SC_MONITORPOWER */
     2.1 --- a/src/video/windib/SDL_dibvideo.c	Tue Jun 26 00:57:09 2007 +0000
     2.2 +++ b/src/video/windib/SDL_dibvideo.c	Tue Jun 26 20:02:40 2007 +0000
     2.3 @@ -282,6 +282,7 @@
     2.4  
     2.5  int DIB_VideoInit(_THIS, SDL_PixelFormat *vformat)
     2.6  {
     2.7 +	const char *env = NULL;
     2.8  #ifndef NO_CHANGEDISPLAYSETTINGS
     2.9  	int i;
    2.10  	DEVMODE settings;
    2.11 @@ -380,6 +381,10 @@
    2.12  	this->hidden->origRotation = -1;
    2.13  #endif
    2.14  
    2.15 +	/* Allow environment override of screensaver disable. */
    2.16 +	env = SDL_getenv("SDL_VIDEO_ALLOW_SCREENSAVER");
    2.17 +	this->hidden->allow_screensaver = ( (env && SDL_atoi(env)) ? 1 : 0 );
    2.18 +
    2.19  	/* We're done! */
    2.20  	return(0);
    2.21  }
     3.1 --- a/src/video/windib/SDL_dibvideo.h	Tue Jun 26 00:57:09 2007 +0000
     3.2 +++ b/src/video/windib/SDL_dibvideo.h	Tue Jun 26 20:02:40 2007 +0000
     3.3 @@ -41,6 +41,8 @@
     3.4      HBITMAP screen_bmp;
     3.5      HPALETTE screen_pal;
     3.6  
     3.7 +    int allow_screensaver;
     3.8 +
     3.9  #define NUM_MODELISTS	4		/* 8, 16, 24, and 32 bits-per-pixel */
    3.10      int SDL_nummodes[NUM_MODELISTS];
    3.11      SDL_Rect **SDL_modelist[NUM_MODELISTS];