From 83133e430252d167dcd298392d871b3aa95c27d3 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 29 Feb 2008 13:55:44 +0000 Subject: [PATCH] * Added configure option --enable-screensaver, to allow enabling the screensaver by default. * Use XResetScreenSaver() instead of disabling screensaver entirely. Full discussion summary from Erik on the SDL mailing list: Current behaviour ================= SDL changes the user's display power management settings without permission from the user and without telling the user. The interface that it uses to do so is DPMSDisable/DPMSEnable, which should only ever be used by configuration utilities like KControl, never by normal application programs, let alone by the libraries that they use. Using an interface that is not at all intended for what SDL tries to achieve means that it will not work as it should. Firstly, the power management is completely disabled during the whole lifetime of the SDL program, not only when it should be. Secondly, it makes SDL non-reentrant, meaning that things will break when multiple SDL programs are clients of the same X server simultaneously. Thirdly, no cleanup mechanism ensures that the setting is restored if the client does not do that (for example if it crashes). In addition to that, this interface is broken on xorg, [http://bugs.freedesktop.org/show_bug.cgi?id=13962], so what SDL tries to do does not work at all on that implementation of the X Window System. (The reason that the DPMSEnable works in KControl is that it calls DPMSSetTimeout immediately after, [http://websvn.kde.org/tags/KDE/3.5.9/kdebase/kcontrol/energy/energy.cpp?annotate=774532#l343]). The problems that the current behaviour causes ============================================== 1. Information leak. When the user is away, someone might see what the user has on the display when the user counts on the screensaver preventing this. This does not even require physical access to the workstation, it is enough to see it from a distance. 2. Draining battery. An SDL program that runs on a laptop will quickly drain the battery while the user is away. The system will soon shut down and require recharging before being usable again, while it should in fact have consumed very little energy if the user's settings would have been obeyed. 3. Wasting energy. Even if battery issues are not considered, energy as such is wasted. 4. Display wear. The display may be worn out. The problems that the current behaviour tries to solve ====================================================== 1. Preventing screensaver while playing movies. Many SDL applications are media players. They have reasons to prevent screensavers from being activated while a movie is being played. When a user clicks on the play button it can be interpreted as saying "play this movie, but do not turn off the display while playing it, because I will watch it even though I do not interact with the system". 2. Preventing screensaver when some input bypasses X. Sometimes SDL uses input from another source than the X server, so that the X server is bypassed. This obviously breaks the screensaver handling. SDL tries to work around that. 3. Preventing screensaver when all input bypasses X. There is something called Direct Graphics Access mode, where a program takes control of both the display and the input devices from the X server. This obviously means that the X server can not handle the screensaver alone, since screensaver handling depends on input handling. SDL does not do what it should to help the X server to handle the screensaver. Nor does SDL take care of screeensaver handling itself. SDL simply disables the screensaver completely. How the problems should be solved ================================= The correct way for an application program to prevent the screensaver under X is to call XResetScreenSaver. This was recently discovered and implemented by the mplayer developers, [http://svn.mplayerhq.hu/mplayer?view=rev&revision=25637]. SDL needs to wrap this in an API call (SDL_ResetScreenSaver) and implement it for the other video targets (if they do not have a corresponding call, SDL should do what it takes on that particular target, for example sending fake key events). 1. When a movie is played, the player should reset the screensaver when the animation is advanced to a new frame. The same applies to anything similar, like slideshows. 2. When the X server is handling input, it must handle all input (keyboards, mice, gamepads, ...). This is necessary, not only to be able to handle the screensaver, but also so that it can send the events to the correct (the currently active) client. If there is an input device that the X server can not handle for some reason (such as lack of Plug and Play capability), the program that handles the device as a workaround must simulate what would happen if the X server would have handled the device, by calling XResetScreenSaver when input is received from the device. 3. When the X server is not handling the input, it depends on the program that does to call XResetScreenSaver whenever an input event occurs. Alternatively the program must handle the screensaver countdown internally and call XActivateScreenSaver. --- configure.in | 20 +++---- docs.html | 39 ++++++++++++++ include/SDL_config.h.in | 4 +- include/SDL_config_macosx.h | 3 ++ include/SDL_config_win32.h | 3 ++ src/video/dga/SDL_dgaevents.c | 12 +++++ src/video/dga/SDL_dgavideo.c | 23 ++++---- src/video/dga/SDL_dgavideo.h | 11 ++-- src/video/quartz/SDL_QuartzEvents.m | 5 +- src/video/quartz/SDL_QuartzVideo.m | 11 +++- src/video/windib/SDL_dibevents.c | 2 +- src/video/windib/SDL_dibvideo.c | 10 +++- src/video/windib/SDL_dibvideo.h | 6 ++- src/video/x11/SDL_x11events.c | 74 ++++---------------------- src/video/x11/SDL_x11events_c.h | 4 -- src/video/x11/SDL_x11sym.h | 12 +---- src/video/x11/SDL_x11video.c | 19 +++---- src/video/x11/SDL_x11video.h | 12 ++--- src/video/xbios/SDL_xbios_centscreen.c | 2 + 19 files changed, 134 insertions(+), 138 deletions(-) diff --git a/configure.in b/configure.in index 287e22434..252bdbda4 100644 --- a/configure.in +++ b/configure.in @@ -1090,19 +1090,6 @@ AC_HELP_STRING([--enable-video-x11-xrandr], [enable X11 Xrandr extension for ful if test x$definitely_enable_video_x11_xrandr = xyes; then AC_DEFINE(SDL_VIDEO_DRIVER_X11_XRANDR) fi - AC_ARG_ENABLE(video-x11-dpms, -AC_HELP_STRING([--enable-video-x11-dpms], [enable X11 DPMS extension [[default=yes]]]), - , enable_video_x11_dpms=yes) - if test x$enable_video_x11_dpms = xyes; then - AC_CHECK_HEADER(X11/extensions/dpms.h, - have_dpms_h_hdr=yes, - have_dpms_h_hdr=no, - [#include - ]) - if test x$have_dpms_h_hdr = xyes; then - AC_DEFINE(SDL_VIDEO_DRIVER_X11_DPMS) - fi - fi fi fi } @@ -1673,6 +1660,13 @@ AC_HELP_STRING([--enable-osmesa-shared], [dynamically load OSMesa OpenGL support fi } +AC_ARG_ENABLE(screensaver, +AC_HELP_STRING([--enable-screensaver], [enable screensaver by default while any SDL application is running [[default=no]]]), + , enable_screensaver=no) +if test x$enable_screensaver = xno; then + AC_DEFINE(SDL_VIDEO_DISABLE_SCREENSAVER) +fi + dnl See if we can use the new unified event interface in Linux 2.4 CheckInputEvents() { diff --git a/docs.html b/docs.html index d2c50aaa4..7c7b4f2a5 100644 --- a/docs.html +++ b/docs.html @@ -14,6 +14,45 @@

API Documentation

+

SDL 1.2.14 Release Notes

+

+SDL 1.2.14 is a minor bug fix release. +

+ +

General Notes

+ +
+

+

+
+ +

Unix Notes

+ +
+

+ Added configure option --enable-screensaver, to allow enabling the screensaver by default. +

+

+ Use XResetScreenSaver() instead of disabling screensaver entirely. +

+
+ +

Windows Notes

+ +
+

+

+
+ +

Mac OS X Notes

+ +
+

+

+
+ +[separator] +

SDL 1.2.13 Release Notes

SDL 1.2.13 is a minor bug fix release. diff --git a/include/SDL_config.h.in b/include/SDL_config.h.in index fb49c0e2f..332cb9775 100644 --- a/include/SDL_config.h.in +++ b/include/SDL_config.h.in @@ -279,7 +279,6 @@ #undef SDL_VIDEO_DRIVER_WSCONS #undef SDL_VIDEO_DRIVER_X11 #undef SDL_VIDEO_DRIVER_X11_DGAMOUSE -#undef SDL_VIDEO_DRIVER_X11_DPMS #undef SDL_VIDEO_DRIVER_X11_DYNAMIC #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR @@ -298,6 +297,9 @@ #undef SDL_VIDEO_OPENGL_OSMESA #undef SDL_VIDEO_OPENGL_OSMESA_DYNAMIC +/* Disable screensaver */ +#undef SDL_VIDEO_DISABLE_SCREENSAVER + /* Enable assembly routines */ #undef SDL_ASSEMBLY_ROUTINES #undef SDL_HERMES_BLITTERS diff --git a/include/SDL_config_macosx.h b/include/SDL_config_macosx.h index 481c22edc..2de52c6b5 100644 --- a/include/SDL_config_macosx.h +++ b/include/SDL_config_macosx.h @@ -126,6 +126,9 @@ /* Enable OpenGL support */ #define SDL_VIDEO_OPENGL 1 +/* Disable screensaver */ +#define SDL_VIDEO_DISABLE_SCREENSAVER 1 + /* Enable assembly routines */ #define SDL_ASSEMBLY_ROUTINES 1 #ifdef __ppc__ diff --git a/include/SDL_config_win32.h b/include/SDL_config_win32.h index cfb44d2a0..37fe11a73 100644 --- a/include/SDL_config_win32.h +++ b/include/SDL_config_win32.h @@ -172,6 +172,9 @@ typedef unsigned int uintptr_t; #define SDL_VIDEO_OPENGL_WGL 1 #endif +/* Disable screensaver */ +#define SDL_VIDEO_DISABLE_SCREENSAVER 1 + /* Enable assembly routines (Win64 doesn't have inline asm) */ #ifndef _WIN64 #define SDL_ASSEMBLY_ROUTINES 1 diff --git a/src/video/dga/SDL_dgaevents.c b/src/video/dga/SDL_dgaevents.c index 11bd21efa..c74c9ce2b 100644 --- a/src/video/dga/SDL_dgaevents.c +++ b/src/video/dga/SDL_dgaevents.c @@ -137,9 +137,21 @@ void DGA_PumpEvents(_THIS) { /* Keep processing pending events */ LOCK_DISPLAY(); + + /* Update activity every five seconds to prevent screensaver. --ryan. */ + if (!allow_screensaver) { + static Uint32 screensaverTicks; + Uint32 nowTicks = SDL_GetTicks(); + if ((nowTicks - screensaverTicks) > 5000) { + XResetScreenSaver(DGA_Display); + screensaverTicks = nowTicks; + } + } + while ( X11_Pending(DGA_Display) ) { DGA_DispatchEvent(this); } + UNLOCK_DISPLAY(); } diff --git a/src/video/dga/SDL_dgavideo.c b/src/video/dga/SDL_dgavideo.c index 331fcd260..cb9f8591c 100644 --- a/src/video/dga/SDL_dgavideo.c +++ b/src/video/dga/SDL_dgavideo.c @@ -43,11 +43,6 @@ /*#define DGA_DEBUG*/ -/* 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); @@ -333,6 +328,7 @@ static void UpdateHWInfo(_THIS, SDL_NAME(XDGAMode) *mode) static int DGA_VideoInit(_THIS, SDL_PixelFormat *vformat) { + const char *env; const char *display; int event_base, error_base; int major_version, minor_version; @@ -401,9 +397,17 @@ static int DGA_VideoInit(_THIS, SDL_PixelFormat *vformat) return(-1); } - /* Save DPMS and screensaver settings */ - X11_SaveScreenSaver(DGA_Display, &screensaver_timeout, &dpms_enabled); - X11_DisableScreenSaver(DGA_Display); + /* Allow environment override of screensaver disable. */ + env = SDL_getenv("SDL_VIDEO_ALLOW_SCREENSAVER"); + if ( env ) { + allow_screensaver = SDL_atoi(env); + } else { +#ifdef SDL_VIDEO_DISABLE_SCREENSAVER + allow_screensaver = 0; +#else + allow_screensaver = 1; +#endif + } /* Query for the list of available video modes */ modes = SDL_NAME(XDGAQueryModes)(DGA_Display, DGA_Screen, &num_modes); @@ -1091,9 +1095,6 @@ void DGA_VideoQuit(_THIS) /* 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); } diff --git a/src/video/dga/SDL_dgavideo.h b/src/video/dga/SDL_dgavideo.h index a0915da58..9af6f6ba1 100644 --- a/src/video/dga/SDL_dgavideo.h +++ b/src/video/dga/SDL_dgavideo.h @@ -32,10 +32,6 @@ #include "SDL_mutex.h" #include "../SDL_sysvideo.h" -#if SDL_VIDEO_DRIVER_X11_DPMS -#include -#endif - /* Hidden "this" pointer for the video functions */ #define _THIS SDL_VideoDevice *this @@ -94,9 +90,9 @@ struct SDL_PrivateVideoData { #endif /* Screensaver settings */ - int screensaver_timeout; - BOOL dpms_enabled; + int allow_screensaver; }; + /* Old variable names */ #define DGA_Display (this->hidden->DGA_Display) #define DGA_Screen DefaultScreen(DGA_Display) @@ -117,7 +113,6 @@ struct SDL_PrivateVideoData { #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) +#define allow_screensaver (this->hidden->allow_screensaver) #endif /* _SDL_dgavideo_h */ diff --git a/src/video/quartz/SDL_QuartzEvents.m b/src/video/quartz/SDL_QuartzEvents.m index c20f58dd3..ada888973 100644 --- a/src/video/quartz/SDL_QuartzEvents.m +++ b/src/video/quartz/SDL_QuartzEvents.m @@ -717,8 +717,6 @@ static int QZ_OtherMouseButtonToSDL(int button) void QZ_PumpEvents (_THIS) { - static Uint32 screensaverTicks = 0; - Uint32 nowTicks; CGMouseDelta dx, dy; NSDate *distantPast; @@ -731,7 +729,8 @@ void QZ_PumpEvents (_THIS) /* Update activity every five seconds to prevent screensaver. --ryan. */ if (!allow_screensaver) { - nowTicks = SDL_GetTicks(); + static Uint32 screensaverTicks; + Uint32 nowTicks = SDL_GetTicks(); if ((nowTicks - screensaverTicks) > 5000) { UpdateSystemActivity(UsrActivity); diff --git a/src/video/quartz/SDL_QuartzVideo.m b/src/video/quartz/SDL_QuartzVideo.m index 3aff6e894..51a376ad2 100644 --- a/src/video/quartz/SDL_QuartzVideo.m +++ b/src/video/quartz/SDL_QuartzVideo.m @@ -188,8 +188,17 @@ static int QZ_VideoInit (_THIS, SDL_PixelFormat *video_format) { mode_list = CGDisplayAvailableModes (display_id); palette = CGPaletteCreateDefaultColorPalette (); + /* Allow environment override of screensaver disable. */ env = SDL_getenv("SDL_VIDEO_ALLOW_SCREENSAVER"); - allow_screensaver = ( env && SDL_atoi(env) ) ? YES : NO; + if ( env ) { + allow_screensaver = SDL_atoi(env); + } else { +#ifdef SDL_VIDEO_DISABLE_SCREENSAVER + allow_screensaver = 0; +#else + allow_screensaver = 1; +#endif + } /* Gather some information that is useful to know about the display */ CFNumberGetValue (CFDictionaryGetValue (save_mode, kCGDisplayBitsPerPixel), diff --git a/src/video/windib/SDL_dibevents.c b/src/video/windib/SDL_dibevents.c index 254ba80f2..8b93a334d 100644 --- a/src/video/windib/SDL_dibevents.c +++ b/src/video/windib/SDL_dibevents.c @@ -227,7 +227,7 @@ LRESULT DIB_HandleMessage(_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar case WM_SYSCOMMAND: { const DWORD val = (DWORD) (wParam & 0xFFF0); if ((val == SC_SCREENSAVE) || (val == SC_MONITORPOWER)) { - if (!this->hidden->allow_screensaver) { + if (!allow_screensaver) { /* Note that this doesn't stop anything on Vista if the screensaver has a password. */ return(0); diff --git a/src/video/windib/SDL_dibvideo.c b/src/video/windib/SDL_dibvideo.c index 734be7eda..f264891ac 100644 --- a/src/video/windib/SDL_dibvideo.c +++ b/src/video/windib/SDL_dibvideo.c @@ -396,7 +396,15 @@ int DIB_VideoInit(_THIS, SDL_PixelFormat *vformat) /* Allow environment override of screensaver disable. */ env = SDL_getenv("SDL_VIDEO_ALLOW_SCREENSAVER"); - this->hidden->allow_screensaver = ( (env && SDL_atoi(env)) ? 1 : 0 ); + if ( env ) { + allow_screensaver = SDL_atoi(env); + } else { +#ifdef SDL_VIDEO_DISABLE_SCREENSAVER + allow_screensaver = 0; +#else + allow_screensaver = 1; +#endif + } /* We're done! */ return(0); diff --git a/src/video/windib/SDL_dibvideo.h b/src/video/windib/SDL_dibvideo.h index 043c11d15..0278bb0f3 100644 --- a/src/video/windib/SDL_dibvideo.h +++ b/src/video/windib/SDL_dibvideo.h @@ -43,8 +43,6 @@ struct SDL_PrivateVideoData { LOGPALETTE *screen_logpal; BOOL grab_palette; - 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]; @@ -56,6 +54,9 @@ struct SDL_PrivateVideoData { int supportRotation; /* for Pocket PC devices */ DWORD origRotation; /* for Pocket PC devices */ #endif + + /* Screensaver settings */ + int allow_screensaver; }; /* Old variable names */ #define screen_bmp (this->hidden->screen_bmp) @@ -64,5 +65,6 @@ struct SDL_PrivateVideoData { #define grab_palette (this->hidden->grab_palette) #define SDL_nummodes (this->hidden->SDL_nummodes) #define SDL_modelist (this->hidden->SDL_modelist) +#define allow_screensaver (this->hidden->allow_screensaver) #endif /* _SDL_dibvideo_h */ diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index dd062cd4f..761a4eaaa 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -920,6 +920,16 @@ void X11_PumpEvents(_THIS) { int pending; + /* Update activity every five seconds to prevent screensaver. --ryan. */ + if (!allow_screensaver) { + static Uint32 screensaverTicks; + Uint32 nowTicks = SDL_GetTicks(); + if ((nowTicks - screensaverTicks) > 5000) { + XResetScreenSaver(SDL_Display); + screensaverTicks = nowTicks; + } + } + /* Keep processing pending events */ pending = 0; while ( X11_Pending(SDL_Display) ) { @@ -1389,67 +1399,3 @@ void X11_InitOSKeymap(_THIS) X11_InitKeymap(); } -void X11_SaveScreenSaver(Display *display, int *saved_timeout, BOOL *dpms) -{ - int timeout, interval, prefer_blank, allow_exp; - 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(display, &dummy, &dummy) ) { - CARD16 state; - DPMSInfo(display, &state, dpms); - } - } -#else - *dpms = 0; -#endif /* SDL_VIDEO_DRIVER_X11_DPMS */ -} - -void X11_DisableScreenSaver(_THIS, Display *display) -{ - int timeout, interval, prefer_blank, allow_exp; - - if (this->hidden->allow_screensaver) { - return; - } - - XGetScreenSaver(display, &timeout, &interval, &prefer_blank, &allow_exp); - timeout = 0; - XSetScreenSaver(display, timeout, interval, prefer_blank, allow_exp); - -#if SDL_VIDEO_DRIVER_X11_DPMS - if ( SDL_X11_HAVE_DPMS ) { - int dummy; - if ( DPMSQueryExtension(display, &dummy, &dummy) ) { - DPMSDisable(display); - } - } -#endif /* SDL_VIDEO_DRIVER_X11_DPMS */ -} - -void X11_RestoreScreenSaver(_THIS, Display *display, int saved_timeout, BOOL dpms) -{ - int timeout, interval, prefer_blank, allow_exp; - - if (this->hidden->allow_screensaver) { - return; - } - - 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(display, &dummy, &dummy) ) { - if ( dpms ) { - DPMSEnable(display); - } - } - } -#endif /* SDL_VIDEO_DRIVER_X11_DPMS */ -} diff --git a/src/video/x11/SDL_x11events_c.h b/src/video/x11/SDL_x11events_c.h index 18a17089f..ad02832ea 100644 --- a/src/video/x11/SDL_x11events_c.h +++ b/src/video/x11/SDL_x11events_c.h @@ -27,7 +27,3 @@ extern void X11_InitOSKeymap(_THIS); extern void X11_PumpEvents(_THIS); extern void X11_SetKeyboardState(Display *display, const char *key_vec); - -extern void X11_SaveScreenSaver(Display *display, int *saved_timeout, BOOL *dpms); -extern void X11_DisableScreenSaver(_THIS, Display *display); -extern void X11_RestoreScreenSaver(_THIS, Display *display, int saved_timeout, BOOL dpms); diff --git a/src/video/x11/SDL_x11sym.h b/src/video/x11/SDL_x11sym.h index 9839fc9b3..2dff59007 100644 --- a/src/video/x11/SDL_x11sym.h +++ b/src/video/x11/SDL_x11sym.h @@ -56,7 +56,6 @@ SDL_X11_SYM(int,XFreePixmap,(Display* a,Pixmap b),(a,b),return) SDL_X11_SYM(int,XGetErrorDatabaseText,(Display* a,_Xconst char* b,_Xconst char* c,_Xconst char* d,char* e,int f),(a,b,c,d,e,f),return) SDL_X11_SYM(XModifierKeymap*,XGetModifierMapping,(Display* a),(a),return) SDL_X11_SYM(int,XGetPointerControl,(Display* a,int* b,int* c,int* d),(a,b,c,d),return) -SDL_X11_SYM(int,XGetScreenSaver,(Display* a,int* b,int* c,int* d, int* e),(a,b,c,d,e),return) SDL_X11_SYM(XVisualInfo*,XGetVisualInfo,(Display* a,long b,XVisualInfo* c,int* d),(a,b,c,d),return) SDL_X11_SYM(XWMHints*,XGetWMHints,(Display* a,Window b),(a,b),return) SDL_X11_SYM(Status,XGetWindowAttributes,(Display* a,Window b,XWindowAttributes* c),(a,b,c),return) @@ -85,13 +84,13 @@ SDL_X11_SYM(int,XQueryKeymap,(Display* a,char *b),(a,b),return) SDL_X11_SYM(Bool,XQueryPointer,(Display* a,Window b,Window* c,Window* d,int* e,int* f,int* g,int* h,unsigned int* i),(a,b,c,d,e,f,g,h,i),return) SDL_X11_SYM(int,XRaiseWindow,(Display* a,Window b),(a,b),return) SDL_X11_SYM(int,XReparentWindow,(Display* a,Window b,Window c,int d,int e),(a,b,c,d,e),return) +SDL_X11_SYM(int,XResetScreenSaver,(Display* a),(a),return) SDL_X11_SYM(int,XResizeWindow,(Display* a,Window b,unsigned int c,unsigned int d),(a,b,c,d),return) SDL_X11_SYM(int,XSelectInput,(Display* a,Window b,long c),(a,b,c),return) SDL_X11_SYM(Status,XSendEvent,(Display* a,Window b,Bool c,long d,XEvent* e),(a,b,c,d,e),return) SDL_X11_SYM(int,XSetClassHint,(Display* a,Window b,XClassHint* c),(a,b,c),return) SDL_X11_SYM(XErrorHandler,XSetErrorHandler,(XErrorHandler a),(a),return) SDL_X11_SYM(XIOErrorHandler,XSetIOErrorHandler,(XIOErrorHandler a),(a),return) -SDL_X11_SYM(int,XSetScreenSaver,(Display* a,int b,int c,int d,int e),(a,b,c,d,e),return) SDL_X11_SYM(int,XSetTransientForHint,(Display* a,Window b,Window c),(a,b,c),return) SDL_X11_SYM(int,XSetWMHints,(Display* a,Window b,XWMHints* c),(a,b,c),return) SDL_X11_SYM(void,XSetTextProperty,(Display* a,Window b,XTextProperty* c,Atom d),(a,b,c,d),) @@ -192,14 +191,5 @@ SDL_X11_SYM(Status,XRRSetScreenConfig,(Display *dpy, XRRScreenConfiguration *con SDL_X11_SYM(void,XRRFreeScreenConfigInfo,(XRRScreenConfiguration *config),(config),) #endif -/* DPMS support */ -#if SDL_VIDEO_DRIVER_X11_DPMS -SDL_X11_MODULE(DPMS) -SDL_X11_SYM(Status,DPMSQueryExtension,(Display *dpy,int *major_versionp,int *minor_versionp),(dpy,major_versionp,minor_versionp),return) -SDL_X11_SYM(Status,DPMSInfo,(Display *dpy,CARD16 *state,BOOL *onoff),(dpy,state,onoff),return) -SDL_X11_SYM(Status,DPMSEnable,(Display *dpy),(dpy),return) -SDL_X11_SYM(Status,DPMSDisable,(Display *dpy),(dpy),return) -#endif - /* end of SDL_x11sym.h ... */ diff --git a/src/video/x11/SDL_x11video.c b/src/video/x11/SDL_x11video.c index 06858720e..33ab1aa80 100644 --- a/src/video/x11/SDL_x11video.c +++ b/src/video/x11/SDL_x11video.c @@ -556,7 +556,7 @@ static void create_aux_windows(_THIS) static int X11_VideoInit(_THIS, SDL_PixelFormat *vformat) { - const char *env = NULL; + const char *env; char *display; int i; @@ -669,11 +669,15 @@ static int X11_VideoInit(_THIS, SDL_PixelFormat *vformat) /* Allow environment override of screensaver disable. */ env = SDL_getenv("SDL_VIDEO_ALLOW_SCREENSAVER"); - this->hidden->allow_screensaver = ( (env && SDL_atoi(env)) ? 1 : 0 ); - - /* Save DPMS and screensaver settings */ - X11_SaveScreenSaver(SDL_Display, &screensaver_timeout, &dpms_enabled); - X11_DisableScreenSaver(this, SDL_Display); + if ( env ) { + allow_screensaver = SDL_atoi(env); + } else { +#ifdef SDL_VIDEO_DISABLE_SCREENSAVER + allow_screensaver = 0; +#else + allow_screensaver = 1; +#endif + } /* See if we have been passed a window to use */ SDL_windowid = SDL_getenv("SDL_WINDOWID"); @@ -1506,9 +1510,6 @@ void X11_VideoQuit(_THIS) X11_SwapVidModeGamma(this); } - /* Restore DPMS and screensaver settings */ - X11_RestoreScreenSaver(this, SDL_Display, screensaver_timeout, dpms_enabled); - /* Free that blank cursor */ if ( SDL_BlankCursor != NULL ) { this->FreeWMCursor(this, SDL_BlankCursor); diff --git a/src/video/x11/SDL_x11video.h b/src/video/x11/SDL_x11video.h index 920942efd..ddfd5b68d 100644 --- a/src/video/x11/SDL_x11video.h +++ b/src/video/x11/SDL_x11video.h @@ -46,9 +46,6 @@ #if SDL_VIDEO_DRIVER_X11_XME #include "../Xext/extensions/xme.h" #endif -#if SDL_VIDEO_DRIVER_X11_DPMS -#include -#endif #include "SDL_x11dyn.h" @@ -139,8 +136,6 @@ struct SDL_PrivateVideoData { int use_xme; int currently_fullscreen; - int allow_screensaver; - /* Automatic mode switching support (entering/leaving fullscreen) */ Uint32 switch_waiting; Uint32 switch_time; @@ -158,8 +153,7 @@ struct SDL_PrivateVideoData { short *iconcolors; /* List of colors used by the icon */ /* Screensaver settings */ - int screensaver_timeout; - BOOL dpms_enabled; + int allow_screensaver; }; /* Old variable names */ @@ -210,8 +204,8 @@ struct SDL_PrivateVideoData { #define gamma_saved (this->hidden->gamma_saved) #define gamma_changed (this->hidden->gamma_changed) #define SDL_iconcolors (this->hidden->iconcolors) -#define screensaver_timeout (this->hidden->screensaver_timeout) -#define dpms_enabled (this->hidden->dpms_enabled) +#define allow_screensaver (this->hidden->allow_screensaver) + /* Some versions of XFree86 have bugs - detect if this is one of them */ #define BUGGY_XFREE86(condition, buggy_version) \ ((SDL_strcmp(ServerVendor(SDL_Display), "The XFree86 Project, Inc") == 0) && \ diff --git a/src/video/xbios/SDL_xbios_centscreen.c b/src/video/xbios/SDL_xbios_centscreen.c index 96e5d7ed8..9cd77e7d1 100644 --- a/src/video/xbios/SDL_xbios_centscreen.c +++ b/src/video/xbios/SDL_xbios_centscreen.c @@ -85,10 +85,12 @@ void SDL_XBIOS_CentscreenSetmode(_THIS, int width, int height, int planes) newmode.plan = planes; Vwrite(0, &newmode, &curmode); +#ifdef SDL_VIDEO_DISABLE_SCREENSAVER /* Disable screensaver */ Vread(&newmode); newmode.mode &= ~(CSCREEN_SAVER|CSCREEN_ENERGYSTAR); Vwrite(0, &newmode, &curmode); +#endif /* SDL_VIDEO_DISABLE_SCREENSAVER */ } void SDL_XBIOS_CentscreenRestore(_THIS, int prev_handle)