# HG changeset patch # User Ryan C. Gordon # Date 1182888160 0 # Node ID b0d021cf41b634e2233908966765697400c7a847 # Parent 5368d56af4da06a57955bc8863b7ebacb5d603e4 windib target can now control screensaver with SDL_VIDEO_ALLOW_SCREENSAVER. Fixes Bugzilla #415. diff -r 5368d56af4da -r b0d021cf41b6 src/video/windib/SDL_dibevents.c --- a/src/video/windib/SDL_dibevents.c Tue Jun 26 00:57:09 2007 +0000 +++ b/src/video/windib/SDL_dibevents.c Tue Jun 26 20:02:40 2007 +0000 @@ -225,9 +225,14 @@ #if defined(SC_SCREENSAVE) && defined(SC_MONITORPOWER) case WM_SYSCOMMAND: { - if ((wParam&0xFFF0)==SC_SCREENSAVE || - (wParam&0xFFF0)==SC_MONITORPOWER) + const DWORD val = (DWORD) (wParam & 0xFFF0); + if ((val == SC_SCREENSAVE) || (val == SC_MONITORPOWER)) { + if (!this->hidden->allow_screensaver) { + /* Note that this doesn't stop anything on Vista + if the screensaver has a password. */ return(0); + } + } } /* Fall through to default processing */ #endif /* SC_SCREENSAVE && SC_MONITORPOWER */ diff -r 5368d56af4da -r b0d021cf41b6 src/video/windib/SDL_dibvideo.c --- a/src/video/windib/SDL_dibvideo.c Tue Jun 26 00:57:09 2007 +0000 +++ b/src/video/windib/SDL_dibvideo.c Tue Jun 26 20:02:40 2007 +0000 @@ -282,6 +282,7 @@ int DIB_VideoInit(_THIS, SDL_PixelFormat *vformat) { + const char *env = NULL; #ifndef NO_CHANGEDISPLAYSETTINGS int i; DEVMODE settings; @@ -380,6 +381,10 @@ this->hidden->origRotation = -1; #endif + /* Allow environment override of screensaver disable. */ + env = SDL_getenv("SDL_VIDEO_ALLOW_SCREENSAVER"); + this->hidden->allow_screensaver = ( (env && SDL_atoi(env)) ? 1 : 0 ); + /* We're done! */ return(0); } diff -r 5368d56af4da -r b0d021cf41b6 src/video/windib/SDL_dibvideo.h --- a/src/video/windib/SDL_dibvideo.h Tue Jun 26 00:57:09 2007 +0000 +++ b/src/video/windib/SDL_dibvideo.h Tue Jun 26 20:02:40 2007 +0000 @@ -41,6 +41,8 @@ HBITMAP screen_bmp; HPALETTE screen_pal; + int allow_screensaver; + #define NUM_MODELISTS 4 /* 8, 16, 24, and 32 bits-per-pixel */ int SDL_nummodes[NUM_MODELISTS]; SDL_Rect **SDL_modelist[NUM_MODELISTS];