Index: src/video/quartz/SDL_QuartzVideo.h =================================================================== --- src/video/quartz/SDL_QuartzVideo.h (revision 2990) +++ src/video/quartz/SDL_QuartzVideo.h (working copy) @@ -80,6 +80,7 @@ /* Main driver structure to store required state information */ typedef struct SDL_PrivateVideoData { + BOOL allow_screensaver; /* 0 == disable screensaver */ CGDirectDisplayID display; /* 0 == main display (only support single display) */ CFDictionaryRef mode; /* current mode of the display */ CFDictionaryRef save_mode; /* original mode of the display */ @@ -127,6 +128,7 @@ #define display_id (this->hidden->display) #define mode (this->hidden->mode) #define save_mode (this->hidden->save_mode) +#define allow_screensaver (this->hidden->allow_screensaver) #define mode_list (this->hidden->mode_list) #define palette (this->hidden->palette) #define gl_context (this->hidden->gl_context) Index: src/video/quartz/SDL_QuartzEvents.m =================================================================== --- src/video/quartz/SDL_QuartzEvents.m (revision 2990) +++ src/video/quartz/SDL_QuartzEvents.m (working copy) @@ -734,11 +734,13 @@ return; /* don't do anything if there's no screen surface. */ /* Update activity every five seconds to prevent screensaver. --ryan. */ - nowTicks = SDL_GetTicks(); - if ((nowTicks - screensaverTicks) > 5000) - { - UpdateSystemActivity(UsrActivity); - screensaverTicks = nowTicks; + if (!allow_screensaver) { + nowTicks = SDL_GetTicks(); + if ((nowTicks - screensaverTicks) > 5000) + { + UpdateSystemActivity(UsrActivity); + screensaverTicks = nowTicks; + } } pool = [ [ NSAutoreleasePool alloc ] init ]; Index: src/video/quartz/SDL_QuartzVideo.m =================================================================== --- src/video/quartz/SDL_QuartzVideo.m (revision 2990) +++ src/video/quartz/SDL_QuartzVideo.m (working copy) @@ -169,12 +169,17 @@ static int QZ_VideoInit (_THIS, SDL_PixelFormat *video_format) { + const char *env = NULL; + /* Initialize the video settings; this data persists between mode switches */ display_id = kCGDirectMainDisplay; save_mode = CGDisplayCurrentMode (display_id); mode_list = CGDisplayAvailableModes (display_id); palette = CGPaletteCreateDefaultColorPalette (); + env = SDL_getenv("SDL_VIDEO_ALLOW_SCREENSAVER"); + allow_screensaver = ( env && SDL_atoi(env) ) ? YES : NO; + /* Gather some information that is useful to know about the display */ CFNumberGetValue (CFDictionaryGetValue (save_mode, kCGDisplayBitsPerPixel), kCFNumberSInt32Type, &device_bpp); Index: src/video/x11/SDL_x11events.c =================================================================== --- src/video/x11/SDL_x11events.c (revision 2990) +++ src/video/x11/SDL_x11events.c (working copy) @@ -1138,7 +1138,15 @@ void X11_DisableScreenSaver(Display *display) { + const char *env = NULL; int timeout, interval, prefer_blank, allow_exp; + + /* Allow environment override */ + env = SDL_getenv("SDL_VIDEO_ALLOW_SCREENSAVER"); + if ( env && SDL_atoi(env) ) { + return; + } + XGetScreenSaver(display, &timeout, &interval, &prefer_blank, &allow_exp); timeout = 0; XSetScreenSaver(display, timeout, interval, prefer_blank, allow_exp); @@ -1155,7 +1163,15 @@ void X11_RestoreScreenSaver(Display *display, int saved_timeout, BOOL dpms) { + const char *env = NULL; int timeout, interval, prefer_blank, allow_exp; + + /* Allow environment override */ + env = SDL_getenv("SDL_VIDEO_ALLOW_SCREENSAVER"); + if ( env && SDL_atoi(env) ) { + return; + } + XGetScreenSaver(display, &timeout, &interval, &prefer_blank, &allow_exp); timeout = saved_timeout; XSetScreenSaver(display, timeout, interval, prefer_blank, allow_exp);