changeset 25466:9ee347c404c9

Add support for XScreenSaverSuspend
author reimar
date Sat, 22 Dec 2007 11:09:43 +0000
parents 6b9447dc7590
children 7bdd28e3fca7
files configure libvo/x11_common.c
diffstat 2 files changed, 46 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/configure	Sat Dec 22 08:35:15 2007 +0000
+++ b/configure	Sat Dec 22 11:09:43 2007 +0000
@@ -363,6 +363,7 @@
   --enable-xinerama        enable Xinerama support [autodetect]
   --enable-x11             enable X11 video output [autodetect]
   --enable-xshape          enable XShape support [autodetect]
+  --disable-xss            disable screensaver support via xss [autodetect]
   --enable-fbdev           enable FBDev video output [autodetect]
   --enable-mlib            enable mediaLib video output (Solaris) [disable]
   --enable-3dfx            enable obsolete /dev/3dfx video output [disable]
@@ -514,6 +515,7 @@
 _mplayer=yes
 _x11=auto
 _xshape=auto
+_xss=auto
 _dga1=auto
 _dga2=auto
 _xv=auto
@@ -812,6 +814,8 @@
   --disable-x11)	_x11=no		;;
   --enable-xshape)	_xshape=yes	;;
   --disable-xshape)	_xshape=no	;;
+  --enable-xss)	_xss=yes	;;
+  --disable-xss)	_xss=no	;;
   --enable-xv)		_xv=yes		;;
   --disable-xv)		_xv=no		;;
   --enable-xvmc)        _xvmc=yes       ;;
@@ -3907,6 +3911,26 @@
 fi
 echores "$_x11"
 
+echocheck "Xss screensaver extensions"
+if test "$_xss" = auto ; then
+  cat > $TMPC << EOF
+#include <X11/Xlib.h>
+#include <X11/extensions/scrnsaver.h>
+int main(void) {
+    XScreenSaverSuspend(NULL, True);
+    return 0;
+}
+EOF
+  _xss=no
+  cc_check -lXss && _xss=yes
+fi
+if test "$_xss" = yes ; then
+  _def_xss='#define HAVE_XSS 1'
+  _libs_mplayer="$_libs_mplayer -lXss"
+else
+  _def_xss='#undef HAVE_XSS'
+fi
+echores "$_xss"
 
 echocheck "DPMS"
 _xdpms3=no
@@ -8497,6 +8521,7 @@
 $_def_dvb_in
 $_def_svga
 $_def_vesa
+$_def_xss
 $_def_xdpms
 $_def_aa
 $_def_caca
--- a/libvo/x11_common.c	Sat Dec 22 08:35:15 2007 +0000
+++ b/libvo/x11_common.c	Sat Dec 22 11:09:43 2007 +0000
@@ -1702,6 +1702,22 @@
     xs_windowid = 0;
 }
 
+static int xss_suspend(Bool suspend)
+{
+#ifndef HAVE_XSS
+    return 0;
+#else
+    int event, error, major, minor;
+    if (XScreenSaverQueryExtension(mDisplay, &event, &error) != True ||
+        XScreenSaverQueryVersion(mDisplay, &major, &minor) != True)
+        return 0;
+    if (major < 1 || major == 1 && minor < 1)
+        return 0;
+    XScreenSaverSuspend(mDisplay, suspend);
+    return 1;
+#endif
+}
+
 /*
  * End of XScreensaver stuff
  */
@@ -1709,6 +1725,8 @@
 void saver_on(Display * mDisplay)
 {
 
+    if (xss_suspend(False))
+        return;
 #ifdef HAVE_XDPMS
     if (dpms_disabled)
     {
@@ -1767,9 +1785,11 @@
 
 void saver_off(Display * mDisplay)
 {
-#ifdef HAVE_XDPMS
     int nothing;
 
+    if (xss_suspend(True))
+        return;
+#ifdef HAVE_XDPMS
     if (DPMSQueryExtension(mDisplay, &nothing, &nothing))
     {
         BOOL onoff;