# HG changeset patch # User arpi # Date 1012437447 0 # Node ID 6144f63cbaa14d89460abd783a1241738e9b1442 # Parent 561de830fdf126af4273f0cd7e01fe648cfad7c4 common -vm code, patch by Santi Bjar diff -r 561de830fdf1 -r 6144f63cbaa1 libvo/x11_common.c --- a/libvo/x11_common.c Thu Jan 31 00:32:04 2002 +0000 +++ b/libvo/x11_common.c Thu Jan 31 00:37:27 2002 +0000 @@ -25,6 +25,10 @@ #include #endif +#ifdef HAVE_XF86VM +#include +#endif + /* * If SCAN_VISUALS is defined, vo_init() scans all available TrueColor * visuals for the 'best' visual for MPlayer video display. Note that @@ -54,6 +58,10 @@ int xinerama_y = 0; #endif +#ifdef HAVE_XF86VM +XF86VidModeModeInfo **vidmodes=NULL; +#endif + void vo_hidecursor ( Display *disp , Window win ) { Cursor no_ptr; @@ -498,4 +506,62 @@ } #endif +#ifdef HAVE_XF86VM +void vo_vm_switch(uint32_t X, uint32_t Y, int* modeline_width, int* modeline_height) +{ + unsigned int vm_event, vm_error; + unsigned int vm_ver, vm_rev; + int i,j,have_vm=0; + + int modecount; + + if (XF86VidModeQueryExtension(mDisplay, &vm_event, &vm_error)) { + XF86VidModeQueryVersion(mDisplay, &vm_ver, &vm_rev); + printf("XF86VidMode Extension v%i.%i\n", vm_ver, vm_rev); + have_vm=1; + } else + printf("XF86VidMode Extenstion not available.\n"); + + if (have_vm) { + if (vidmodes==NULL) + XF86VidModeGetAllModeLines(mDisplay,mScreen,&modecount,&vidmodes); + j=0; + *modeline_width=vidmodes[0]->hdisplay; + *modeline_height=vidmodes[0]->vdisplay; + + for (i=1; ihdisplay >= X) && (vidmodes[i]->vdisplay >= Y)) + if ( (vidmodes[i]->hdisplay < *modeline_width ) && (vidmodes[i]->vdisplay < *modeline_height) ) + { + *modeline_width=vidmodes[i]->hdisplay; + *modeline_height=vidmodes[i]->vdisplay; + j=i; + } + + printf("XF86VM: Selected video mode %dx%d for image size %dx%d.\n",*modeline_width, *modeline_height, X, Y); + XF86VidModeLockModeSwitch(mDisplay,mScreen,0); + XF86VidModeSwitchToMode(mDisplay,mScreen,vidmodes[j]); + XF86VidModeSwitchToMode(mDisplay,mScreen,vidmodes[j]); + X=(vo_screenwidth-*modeline_width)/2; + Y=(vo_screenheight-*modeline_height)/2; + XF86VidModeSetViewPort(mDisplay,mScreen,X,Y); + } +} + +void vo_vm_close(Display *dpy) +{ + #ifdef HAVE_NEW_GUI + if ((vidmodes!=NULL)&&( vo_window == None ) ) + #else + if (vidmodes!=NULL) + #endif + { + int screen; screen=DefaultScreen( dpy ); + XF86VidModeSwitchToMode(dpy,screen,vidmodes[0]); + XF86VidModeSwitchToMode(dpy,screen,vidmodes[0]); + free(vidmodes); + } +} #endif + +#endif diff -r 561de830fdf1 -r 6144f63cbaa1 libvo/x11_common.h --- a/libvo/x11_common.h Thu Jan 31 00:32:04 2002 +0000 +++ b/libvo/x11_common.h Thu Jan 31 00:37:27 2002 +0000 @@ -41,3 +41,8 @@ #ifdef HAVE_XINERAMA void vo_x11_xinerama_move(Display *dsp, Window w); #endif + +#ifdef HAVE_XF86VM +void vo_vm_switch(uint32_t, uint32_t, int*, int*); +void vo_vm_close(Display*); +#endif