Added an API to enable/disable the screen saver.
authorSam Lantinga <slouken@libsdl.org>
Mon, 12 Jan 2009 06:19:05 +0000
changeset 302554fac87e1f34
parent 3024 1a08749aebce
child 3026 69ab1117dd3b
Added an API to enable/disable the screen saver.
The screensaver is disabled by default when using SDL 1.2 compatibility.
Use the new XScreenSaver extension, removed unused DPMS extension.
configure.in
include/SDL_config.h.in
include/SDL_video.h
src/SDL_compat.c
src/video/SDL_sysvideo.h
src/video/SDL_video.c
src/video/Xext/extensions/xme.h
src/video/cocoa/SDL_cocoaevents.m
src/video/cocoa/SDL_cocoavideo.h
src/video/win32/SDL_win32events.c
src/video/x11/SDL_x11dyn.c
src/video/x11/SDL_x11events.c
src/video/x11/SDL_x11events.h
src/video/x11/SDL_x11sym.h
src/video/x11/SDL_x11video.c
src/video/x11/SDL_x11video.h
     1.1 --- a/configure.in	Sun Jan 11 23:56:19 2009 +0000
     1.2 +++ b/configure.in	Mon Jan 12 06:19:05 2009 +0000
     1.3 @@ -1020,6 +1020,7 @@
     1.4                      xrender_lib='/usr/X11R6/lib/libXrender.1.dylib'
     1.5                      xrandr_lib='/usr/X11R6/lib/libXrandr.2.dylib'
     1.6                      xinput_lib='/usr/X11R6/lib/libXi.6.dylib'
     1.7 +                    xss_lib='/usr/X11R6/lib/libXss.6.dylib'
     1.8                      ;;
     1.9                  *-*-osf*)
    1.10                      x11_lib='libX11.so'
    1.11 @@ -1062,6 +1063,12 @@
    1.12                                  xinput_lib=[`ls -- $path/libXi.so.[0-9]* 2>/dev/null | sort -r | sed 's/.*\/\(.*\)/\1/; q'`]
    1.13                              fi
    1.14                          fi
    1.15 +                        if test "x$xss_lib" = "x"; then
    1.16 +                            xss_lib=[`ls -- $path/libXss.so.[0-9] 2>/dev/null | sort -r | sed 's/.*\/\(.*\)/\1/; q'`]
    1.17 +                            if test "x$xss_lib" = "x"; then
    1.18 +                                xss_lib=[`ls -- $path/libXss.so.[0-9]* 2>/dev/null | sort -r | sed 's/.*\/\(.*\)/\1/; q'`]
    1.19 +                            fi
    1.20 +                        fi
    1.21                      done
    1.22                      ;;
    1.23              esac
    1.24 @@ -1124,13 +1131,6 @@
    1.25                  AC_DEFINE(SDL_VIDEO_DRIVER_X11_XINERAMA)
    1.26                  SOURCES="$SOURCES $srcdir/src/video/Xext/Xinerama/*.c"
    1.27              fi
    1.28 -            AC_ARG_ENABLE(video-x11-xme,
    1.29 -AC_HELP_STRING([--enable-video-x11-xme], [enable Xi Graphics XME for fullscreen [[default=yes]]]),
    1.30 -                            , enable_video_x11_xme=yes)
    1.31 -            if test x$enable_video_x11_xme = xyes; then
    1.32 -                AC_DEFINE(SDL_VIDEO_DRIVER_X11_XME)
    1.33 -                SOURCES="$SOURCES $srcdir/src/video/Xext/XME/*.c"
    1.34 -            fi
    1.35              AC_ARG_ENABLE(video-x11-xrandr,
    1.36  AC_HELP_STRING([--enable-video-x11-xrandr], [enable X11 Xrandr extension for fullscreen [[default=yes]]]),
    1.37                              , enable_video_x11_xrandr=yes)
    1.38 @@ -1188,19 +1188,32 @@
    1.39              if test x$definitely_enable_video_x11_xinput = xyes; then
    1.40                  AC_DEFINE(SDL_VIDEO_DRIVER_X11_XINPUT)
    1.41              fi
    1.42 -            AC_ARG_ENABLE(video-x11-dpms,
    1.43 -AC_HELP_STRING([--enable-video-x11-dpms], [enable X11 DPMS extension [[default=yes]]]),
    1.44 -                            , enable_video_x11_dpms=yes)
    1.45 -            if test x$enable_video_x11_dpms = xyes; then
    1.46 -                AC_CHECK_HEADER(X11/extensions/dpms.h,
    1.47 -                                have_dpms_h_hdr=yes,
    1.48 -                                have_dpms_h_hdr=no,
    1.49 +            AC_ARG_ENABLE(video-x11-scrnsaver,
    1.50 +AC_HELP_STRING([--enable-video-x11-scrnsaver], [enable X11 screensaver extension [[default=yes]]]),
    1.51 +                            , enable_video_x11_scrnsaver=yes)
    1.52 +            if test x$enable_video_x11_scrnsaver = xyes; then
    1.53 +                AC_CHECK_HEADER(X11/extensions/scrnsaver.h,
    1.54 +                                have_scrnsaver_h_hdr=yes,
    1.55 +                                have_scrnsaver_h_hdr=no,
    1.56                                  [#include <X11/Xlib.h>
    1.57                                  ])
    1.58 -                if test x$have_dpms_h_hdr = xyes; then
    1.59 -                    AC_DEFINE(SDL_VIDEO_DRIVER_X11_DPMS)
    1.60 +                if test x$have_scrnsaver_h_hdr = xyes; then
    1.61 +                    if test x$enable_x11_shared = xyes && test x$xss_lib != x ; then
    1.62 +                        echo "-- dynamic libXss -> $xss_lib"
    1.63 +                        AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS, "$xss_lib")
    1.64 +                        definitely_enable_video_x11_scrnsaver=yes
    1.65 +                    else
    1.66 +                        AC_CHECK_LIB(Xss, XScreenSaverSuspend, have_xss_lib=yes)
    1.67 +                        if test x$have_xss_lib = xyes ; then
    1.68 +                            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXss"
    1.69 +                            definitely_enable_video_x11_scrnsaver=yes
    1.70 +                        fi
    1.71 +                    fi
    1.72                  fi
    1.73              fi
    1.74 +            if test x$definitely_enable_video_x11_scrnsaver = xyes; then
    1.75 +                AC_DEFINE(SDL_VIDEO_DRIVER_X11_SCRNSAVER)
    1.76 +            fi
    1.77  
    1.78              AC_ARG_ENABLE(render-x11,
    1.79  AC_HELP_STRING([--enable-render-x11], [enable the X11 render driver [[default=yes]]]),
     2.1 --- a/include/SDL_config.h.in	Sun Jan 11 23:56:19 2009 +0000
     2.2 +++ b/include/SDL_config.h.in	Mon Jan 12 06:19:05 2009 +0000
     2.3 @@ -291,17 +291,17 @@
     2.4  #undef SDL_VIDEO_DRIVER_WIN32
     2.5  #undef SDL_VIDEO_DRIVER_WSCONS
     2.6  #undef SDL_VIDEO_DRIVER_X11
     2.7 -#undef SDL_VIDEO_DRIVER_X11_DPMS
     2.8  #undef SDL_VIDEO_DRIVER_X11_DYNAMIC
     2.9  #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT
    2.10  #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR
    2.11  #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER
    2.12  #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT
    2.13 +#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS
    2.14  #undef SDL_VIDEO_DRIVER_X11_VIDMODE
    2.15  #undef SDL_VIDEO_DRIVER_X11_XINERAMA
    2.16 -#undef SDL_VIDEO_DRIVER_X11_XME
    2.17  #undef SDL_VIDEO_DRIVER_X11_XRANDR
    2.18  #undef SDL_VIDEO_DRIVER_X11_XINPUT
    2.19 +#undef SDL_VIDEO_DRIVER_X11_SCRNSAVER
    2.20  #undef SDL_VIDEO_DRIVER_X11_XV
    2.21  #undef SDL_VIDEO_DRIVER_XBIOS
    2.22  
     3.1 --- a/include/SDL_video.h	Sun Jan 11 23:56:19 2009 +0000
     3.2 +++ b/include/SDL_video.h	Mon Jan 12 06:19:05 2009 +0000
     3.3 @@ -1311,6 +1311,36 @@
     3.4   */
     3.5  extern DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_WindowID windowID);
     3.6  
     3.7 +/**
     3.8 + * \fn SDL_bool SDL_IsScreenSaverEnabled();
     3.9 + *
    3.10 + * \brief Returns whether the screensaver is currently enabled (default off).
    3.11 + *
    3.12 + * \sa SDL_EnableScreenSaver()
    3.13 + * \sa SDL_DisableScreenSaver()
    3.14 + */
    3.15 +extern DECLSPEC SDL_bool SDLCALL SDL_IsScreenSaverEnabled();
    3.16 +
    3.17 +/**
    3.18 + * \fn void SDL_EnableScreenSaver();
    3.19 + *
    3.20 + * \brief Allow the screen to be blanked by a screensaver
    3.21 + *
    3.22 + * \sa SDL_IsScreenSaverEnabled()
    3.23 + * \sa SDL_DisableScreenSaver()
    3.24 + */
    3.25 +extern DECLSPEC void SDLCALL SDL_EnableScreenSaver();
    3.26 +
    3.27 +/**
    3.28 + * \fn void SDL_DisableScreenSaver();
    3.29 + *
    3.30 + * \brief Prevent the screen from being blanked by a screensaver
    3.31 + *
    3.32 + * \sa SDL_IsScreenSaverEnabled()
    3.33 + * \sa SDL_EnableScreenSaver()
    3.34 + */
    3.35 +extern DECLSPEC void SDLCALL SDL_DisableScreenSaver();
    3.36 +
    3.37  
    3.38  /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
    3.39  /* OpenGL support functions.                                                 */
     4.1 --- a/src/SDL_compat.c	Sun Jan 11 23:56:19 2009 +0000
     4.2 +++ b/src/SDL_compat.c	Mon Jan 12 06:19:05 2009 +0000
     4.3 @@ -376,6 +376,26 @@
     4.4      SDL_UpdateRect(SDL_PublicSurface, 0, 0, 0, 0);
     4.5  }
     4.6  
     4.7 +static void
     4.8 +SetupScreenSaver()
     4.9 +{
    4.10 +    const char *env;
    4.11 +    SDL_bool allow_screensaver;
    4.12 +
    4.13 +	/* Allow environment override of screensaver disable */
    4.14 +	env = SDL_getenv("SDL_VIDEO_ALLOW_SCREENSAVER");
    4.15 +	if (env) {
    4.16 +		allow_screensaver = SDL_atoi(env) ? SDL_TRUE : SDL_FALSE;
    4.17 +	} else {
    4.18 +		allow_screensaver = SDL_FALSE;
    4.19 +	}
    4.20 +    if (allow_screensaver) {
    4.21 +        SDL_EnableScreenSaver();
    4.22 +    } else {
    4.23 +        SDL_DisableScreenSaver();
    4.24 +    }
    4.25 +}
    4.26 +
    4.27  int
    4.28  SDL_ResizeVideoMode(int width, int height, int bpp, Uint32 flags)
    4.29  {
    4.30 @@ -456,6 +476,7 @@
    4.31  {
    4.32      SDL_DisplayMode desktop_mode;
    4.33      SDL_DisplayMode mode;
    4.34 +    const char *env;
    4.35      int window_x = SDL_WINDOWPOS_UNDEFINED;
    4.36      int window_y = SDL_WINDOWPOS_UNDEFINED;
    4.37      Uint32 window_flags;
    4.38 @@ -679,6 +700,8 @@
    4.39  
    4.40      ClearVideoSurface();
    4.41  
    4.42 +    SetupScreenSaver();
    4.43 +
    4.44      /* We're finally done! */
    4.45      return SDL_PublicSurface;
    4.46  }
     5.1 --- a/src/video/SDL_sysvideo.h	Sun Jan 11 23:56:19 2009 +0000
     5.2 +++ b/src/video/SDL_sysvideo.h	Mon Jan 12 06:19:05 2009 +0000
     5.3 @@ -273,8 +273,12 @@
     5.4       */
     5.5      void (*PumpEvents) (_THIS);
     5.6  
     5.7 +    /* Suspend the screensaver */
     5.8 +    void (*SuspendScreenSaver) (_THIS);
     5.9 +
    5.10      /* * * */
    5.11      /* Data common to all drivers */
    5.12 +    SDL_bool suspend_screensaver;
    5.13      int num_displays;
    5.14      SDL_VideoDisplay *displays;
    5.15      int current_display;
     6.1 --- a/src/video/SDL_video.c	Sun Jan 11 23:56:19 2009 +0000
     6.2 +++ b/src/video/SDL_video.c	Mon Jan 12 06:19:05 2009 +0000
     6.3 @@ -2326,6 +2326,45 @@
     6.4      }
     6.5  }
     6.6  
     6.7 +SDL_bool
     6.8 +SDL_IsScreenSaverEnabled()
     6.9 +{
    6.10 +    if (!_this) {
    6.11 +        return SDL_TRUE;
    6.12 +    }
    6.13 +    return _this->suspend_screensaver ? SDL_FALSE : SDL_TRUE;
    6.14 +}
    6.15 +
    6.16 +void
    6.17 +SDL_EnableScreenSaver()
    6.18 +{
    6.19 +    if (!_this) {
    6.20 +        return;
    6.21 +    }
    6.22 +    if (!_this->suspend_screensaver) {
    6.23 +        return;
    6.24 +    }
    6.25 +    _this->suspend_screensaver = SDL_FALSE;
    6.26 +    if (_this->SuspendScreenSaver) {
    6.27 +        _this->SuspendScreenSaver(_this);
    6.28 +    }
    6.29 +}
    6.30 +
    6.31 +void
    6.32 +SDL_DisableScreenSaver()
    6.33 +{
    6.34 +    if (!_this) {
    6.35 +        return;
    6.36 +    }
    6.37 +    if (_this->suspend_screensaver) {
    6.38 +        return;
    6.39 +    }
    6.40 +    _this->suspend_screensaver = SDL_TRUE;
    6.41 +    if (_this->SuspendScreenSaver) {
    6.42 +        _this->SuspendScreenSaver(_this);
    6.43 +    }
    6.44 +}
    6.45 +
    6.46  void
    6.47  SDL_VideoQuit(void)
    6.48  {
     7.1 --- a/src/video/Xext/extensions/xme.h	Sun Jan 11 23:56:19 2009 +0000
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,46 +0,0 @@
     7.4 -/*
     7.5 - * Copyright 1993-2001 by Xi Graphics, Inc.
     7.6 - * All Rights Reserved.
     7.7 - *
     7.8 - * Please see the LICENSE file accompanying this distribution for licensing 
     7.9 - * information. 
    7.10 - *
    7.11 - * Please send any bug fixes and modifications to src@xig.com.
    7.12 - *
    7.13 - * $XiGId: xme.h,v 1.1.1.1 2001/11/19 19:01:10 jon Exp $
    7.14 - *
    7.15 - */
    7.16 -
    7.17 -
    7.18 -#ifndef _XME_H_INCLUDED
    7.19 -#define _XME_H_INCLUDED
    7.20 -
    7.21 -typedef struct
    7.22 -{
    7.23 -    short x;
    7.24 -    short y;
    7.25 -    unsigned short w;
    7.26 -    unsigned short h;
    7.27 -} XiGMiscViewInfo;
    7.28 -
    7.29 -typedef struct
    7.30 -{
    7.31 -    unsigned short width;
    7.32 -    unsigned short height;
    7.33 -    int refresh;
    7.34 -} XiGMiscResolutionInfo;
    7.35 -
    7.36 -extern Bool XiGMiscQueryVersion(Display * dpy, int *major, int *minor);
    7.37 -extern int XiGMiscQueryViews(Display * dpy, int screen,
    7.38 -                             XiGMiscViewInfo ** pviews);
    7.39 -extern int XiGMiscQueryResolutions(Display * dpy, int screen, int view,
    7.40 -                                   int *pactive,
    7.41 -                                   XiGMiscResolutionInfo ** presolutions);
    7.42 -extern void XiGMiscChangeResolution(Display * dpy, int screen, int view,
    7.43 -                                    int width, int height, int refresh);
    7.44 -
    7.45 -/* SDL addition from Ryan: free memory used by xme. */
    7.46 -extern void XiGMiscDestroy(void);
    7.47 -
    7.48 -#endif /* _XME_H_INCLUDED */
    7.49 -/* vi: set ts=4 sw=4 expandtab: */
     8.1 --- a/src/video/cocoa/SDL_cocoaevents.m	Sun Jan 11 23:56:19 2009 +0000
     8.2 +++ b/src/video/cocoa/SDL_cocoaevents.m	Mon Jan 12 06:19:05 2009 +0000
     8.3 @@ -164,6 +164,17 @@
     8.4  {
     8.5      NSAutoreleasePool *pool;
     8.6  
     8.7 +    /* Update activity every 30 seconds to prevent screensaver */
     8.8 +    if (_this->suspend_screensaver) {
     8.9 +        SDL_VideoData *data = (SDL_VideoData *)_this->driverdata;
    8.10 +        Uint32 now = SDL_GetTicks();
    8.11 +        if (!data->screensaver_activity ||
    8.12 +            (int)(now-data->screensaver_activity) >= 30000) {
    8.13 +            UpdateSystemActivity(UsrActivity);
    8.14 +            data->screensaver_activity = now;
    8.15 +        }
    8.16 +    }
    8.17 +
    8.18      pool = [[NSAutoreleasePool alloc] init];
    8.19      while ([NSApp isRunning]) {
    8.20          NSEvent *event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES ];
     9.1 --- a/src/video/cocoa/SDL_cocoavideo.h	Sun Jan 11 23:56:19 2009 +0000
     9.2 +++ b/src/video/cocoa/SDL_cocoavideo.h	Mon Jan 12 06:19:05 2009 +0000
     9.3 @@ -49,6 +49,7 @@
     9.4      int keyboard;
     9.5      void *key_layout;
     9.6      NSText *fieldEdit;
     9.7 +    Uint32 screensaver_activity;
     9.8  } SDL_VideoData;
     9.9  
    9.10  #endif /* _SDL_cocoavideo_h */
    10.1 --- a/src/video/win32/SDL_win32events.c	Sun Jan 11 23:56:19 2009 +0000
    10.2 +++ b/src/video/win32/SDL_win32events.c	Mon Jan 12 06:19:05 2009 +0000
    10.3 @@ -578,8 +578,8 @@
    10.4              /* Don't start the screensaver or blank the monitor in fullscreen apps */
    10.5              if ((wParam & 0xFFF0) == SC_SCREENSAVE ||
    10.6                  (wParam & 0xFFF0) == SC_MONITORPOWER) {
    10.7 -                if (SDL_GetWindowFlags(data->windowID) &
    10.8 -                    SDL_WINDOW_FULLSCREEN) {
    10.9 +                SDL_VideoData *videodata = data->videodata;
   10.10 +                if (videodata->suspend_screensaver) {
   10.11                      return (0);
   10.12                  }
   10.13              }
    11.1 --- a/src/video/x11/SDL_x11dyn.c	Sun Jan 11 23:56:19 2009 +0000
    11.2 +++ b/src/video/x11/SDL_x11dyn.c	Mon Jan 12 06:19:05 2009 +0000
    11.3 @@ -62,6 +62,7 @@
    11.4      {NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER},
    11.5      {NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR},
    11.6      {NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT},
    11.7 +    {NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS},
    11.8  };
    11.9  
   11.10  static void
    12.1 --- a/src/video/x11/SDL_x11events.c	Sun Jan 11 23:56:19 2009 +0000
    12.2 +++ b/src/video/x11/SDL_x11events.c	Mon Jan 12 06:19:05 2009 +0000
    12.3 @@ -394,6 +394,16 @@
    12.4  {
    12.5      SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
    12.6  
    12.7 +    /* Update activity every 30 seconds to prevent screensaver */
    12.8 +    if (_this->suspend_screensaver) {
    12.9 +        Uint32 now = SDL_GetTicks();
   12.10 +        if (!data->screensaver_activity ||
   12.11 +            (int)(now-data->screensaver_activity) >= 30000) {
   12.12 +            XResetScreenSaver(data->display);
   12.13 +            data->screensaver_activity = now;
   12.14 +        }
   12.15 +    }
   12.16 +
   12.17      /* Keep processing pending events */
   12.18      while (X11_Pending(data->display)) {
   12.19          X11_DispatchEvent(_this);
   12.20 @@ -401,61 +411,28 @@
   12.21  }
   12.22  
   12.23  void
   12.24 -X11_SaveScreenSaver(Display * display, int *saved_timeout, BOOL * dpms)
   12.25 +X11_SuspendScreenSaver(_THIS)
   12.26  {
   12.27 -    int timeout, interval, prefer_blank, allow_exp;
   12.28 -    XGetScreenSaver(display, &timeout, &interval, &prefer_blank, &allow_exp);
   12.29 -    *saved_timeout = timeout;
   12.30 +#if SDL_VIDEO_DRIVER_X11_SCRNSAVER
   12.31 +    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
   12.32 +    int dummy;
   12.33 +    int major_version, minor_version;
   12.34  
   12.35 -#if SDL_VIDEO_DRIVER_X11_DPMS
   12.36 -    if (SDL_X11_HAVE_DPMS) {
   12.37 -        int dummy;
   12.38 -        if (DPMSQueryExtension(display, &dummy, &dummy)) {
   12.39 -            CARD16 state;
   12.40 -            DPMSInfo(display, &state, dpms);
   12.41 -        }
   12.42 +    if (!SDL_X11_HAVE_XSS) {
   12.43 +        return;
   12.44      }
   12.45 -#else
   12.46 -    *dpms = 0;
   12.47 -#endif /* SDL_VIDEO_DRIVER_X11_DPMS */
   12.48 -}
   12.49  
   12.50 -void
   12.51 -X11_DisableScreenSaver(Display * display)
   12.52 -{
   12.53 -    int timeout, interval, prefer_blank, allow_exp;
   12.54 -    XGetScreenSaver(display, &timeout, &interval, &prefer_blank, &allow_exp);
   12.55 -    timeout = 0;
   12.56 -    XSetScreenSaver(display, timeout, interval, prefer_blank, allow_exp);
   12.57 +    /* XScreenSaverSuspend was introduced in MIT-SCREEN-SAVER 1.1 */
   12.58 +    if (!XScreenSaverQueryExtension(data->display, &dummy, &dummy) ||
   12.59 +        !XScreenSaverQueryVersion(data->display,
   12.60 +                                  &major_version, &minor_version) ||
   12.61 +        major_version < 1 || (major_version == 1 && minor_version < 1)) {
   12.62 +        return;
   12.63 +    }
   12.64  
   12.65 -#if SDL_VIDEO_DRIVER_X11_DPMS
   12.66 -    if (SDL_X11_HAVE_DPMS) {
   12.67 -        int dummy;
   12.68 -        if (DPMSQueryExtension(display, &dummy, &dummy)) {
   12.69 -            DPMSDisable(display);
   12.70 -        }
   12.71 -    }
   12.72 -#endif /* SDL_VIDEO_DRIVER_X11_DPMS */
   12.73 -}
   12.74 -
   12.75 -void
   12.76 -X11_RestoreScreenSaver(Display * display, int saved_timeout, BOOL dpms)
   12.77 -{
   12.78 -    int timeout, interval, prefer_blank, allow_exp;
   12.79 -    XGetScreenSaver(display, &timeout, &interval, &prefer_blank, &allow_exp);
   12.80 -    timeout = saved_timeout;
   12.81 -    XSetScreenSaver(display, timeout, interval, prefer_blank, allow_exp);
   12.82 -
   12.83 -#if SDL_VIDEO_DRIVER_X11_DPMS
   12.84 -    if (SDL_X11_HAVE_DPMS) {
   12.85 -        int dummy;
   12.86 -        if (DPMSQueryExtension(display, &dummy, &dummy)) {
   12.87 -            if (dpms) {
   12.88 -                DPMSEnable(display);
   12.89 -            }
   12.90 -        }
   12.91 -    }
   12.92 -#endif /* SDL_VIDEO_DRIVER_X11_DPMS */
   12.93 +    XScreenSaverSuspend(data->display, _this->suspend_screensaver);
   12.94 +    XResetScreenSaver(data->display);
   12.95 +#endif
   12.96  }
   12.97  
   12.98  /* vi: set ts=4 sw=4 expandtab: */
    13.1 --- a/src/video/x11/SDL_x11events.h	Sun Jan 11 23:56:19 2009 +0000
    13.2 +++ b/src/video/x11/SDL_x11events.h	Mon Jan 12 06:19:05 2009 +0000
    13.3 @@ -25,11 +25,7 @@
    13.4  #define _SDL_x11events_h
    13.5  
    13.6  extern void X11_PumpEvents(_THIS);
    13.7 -extern void X11_SaveScreenSaver(Display * display, int *saved_timeout,
    13.8 -                                BOOL * dpms);
    13.9 -extern void X11_DisableScreenSaver(Display * display);
   13.10 -extern void X11_RestoreScreenSaver(Display * display, int saved_timeout,
   13.11 -                                   BOOL dpms);
   13.12 +extern void X11_SuspendScreenSaver(_THIS);
   13.13  
   13.14  #endif /* _SDL_x11events_h */
   13.15  
    14.1 --- a/src/video/x11/SDL_x11sym.h	Sun Jan 11 23:56:19 2009 +0000
    14.2 +++ b/src/video/x11/SDL_x11sym.h	Mon Jan 12 06:19:05 2009 +0000
    14.3 @@ -67,7 +67,6 @@
    14.4  SDL_X11_SYM(XModifierKeymap*,XGetModifierMapping,(Display* a),(a),return)
    14.5  SDL_X11_SYM(int,XGetPointerControl,(Display* a,int* b,int* c,int* d),(a,b,c,d),return)
    14.6  SDL_X11_SYM(int,XGetRGBColormaps,(Display* a,Window b,XStandardColormap **c,int *d,Atom e),(a,b,c,d,e),return)
    14.7 -SDL_X11_SYM(int,XGetScreenSaver,(Display* a,int* b,int* c,int* d,int* e),(a,b,c,d,e),return)
    14.8  SDL_X11_SYM(XVisualInfo*,XGetVisualInfo,(Display* a,long b,XVisualInfo* c,int* d),(a,b,c,d),return)
    14.9  SDL_X11_SYM(XWMHints*,XGetWMHints,(Display* a,Window b),(a,b),return)
   14.10  SDL_X11_SYM(Status,XGetWindowAttributes,(Display* a,Window b,XWindowAttributes* c),(a,b,c),return)
   14.11 @@ -102,6 +101,7 @@
   14.12  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)
   14.13  SDL_X11_SYM(int,XRaiseWindow,(Display* a,Window b),(a,b),return)
   14.14  SDL_X11_SYM(int,XReparentWindow,(Display* a,Window b,Window c,int d,int e),(a,b,c,d,e),return)
   14.15 +SDL_X11_SYM(int,XResetScreenSaver,(Display* a),(a),return)
   14.16  SDL_X11_SYM(int,XResizeWindow,(Display* a,Window b,unsigned int c,unsigned int d),(a,b,c,d),return)
   14.17  SDL_X11_SYM(int,XSelectInput,(Display* a,Window b,long c),(a,b,c),return)
   14.18  SDL_X11_SYM(Status,XSendEvent,(Display* a,Window b,Bool c,long d,XEvent* e),(a,b,c,d,e),return)
   14.19 @@ -111,7 +111,6 @@
   14.20  SDL_X11_SYM(XErrorHandler,XSetErrorHandler,(XErrorHandler a),(a),return)
   14.21  SDL_X11_SYM(XIOErrorHandler,XSetIOErrorHandler,(XIOErrorHandler a),(a),return)
   14.22  SDL_X11_SYM(void,XSetRGBColormaps,( Display *a,Window b,XStandardColormap *c,int d,Atom e),(a,b,c,d,e),return)
   14.23 -SDL_X11_SYM(int,XSetScreenSaver,(Display* a,int b,int c,int d,int e),(a,b,c,d,e),return)
   14.24  SDL_X11_SYM(int,XSetTransientForHint,(Display* a,Window b,Window c),(a,b,c),return)
   14.25  SDL_X11_SYM(int,XSetWMHints,(Display* a,Window b,XWMHints* c),(a,b,c),return)
   14.26  SDL_X11_SYM(void,XSetTextProperty,(Display* a,Window b,XTextProperty* c,Atom d),(a,b,c,d),)
   14.27 @@ -212,15 +211,6 @@
   14.28  SDL_X11_SYM(void,XRRFreeScreenConfigInfo,(XRRScreenConfiguration *config),(config),)
   14.29  #endif
   14.30  
   14.31 -/* DPMS support */
   14.32 -#if SDL_VIDEO_DRIVER_X11_DPMS
   14.33 -SDL_X11_MODULE(DPMS)
   14.34 -SDL_X11_SYM(Status,DPMSQueryExtension,(Display *dpy,int *major_versionp,int *minor_versionp),(dpy,major_versionp,minor_versionp),return)
   14.35 -SDL_X11_SYM(Status,DPMSInfo,(Display *dpy,CARD16 *state,BOOL *onoff),(dpy,state,onoff),return)
   14.36 -SDL_X11_SYM(Status,DPMSEnable,(Display *dpy),(dpy),return)
   14.37 -SDL_X11_SYM(Status,DPMSDisable,(Display *dpy),(dpy),return)
   14.38 -#endif
   14.39 -
   14.40  /* XInput support for multiple mice, tablets, etc. */
   14.41  #if SDL_VIDEO_DRIVER_X11_XINPUT
   14.42  SDL_X11_MODULE(XINPUT)
   14.43 @@ -231,6 +221,14 @@
   14.44  SDL_X11_SYM(int,XCloseDevice,(Display* a,XDevice* b),(a,b),return)
   14.45  #endif
   14.46  
   14.47 +/* MIT-SCREEN-SAVER support */
   14.48 +#if SDL_VIDEO_DRIVER_X11_SCRNSAVER
   14.49 +SDL_X11_MODULE(XSS)
   14.50 +SDL_X11_SYM(Bool,XScreenSaverQueryExtension,(Display *dpy,int *event_base,int *error_base),(dpy,event_base,error_base),return)
   14.51 +SDL_X11_SYM(Status,XScreenSaverQueryVersion,(Display *dpy,int *major_versionp,int *minor_versionp),(dpy,major_versionp,minor_versionp),return)
   14.52 +SDL_X11_SYM(void,XScreenSaverSuspend,(Display *dpy,Bool suspend),(dpy,suspend),return)
   14.53 +#endif
   14.54 +
   14.55  /* *INDENT-ON* */
   14.56  
   14.57  /* vi: set ts=4 sw=4 expandtab: */
    15.1 --- a/src/video/x11/SDL_x11video.c	Sun Jan 11 23:56:19 2009 +0000
    15.2 +++ b/src/video/x11/SDL_x11video.c	Mon Jan 12 06:19:05 2009 +0000
    15.3 @@ -169,6 +169,7 @@
    15.4      device->SetDisplayMode = X11_SetDisplayMode;
    15.5      device->SetDisplayGammaRamp = X11_SetDisplayGammaRamp;
    15.6      device->GetDisplayGammaRamp = X11_GetDisplayGammaRamp;
    15.7 +    device->SuspendScreenSaver = X11_SuspendScreenSaver;
    15.8      device->PumpEvents = X11_PumpEvents;
    15.9  
   15.10      device->CreateWindow = X11_CreateWindow;
   15.11 @@ -224,11 +225,6 @@
   15.12      }
   15.13  #endif
   15.14  
   15.15 -    /* Save DPMS and screensaver settings */
   15.16 -    X11_SaveScreenSaver(data->display, &data->screensaver_timeout,
   15.17 -                        &data->dpms_enabled);
   15.18 -    X11_DisableScreenSaver(data->display);
   15.19 -
   15.20      /* Look up some useful Atoms */
   15.21      data->WM_DELETE_WINDOW =
   15.22          XInternAtom(data->display, "WM_DELETE_WINDOW", False);
   15.23 @@ -260,8 +256,6 @@
   15.24          XCloseIM(data->im);
   15.25      }
   15.26  #endif
   15.27 -    X11_RestoreScreenSaver(data->display, data->screensaver_timeout,
   15.28 -                           data->dpms_enabled);
   15.29  
   15.30      X11_QuitModes(_this);
   15.31      X11_QuitKeyboard(_this);
    16.1 --- a/src/video/x11/SDL_x11video.h	Sun Jan 11 23:56:19 2009 +0000
    16.2 +++ b/src/video/x11/SDL_x11video.h	Mon Jan 12 06:19:05 2009 +0000
    16.3 @@ -39,15 +39,12 @@
    16.4  #if SDL_VIDEO_DRIVER_X11_VIDMODE
    16.5  #include "../Xext/extensions/xf86vmode.h"
    16.6  #endif
    16.7 -#if SDL_VIDEO_DRIVER_X11_XME
    16.8 -#include "../Xext/extensions/xme.h"
    16.9 -#endif
   16.10 -#if SDL_VIDEO_DRIVER_X11_DPMS
   16.11 -#include <X11/extensions/dpms.h>
   16.12 -#endif
   16.13  #if SDL_VIDEO_DRIVER_X11_XINPUT
   16.14  #include <X11/extensions/XInput.h>
   16.15  #endif
   16.16 +#if SDL_VIDEO_DRIVER_X11_SCRNSAVER
   16.17 +#include <X11/extensions/scrnsaver.h>
   16.18 +#endif
   16.19  
   16.20  #include "SDL_x11dyn.h"
   16.21  
   16.22 @@ -66,8 +63,7 @@
   16.23      Display *display;
   16.24      char *classname;
   16.25      XIM im;
   16.26 -    int screensaver_timeout;
   16.27 -    BOOL dpms_enabled;
   16.28 +    Uint32 screensaver_activity;
   16.29      int numwindows;
   16.30      SDL_WindowData **windowlist;
   16.31      int windowlistlength;