comparison libvo/vo_x11.c @ 322:4e69a8e2700a

Screensaver and monitor powersafe function is switched off when playing a movie.
author laaz
date Mon, 09 Apr 2001 22:27:27 +0000
parents 828ec81e0d64
children 720c640332c8
comparison
equal deleted inserted replaced
321:237b5f54bb78 322:4e69a8e2700a
26 LIBVO_EXTERN( x11 ) 26 LIBVO_EXTERN( x11 )
27 27
28 #include <X11/Xlib.h> 28 #include <X11/Xlib.h>
29 #include <X11/Xutil.h> 29 #include <X11/Xutil.h>
30 #include <X11/extensions/XShm.h> 30 #include <X11/extensions/XShm.h>
31 #include <X11/extensions/dpms.h>
31 #ifdef HAVE_XF86VM 32 #ifdef HAVE_XF86VM
32 #include <X11/extensions/xf86vmode.h> 33 #include <X11/extensions/xf86vmode.h>
33 #endif 34 #endif
34 #include <errno.h> 35 #include <errno.h>
35 #include "yuv2rgb.h" 36 #include "yuv2rgb.h"
64 static XImage *myximage; 65 static XImage *myximage;
65 static int depth,bpp,mode; 66 static int depth,bpp,mode;
66 static XWindowAttributes attribs; 67 static XWindowAttributes attribs;
67 static int X_already_started=0; 68 static int X_already_started=0;
68 69
70 static int timeout_save=0;
71 static int dpms_disabled=0;
69 //static int vo_dwidth,vo_dheight; 72 //static int vo_dwidth,vo_dheight;
70 73
71 #define SH_MEM 74 #define SH_MEM
72 75
73 #ifdef SH_MEM 76 #ifdef SH_MEM
109 } 112 }
110 113
111 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 ) 114 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 )
112 { 115 {
113 int screen; 116 int screen;
117 int interval, prefer_blank, allow_exp, nothing;
114 unsigned int fg,bg; 118 unsigned int fg,bg;
115 char *hello=( title == NULL ) ? "X11 render" : title; 119 char *hello=( title == NULL ) ? "X11 render" : title;
116 char *name=":0.0"; 120 char *name=":0.0";
117 XSizeHints hint; 121 XSizeHints hint;
118 XVisualInfo vinfo; 122 XVisualInfo vinfo;
136 if ( mDisplay == NULL ) 140 if ( mDisplay == NULL )
137 { 141 {
138 fprintf( stderr,"Can not open display\n" ); 142 fprintf( stderr,"Can not open display\n" );
139 return -1; 143 return -1;
140 } 144 }
141
142 screen=DefaultScreen( mDisplay ); 145 screen=DefaultScreen( mDisplay );
143 146
144 hint.x=0; 147 hint.x=0;
145 hint.y=0; 148 hint.y=0;
146 hint.width=image_width; 149 hint.width=image_width;
334 337
335 XSelectInput( mDisplay,mywindow,StructureNotifyMask | KeyPressMask ); 338 XSelectInput( mDisplay,mywindow,StructureNotifyMask | KeyPressMask );
336 X_already_started++; 339 X_already_started++;
337 340
338 // vo_initthread( mThread ); 341 // vo_initthread( mThread );
342
343 if (DPMSQueryExtension(mDisplay, &nothing, &nothing))
344 {
345 BOOL onoff;
346 CARD16 state;
347 DPMSInfo(mDisplay, &state, &onoff);
348 if (onoff)
349 {
350 printf ("Disabling DPMS\n");
351 dpms_disabled=1;
352 DPMSDisable(mDisplay); // monitor powersave off
353 }
354 }
355
356 XGetScreenSaver(mDisplay, &timeout_save, &interval, &prefer_blank, &allow_exp);
357 if (timeout_save)
358 XSetScreenSaver(mDisplay, 0, interval, prefer_blank, allow_exp);
359 // switching off screensaver
339 360
340 return 0; 361 return 0;
341 } 362 }
342 363
343 static const vo_info_t* get_info( void ) 364 static const vo_info_t* get_info( void )
526 } 547 }
527 return 0; 548 return 0;
528 } 549 }
529 550
530 551
552
531 static void 553 static void
532 uninit(void) 554 uninit(void)
533 { 555 {
556
557 int nothing;
558
559 // DMPSEnable doesn't work if there isn't a DPMSQueryExtension after it.
560 // XSetScreenSaver doesn't work if there isn't an XGetScreensaver after it.
561
562 if (dpms_disabled)
563 {
564 if (DPMSQueryExtension(mDisplay, &nothing, &nothing))
565 {
566 printf ("Enabling DPMS\n");
567 DPMSEnable(mDisplay); // restoring power saving settings
568 DPMSQueryExtension(mDisplay, &nothing, &nothing);
569 }
570 }
571
572 if (timeout_save)
573 {
574 int dummy, interval, prefer_blank, allow_exp;
575 XGetScreenSaver(mDisplay, &dummy, &interval, &prefer_blank, &allow_exp);
576 XSetScreenSaver(mDisplay, timeout_save, interval, prefer_blank, allow_exp); // screensaver
577 XGetScreenSaver(mDisplay, &timeout_save, &interval, &prefer_blank, &allow_exp);
578 }
579
580
534 #ifdef HAVE_XF86VM 581 #ifdef HAVE_XF86VM
535 if (vidmodes!=NULL) 582 if (vidmodes!=NULL)
536 { 583 {
537 int screen; screen=DefaultScreen( mDisplay ); 584 int screen; screen=DefaultScreen( mDisplay );
538 XF86VidModeSwitchToMode(mDisplay,screen,vidmodes[0]); 585 XF86VidModeSwitchToMode(mDisplay,screen,vidmodes[0]);