Mercurial > sdl-ios-xcode
changeset 1784:45669d4efd02
Disable the screensaver in DGA mode, which is even more important than X11...
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 08 May 2006 06:54:20 +0000 |
parents | c546353b1ad4 |
children | dcec47a019e2 |
files | 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 |
diffstat | 5 files changed, 47 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/src/video/dga/SDL_dgavideo.c Mon May 08 06:38:13 2006 +0000 +++ b/src/video/dga/SDL_dgavideo.c Mon May 08 06:54:20 2006 +0000 @@ -41,6 +41,11 @@ /* get function pointers... */ #include "../x11/SDL_x11dyn.h" +/* Heheh we're using X11 event code */ +extern void X11_SaveScreenSaver(Display *display, int *saved_timeout, BOOL *dpms); +extern void X11_DisableScreenSaver(Display *display); +extern void X11_RestoreScreenSaver(Display *display, int saved_timeout, BOOL dpms); + /* Initialization/Query functions */ static int DGA_VideoInit(_THIS, SDL_PixelFormat *vformat); static SDL_Rect **DGA_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags); @@ -387,6 +392,10 @@ return(-1); } + /* Save DPMS and screensaver settings */ + X11_SaveScreenSaver(DGA_Display, &screensaver_timeout, &dpms_enabled); + X11_DisableScreenSaver(DGA_Display); + /* Query for the list of available video modes */ modes = SDL_NAME(XDGAQueryModes)(DGA_Display, DGA_Screen, &num_modes); SDL_qsort(modes, num_modes, sizeof *modes, cmpmodes); @@ -1048,7 +1057,6 @@ } #endif /* LOCK_DGA_DISPLAY */ - /* Clean up defined video modes */ for ( i=0; i<NUM_MODELISTS; ++i ) { if ( SDL_modelist[i] != NULL ) { @@ -1063,6 +1071,9 @@ /* Clean up the memory bucket list */ DGA_FreeHWSurfaces(this); + /* Restore DPMS and screensaver settings */ + X11_RestoreScreenSaver(DGA_Display, screensaver_timeout, dpms_enabled); + /* Close up the display */ XCloseDisplay(DGA_Display); }
--- a/src/video/dga/SDL_dgavideo.h Mon May 08 06:38:13 2006 +0000 +++ b/src/video/dga/SDL_dgavideo.h Mon May 08 06:54:20 2006 +0000 @@ -30,6 +30,10 @@ #include "SDL_mutex.h" #include "../SDL_sysvideo.h" +#if SDL_VIDEO_DRIVER_X11_DPMS +#include <X11/extensions/dpms.h> +#endif + /* Hidden "this" pointer for the video functions */ #define _THIS SDL_VideoDevice *this @@ -86,6 +90,12 @@ #ifdef LOCK_DGA_DISPLAY SDL_mutex *event_lock; #endif + + /* Screensaver settings */ + int screensaver_timeout; +#if SDL_VIDEO_DRIVER_X11_DPMS + BOOL dpms_enabled; +#endif }; /* Old variable names */ #define DGA_Display (this->hidden->DGA_Display) @@ -107,5 +117,7 @@ #define hw_lock (this->hidden->hw_lock) #define DGA_event_base (this->hidden->event_base) #define event_lock (this->hidden->event_lock) +#define screensaver_timeout (this->hidden->screensaver_timeout) +#define dpms_enabled (this->hidden->dpms_enabled) #endif /* _SDL_dgavideo_h */
--- a/src/video/x11/SDL_x11events.c Mon May 08 06:38:13 2006 +0000 +++ b/src/video/x11/SDL_x11events.c Mon May 08 06:54:20 2006 +0000 @@ -1118,53 +1118,53 @@ X11_InitKeymap(); } -void X11_SaveScreenSaver(_THIS) +void X11_SaveScreenSaver(Display *display, int *saved_timeout, BOOL *dpms) { int timeout, interval, prefer_blank, allow_exp; - XGetScreenSaver(SDL_Display, &timeout, &interval, &prefer_blank, &allow_exp); - screensaver_timeout = timeout; + XGetScreenSaver(display, &timeout, &interval, &prefer_blank, &allow_exp); + *saved_timeout = timeout; #if SDL_VIDEO_DRIVER_X11_DPMS if ( SDL_X11_HAVE_DPMS ) { int dummy; - if ( DPMSQueryExtension(SDL_Display, &dummy, &dummy) ) { + if ( DPMSQueryExtension(display, &dummy, &dummy) ) { CARD16 state; - DPMSInfo(SDL_Display, &state, &dpms_enabled); + DPMSInfo(display, &state, dpms); } } #endif /* SDL_VIDEO_DRIVER_X11_DPMS */ } -void X11_DisableScreenSaver(_THIS) +void X11_DisableScreenSaver(Display *display) { int timeout, interval, prefer_blank, allow_exp; - XGetScreenSaver(SDL_Display, &timeout, &interval, &prefer_blank, &allow_exp); + XGetScreenSaver(display, &timeout, &interval, &prefer_blank, &allow_exp); timeout = 0; - XSetScreenSaver(SDL_Display, timeout, interval, prefer_blank, allow_exp); + XSetScreenSaver(display, timeout, interval, prefer_blank, allow_exp); #if SDL_VIDEO_DRIVER_X11_DPMS if ( SDL_X11_HAVE_DPMS ) { int dummy; - if ( DPMSQueryExtension(SDL_Display, &dummy, &dummy) ) { - DPMSDisable(SDL_Display); + if ( DPMSQueryExtension(display, &dummy, &dummy) ) { + DPMSDisable(display); } } #endif /* SDL_VIDEO_DRIVER_X11_DPMS */ } -void X11_RestoreScreenSaver(_THIS) +void X11_RestoreScreenSaver(Display *display, int saved_timeout, BOOL dpms) { int timeout, interval, prefer_blank, allow_exp; - XGetScreenSaver(SDL_Display, &timeout, &interval, &prefer_blank, &allow_exp); - timeout = screensaver_timeout; - XSetScreenSaver(SDL_Display, timeout, interval, prefer_blank, allow_exp); + XGetScreenSaver(display, &timeout, &interval, &prefer_blank, &allow_exp); + timeout = saved_timeout; + XSetScreenSaver(display, timeout, interval, prefer_blank, allow_exp); #if SDL_VIDEO_DRIVER_X11_DPMS if ( SDL_X11_HAVE_DPMS ) { int dummy; - if ( DPMSQueryExtension(SDL_Display, &dummy, &dummy) ) { - if ( dpms_enabled ) { - DPMSEnable(SDL_Display); + if ( DPMSQueryExtension(display, &dummy, &dummy) ) { + if ( dpms ) { + DPMSEnable(display); } } }
--- a/src/video/x11/SDL_x11events_c.h Mon May 08 06:38:13 2006 +0000 +++ b/src/video/x11/SDL_x11events_c.h Mon May 08 06:54:20 2006 +0000 @@ -28,6 +28,6 @@ extern void X11_PumpEvents(_THIS); extern void X11_SetKeyboardState(Display *display, const char *key_vec); -extern void X11_SaveScreenSaver(_THIS); -extern void X11_DisableScreenSaver(_THIS); -extern void X11_RestoreScreenSaver(_THIS); +extern void X11_SaveScreenSaver(Display *display, int *saved_timeout, BOOL *dpms); +extern void X11_DisableScreenSaver(Display *display); +extern void X11_RestoreScreenSaver(Display *display, int saved_timeout, BOOL dpms);
--- a/src/video/x11/SDL_x11video.c Mon May 08 06:38:13 2006 +0000 +++ b/src/video/x11/SDL_x11video.c Mon May 08 06:54:20 2006 +0000 @@ -545,8 +545,8 @@ X11_SaveVidModeGamma(this); /* Save DPMS and screensaver settings */ - X11_SaveScreenSaver(this); - X11_DisableScreenSaver(this); + X11_SaveScreenSaver(SDL_Display, &screensaver_timeout, &dpms_enabled); + X11_DisableScreenSaver(SDL_Display); /* See if we have been passed a window to use */ SDL_windowid = SDL_getenv("SDL_WINDOWID"); @@ -1375,7 +1375,7 @@ } /* Restore DPMS and screensaver settings */ - X11_RestoreScreenSaver(this); + X11_RestoreScreenSaver(SDL_Display, screensaver_timeout, dpms_enabled); /* Free that blank cursor */ if ( SDL_BlankCursor != NULL ) {