Skip to content

Commit

Permalink
windib target can now control screensaver with SDL_VIDEO_ALLOW_SCREEN…
Browse files Browse the repository at this point in the history
…SAVER.

  Fixes Bugzilla #415.
  • Loading branch information
icculus committed Jun 26, 2007
1 parent 7f96ad3 commit d488381
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/video/windib/SDL_dibevents.c
Expand Up @@ -225,9 +225,14 @@ LRESULT DIB_HandleMessage(_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar

#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 */
Expand Down
5 changes: 5 additions & 0 deletions src/video/windib/SDL_dibvideo.c
Expand Up @@ -282,6 +282,7 @@ static HPALETTE DIB_CreatePalette(int bpp)

int DIB_VideoInit(_THIS, SDL_PixelFormat *vformat)
{
const char *env = NULL;
#ifndef NO_CHANGEDISPLAYSETTINGS
int i;
DEVMODE settings;
Expand Down Expand Up @@ -380,6 +381,10 @@ int DIB_VideoInit(_THIS, SDL_PixelFormat *vformat)
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);
}
Expand Down
2 changes: 2 additions & 0 deletions src/video/windib/SDL_dibvideo.h
Expand Up @@ -41,6 +41,8 @@ struct SDL_PrivateVideoData {
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];
Expand Down

0 comments on commit d488381

Please sign in to comment.