summaryrefslogtreecommitdiffstats
path: root/libvo
diff options
context:
space:
mode:
authorlaaz <laaz@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-04-09 22:27:27 +0000
committerlaaz <laaz@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-04-09 22:27:27 +0000
commit77f6df6ba711ed88ffb3cb49da6b37637dc36e4e (patch)
tree9b43546fb3debc10d09867ce7b722968e7a6934f /libvo
parentca34f5e699df0478f0d1842a8c766d472ec3e1a6 (diff)
downloadmpv-77f6df6ba711ed88ffb3cb49da6b37637dc36e4e.tar.bz2
mpv-77f6df6ba711ed88ffb3cb49da6b37637dc36e4e.tar.xz
Screensaver and monitor powersafe function is switched off when playing a
movie. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@323 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libvo')
-rw-r--r--libvo/vo_x11.c49
-rw-r--r--libvo/vo_xv.c45
2 files changed, 92 insertions, 2 deletions
diff --git a/libvo/vo_x11.c b/libvo/vo_x11.c
index 49c5c61f44..d10dbfb2f7 100644
--- a/libvo/vo_x11.c
+++ b/libvo/vo_x11.c
@@ -28,6 +28,7 @@ LIBVO_EXTERN( x11 )
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/extensions/XShm.h>
+#include <X11/extensions/dpms.h>
#ifdef HAVE_XF86VM
#include <X11/extensions/xf86vmode.h>
#endif
@@ -66,6 +67,8 @@ static int depth,bpp,mode;
static XWindowAttributes attribs;
static int X_already_started=0;
+static int timeout_save=0;
+static int dpms_disabled=0;
//static int vo_dwidth,vo_dheight;
#define SH_MEM
@@ -111,6 +114,7 @@ static void check_events(){
static uint32_t init( uint32_t width,uint32_t height,uint32_t d_width,uint32_t d_height,uint32_t fullscreen,char *title,uint32_t format )
{
int screen;
+ int interval, prefer_blank, allow_exp, nothing;
unsigned int fg,bg;
char *hello=( title == NULL ) ? "X11 render" : title;
char *name=":0.0";
@@ -138,7 +142,6 @@ static uint32_t init( uint32_t width,uint32_t height,uint32_t d_width,uint32_t d
fprintf( stderr,"Can not open display\n" );
return -1;
}
-
screen=DefaultScreen( mDisplay );
hint.x=0;
@@ -337,6 +340,24 @@ static uint32_t init( uint32_t width,uint32_t height,uint32_t d_width,uint32_t d
// vo_initthread( mThread );
+ if (DPMSQueryExtension(mDisplay, &nothing, &nothing))
+ {
+ BOOL onoff;
+ CARD16 state;
+ DPMSInfo(mDisplay, &state, &onoff);
+ if (onoff)
+ {
+ printf ("Disabling DPMS\n");
+ dpms_disabled=1;
+ DPMSDisable(mDisplay); // monitor powersave off
+ }
+ }
+
+ XGetScreenSaver(mDisplay, &timeout_save, &interval, &prefer_blank, &allow_exp);
+ if (timeout_save)
+ XSetScreenSaver(mDisplay, 0, interval, prefer_blank, allow_exp);
+ // switching off screensaver
+
return 0;
}
@@ -528,9 +549,35 @@ static uint32_t query_format( uint32_t format )
}
+
static void
uninit(void)
{
+
+ int nothing;
+
+// DMPSEnable doesn't work if there isn't a DPMSQueryExtension after it.
+// XSetScreenSaver doesn't work if there isn't an XGetScreensaver after it.
+
+if (dpms_disabled)
+ {
+ if (DPMSQueryExtension(mDisplay, &nothing, &nothing))
+ {
+ printf ("Enabling DPMS\n");
+ DPMSEnable(mDisplay); // restoring power saving settings
+ DPMSQueryExtension(mDisplay, &nothing, &nothing);
+ }
+ }
+
+ if (timeout_save)
+ {
+ int dummy, interval, prefer_blank, allow_exp;
+ XGetScreenSaver(mDisplay, &dummy, &interval, &prefer_blank, &allow_exp);
+ XSetScreenSaver(mDisplay, timeout_save, interval, prefer_blank, allow_exp); // screensaver
+ XGetScreenSaver(mDisplay, &timeout_save, &interval, &prefer_blank, &allow_exp);
+ }
+
+
#ifdef HAVE_XF86VM
if (vidmodes!=NULL)
{
diff --git a/libvo/vo_xv.c b/libvo/vo_xv.c
index 06d38097fb..d0629b3908 100644
--- a/libvo/vo_xv.c
+++ b/libvo/vo_xv.c
@@ -24,6 +24,7 @@ LIBVO_EXTERN(xv)
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/extensions/XShm.h>
+#include <X11/extensions/dpms.h>
#include <errno.h>
#include "x11_common.h"
@@ -78,6 +79,9 @@ static Window mRoot;
static uint32_t drwX,drwY,drwWidth,drwHeight,drwBorderWidth,drwDepth;
static uint32_t drwcX,drwcY,dwidth,dheight,mFullscreen;
+static int timeout_save=0;
+static int dpms_disabled=0;
+
/*
* connect to server, create and map window,
* allocate colors and (shared) memory
@@ -85,6 +89,7 @@ static uint32_t drwcX,drwcY,dwidth,dheight,mFullscreen;
static uint32_t init(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t fullscreen, char *title, uint32_t format)
{
int screen;
+ int nothing, interval, prefer_blank, allow_exp;
char *hello = (title == NULL) ? "Xv render" : title;
char *name = ":0.0";
XSizeHints hint;
@@ -198,6 +203,24 @@ static uint32_t init(uint32_t width, uint32_t height, uint32_t d_width, uint32_t
drwHeight=(dheight > vo_screenheight?vo_screenheight:dheight);
fprintf( stderr,"[xv-fs] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight );
}
+
+ if (DPMSQueryExtension(mydisplay, &nothing, &nothing))
+ {
+ BOOL onoff;
+ CARD16 state;
+ DPMSInfo(mydisplay, &state, &onoff);
+ if (onoff)
+ {
+ dpms_disabled=1;
+ DPMSDisable(mydisplay); // monitor powersave off
+ }
+ }
+
+ XGetScreenSaver(mydisplay, &timeout_save, &interval, &prefer_blank, &allow_exp);
+ if (timeout_save)
+ XSetScreenSaver(mydisplay, 0, interval, prefer_blank, allow_exp);
+ // switching off screensaver
+
return 0;
}
}
@@ -388,7 +411,27 @@ static uint32_t query_format(uint32_t format)
return 0;
}
-static void uninit(void) { }
+static void uninit(void) {
+ int nothing;
+ if (DPMSQueryExtension(mydisplay, &nothing, &nothing))
+ {
+ if (dpms_disabled)
+ {
+ DPMSEnable(mydisplay); // restoring power saving settings
+ DPMSQueryExtension(mydisplay, &nothing, &nothing);
+ }
+ }
+
+ if (timeout_save)
+ {
+ int interval, prefer_blank, allow_exp, dummy;
+ XGetScreenSaver(mydisplay, &dummy, &interval, &prefer_blank, &allow_exp);
+ XSetScreenSaver(mydisplay, timeout_save, interval, prefer_blank, allow_exp);
+ XGetScreenSaver(mydisplay, &timeout_save, &interval, &prefer_blank, &allow_exp);
+ }
+
+
+}