mirror of
https://github.com/mpv-player/mpv
synced 2025-03-25 04:38:01 +00:00
Szebb es jobb screensaver-kikapcsolo resz
xmga, xv, x11 support (sdl comming soon) git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@325 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
fd9595e99b
commit
473f1b7b07
@ -28,7 +28,6 @@ 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
|
||||
@ -67,8 +66,6 @@ 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
|
||||
@ -340,24 +337,7 @@ static uint32_t init( uint32_t width,uint32_t height,uint32_t d_width,uint32_t d
|
||||
|
||||
// vo_initthread( mThread );
|
||||
|
||||
if (DPMSQueryExtension(mDisplay, ¬hing, ¬hing))
|
||||
{
|
||||
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
|
||||
|
||||
saver_off(mDisplay);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -535,49 +515,19 @@ static uint32_t draw_frame( uint8_t *src[] )
|
||||
static uint32_t query_format( uint32_t format )
|
||||
{
|
||||
if( !vo_init() ) return 0; // Can't open X11
|
||||
if( ( format&IMGFMT_BGR_MASK )==IMGFMT_BGR ){
|
||||
int bpp=format&0xFF;
|
||||
if( bpp==vo_depthonscreen ) return 1;
|
||||
if( bpp==15 && vo_depthonscreen==16) return 1; // built-in conversion
|
||||
if( bpp==24 && vo_depthonscreen==32) return 1; // built-in conversion
|
||||
}
|
||||
if( ( format&IMGFMT_BGR_MASK )==IMGFMT_BGR && ( format&0xFF )==vo_depthonscreen ) return 1;
|
||||
switch( format )
|
||||
{
|
||||
{
|
||||
case IMGFMT_YV12: return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
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, ¬hing, ¬hing))
|
||||
{
|
||||
printf ("Enabling DPMS\n");
|
||||
DPMSEnable(mDisplay); // restoring power saving settings
|
||||
DPMSQueryExtension(mDisplay, ¬hing, ¬hing);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
saver_on(mDisplay); // screen saver back on
|
||||
#ifdef HAVE_XF86VM
|
||||
if (vidmodes!=NULL)
|
||||
{
|
||||
|
@ -274,6 +274,8 @@ static uint32_t init( uint32_t width, uint32_t height, uint32_t d_width, uint32_
|
||||
XFlush( mDisplay );
|
||||
XSync( mDisplay,False );
|
||||
|
||||
saver_off(mDisplay);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -284,6 +286,7 @@ static const vo_info_t* get_info( void )
|
||||
static void
|
||||
uninit(void)
|
||||
{
|
||||
saver_on(mDisplay);
|
||||
ioctl( f,MGA_VID_OFF,0 );
|
||||
printf("vo: uninit!\n");
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ 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"
|
||||
@ -79,9 +78,6 @@ 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
|
||||
@ -89,7 +85,6 @@ static int dpms_disabled=0;
|
||||
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;
|
||||
@ -204,23 +199,7 @@ static uint32_t init(uint32_t width, uint32_t height, uint32_t d_width, uint32_t
|
||||
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, ¬hing, ¬hing))
|
||||
{
|
||||
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
|
||||
|
||||
saver_off(mydisplay); // turning off screen saver
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -412,25 +391,7 @@ static uint32_t query_format(uint32_t format)
|
||||
}
|
||||
|
||||
static void uninit(void) {
|
||||
int nothing;
|
||||
if (DPMSQueryExtension(mydisplay, ¬hing, ¬hing))
|
||||
{
|
||||
if (dpms_disabled)
|
||||
{
|
||||
DPMSEnable(mydisplay); // restoring power saving settings
|
||||
DPMSQueryExtension(mydisplay, ¬hing, ¬hing);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
saver_on(mydisplay); // screen saver back on
|
||||
}
|
||||
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#ifdef X11_FULLSCREEN
|
||||
|
||||
#include <X11/Xmd.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/Xatom.h>
|
||||
@ -20,6 +21,9 @@ int vo_screenheight=0;
|
||||
int vo_dwidth=0;
|
||||
int vo_dheight=0;
|
||||
|
||||
static int dpms_disabled=0;
|
||||
static int timeout_save=0;
|
||||
|
||||
int vo_init( void )
|
||||
{
|
||||
int CompletionType = -1;
|
||||
@ -151,3 +155,48 @@ int vo_x11_check_events(Display *mydisplay){
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void saver_on(Display *mDisplay) {
|
||||
|
||||
int nothing;
|
||||
if (dpms_disabled)
|
||||
{
|
||||
if (DPMSQueryExtension(mDisplay, ¬hing, ¬hing))
|
||||
{
|
||||
printf ("Enabling DPMS\n");
|
||||
DPMSEnable(mDisplay); // restoring power saving settings
|
||||
DPMSQueryExtension(mDisplay, ¬hing, ¬hing);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
XGetScreenSaver(mDisplay, &timeout_save, &interval, &prefer_blank, &allow_exp);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void saver_off(Display *mDisplay) {
|
||||
|
||||
int interval, prefer_blank, allow_exp, nothing;
|
||||
|
||||
if (DPMSQueryExtension(mDisplay, ¬hing, ¬hing))
|
||||
{
|
||||
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);
|
||||
// turning off screensaver
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
#include <X11/extensions/dpms.h>
|
||||
|
||||
#ifdef X11_FULLSCREEN
|
||||
|
||||
@ -10,6 +11,7 @@ extern int vo_dheight;
|
||||
int vo_init( void );
|
||||
void vo_x11_decoration( Display * vo_Display,Window w,int d );
|
||||
int vo_x11_check_events(Display *mydisplay);
|
||||
|
||||
#endif
|
||||
|
||||
void saver_off( Display * );
|
||||
void saver_on( Display * );
|
||||
|
Loading…
Reference in New Issue
Block a user