[MPlayer-dev-eng] vo_xv -vm patch
ralf willenbacher
b_j at gmx.net
Sun Nov 18 18:10:39 CET 2001
copy/pasted from vo_x11,
i got tired of some docking apps blocking the -fs view.
--
ralf willenbacher (bj at ocrana.de)
-------------- next part --------------
--- vo_xv.c.org Thu Oct 18 02:42:20 2001
+++ vo_xv.c Sun Nov 18 16:58:12 2001
@@ -15,6 +15,7 @@
* Xv image suuport by Gerd Knorr <kraxel at goldbach.in-berlin.de>
* fullscreen support by Pontscho
* double buffering support by A'rpi
+ * copy/paste from vo_x11 by me
*/
#include <stdio.h>
@@ -30,6 +31,10 @@
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/extensions/XShm.h>
+#ifdef HAVE_XF86VM
+#include <X11/extensions/xf86vmode.h>
+#endif
+
#include <errno.h>
#include "x11_common.h"
@@ -96,6 +101,12 @@
#endif
+static uint32_t xv_doVM;
+#ifdef HAVE_XF86VM
+static XF86VidModeModeInfo **xv_vidmodes=NULL;
+#endif
+
+
static void (*draw_alpha_fnc)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride);
static void draw_alpha_yv12(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){
@@ -121,6 +132,7 @@
static uint32_t init(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format)
{
// int screen;
+ unsigned int modeline_width, modeline_height;
char *hello = (title == NULL) ? "Xv render" : title;
// char *name = ":0.0";
XSizeHints hint;
@@ -145,12 +157,62 @@
#endif
mFullscreen=flags&1;
+ xv_doVM = flags & 0x2;
+
+ dwidth=d_width; dheight=d_height;
num_buffers=vo_doublebuffering?NUM_BUFFERS:1;
if (!vo_init()) return -1;
aspect_save_screenres(vo_screenwidth,vo_screenheight);
+#ifdef HAVE_XF86VM
+ if (xv_doVM) {
+ unsigned int vm_event, vm_error;
+ unsigned int vm_ver, vm_rev;
+ int i,j,have_vm=0,X,Y;
+
+ 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 (xv_vidmodes==NULL)
+ XF86VidModeGetAllModeLines(mDisplay,mScreen,&modecount,&xv_vidmodes);
+ j=0;
+ modeline_width=xv_vidmodes[0]->hdisplay;
+ modeline_height=xv_vidmodes[0]->vdisplay;
+ if ((d_width==0) && (d_height==0))
+ { X=image_width; Y=image_height; }
+ else
+ { X=d_width; Y=d_height; }
+
+ for (i=1; i<modecount; i++)
+ if ((xv_vidmodes[i]->hdisplay >= X) && (xv_vidmodes[i]->vdisplay >= Y))
+ if ( (xv_vidmodes[i]->hdisplay < modeline_width ) && (xv_vidmodes[i]->vdisplay < modeline_height) )
+ {
+ modeline_width=xv_vidmodes[i]->hdisplay;
+ modeline_height=xv_vidmodes[i]->vdisplay;
+ j=i;
+ }
+
+ printf("XF86VM: Selected video mode %dx%d for image size %dx%d.\n",modeline_width, modeline_height, image_width, image_height);
+ XF86VidModeLockModeSwitch(mDisplay,mScreen,0);
+ XF86VidModeSwitchToMode(mDisplay,mScreen,xv_vidmodes[j]);
+ XF86VidModeSwitchToMode(mDisplay,mScreen,xv_vidmodes[j]);
+ X=(vo_screenwidth-modeline_width)/2;
+ Y=(vo_screenheight-modeline_height)/2;
+ XF86VidModeSetViewPort(mDisplay,mScreen,X,Y);
+ }
+ }
+#endif
+
+
#ifdef HAVE_NEW_GUI
if ( vo_window == None )
{
@@ -159,9 +221,23 @@
hint.y = 0;
hint.width = d_width;
hint.height = d_height;
- aspect(&d_width,&d_height,A_NOZOOM);
- if ( mFullscreen )
+ aspect(&d_width,&d_height,A_NOZOOM);
+ if(xv_doVM)
+ {
+ hint.x=(vo_screenwidth-modeline_width)/2;
+ hint.y=(vo_screenheight-modeline_height)/2;
+ hint.width = modeline_width;
+ hint.height = modeline_height;
+#ifdef X11_FULLSCREEN
+ aspect_save_screenres(modeline_width, modeline_height);
+ aspect(&d_width,&d_height,A_ZOOM);
+ dwidth=d_width; dheight=d_height;
+ vo_screenwidth = modeline_width;
+ vo_screenheight = modeline_height;
+#endif
+/* printf("%d %d -> %d %d\n", modeline_width, modeline_height, dwidth, dheight); */
+ }else if ( mFullscreen )
{
hint.width=vo_screenwidth;
hint.height=vo_screenheight;
@@ -173,11 +249,13 @@
* irritated for now (and send lots o' mails ;) ::atmos
*/
- aspect(&d_width,&d_height,A_ZOOM);
+ {
+ aspect(&d_width,&d_height,A_ZOOM);
+ dwidth=d_width; dheight=d_height;
+ }
#endif
}
- dwidth=d_width; dheight=d_height; //XXX: what are the copy vars used for?
hint.flags = PPosition | PSize;
XGetWindowAttributes(mDisplay, DefaultRootWindow(mDisplay), &attribs);
depth=attribs.depth;
@@ -188,6 +266,12 @@
xswa.border_pixel = 0;
xswamask = CWBackPixel | CWBorderPixel;
+ if(xv_doVM)
+ {
+ xswa.override_redirect=True;
+ xswamask|=CWOverrideRedirect;
+ }
+
mywindow = XCreateWindow(mDisplay, RootWindow(mDisplay,mScreen),
hint.x, hint.y, hint.width, hint.height,
0, depth,CopyFromParent,vinfo.visual,xswamask,&xswa);
@@ -196,11 +280,15 @@
XSelectInput(mDisplay, mywindow, StructureNotifyMask | KeyPressMask );
XSetStandardProperties(mDisplay, mywindow, hello, hello, None, NULL, 0, &hint);
- if ( mFullscreen ) vo_x11_decoration( mDisplay,mywindow,0 );
+ if ( mFullscreen || xv_doVM) vo_x11_decoration( mDisplay,mywindow,0 );
XMapWindow(mDisplay, mywindow);
- mygc = XCreateGC(mDisplay, mywindow, 0L, &xgcv);
+ do { XNextEvent( mDisplay,&xev ); } while ( xev.type != MapNotify || xev.xmap.event != mywindow );
+
+ XSelectInput( mDisplay,mywindow,NoEventMask );
+
XFlush(mDisplay);
XSync(mDisplay, False);
+ mygc = XCreateGC(mDisplay, mywindow, 0L, &xgcv);
#ifdef HAVE_NEW_GUI
}
else
@@ -210,6 +298,19 @@
}
#endif
+#ifdef HAVE_XF86VM
+
+ if ( xv_doVM )
+ {
+ XGrabPointer(mDisplay, mywindow, True, 0,
+ GrabModeAsync, GrabModeAsync,
+ mywindow, None, CurrentTime);
+ XSetInputFocus(mDisplay, mywindow, RevertToNone, CurrentTime);
+ }
+
+#endif
+
+
xv_port = 0;
if (Success == XvQueryExtension(mDisplay,&ver,&rel,&req,&ev,&err))
{
@@ -286,7 +387,7 @@
XTranslateCoordinates( mDisplay,mywindow,mRoot,0,0,&drwcX,&drwcY,&mRoot );
printf( "[xv] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight );
- if ( mFullscreen )
+ if ( mFullscreen || xv_doVM)
{
drwX=( vo_screenwidth - (dwidth > vo_screenwidth?vo_screenwidth:dwidth) ) / 2;
drwcX+=drwX;
@@ -299,7 +400,10 @@
#ifdef HAVE_NEW_GUI
if ( vo_window == None )
#endif
+ {
saver_off(mDisplay); // turning off screen saver
+ XSelectInput( mDisplay,mywindow,StructureNotifyMask | KeyPressMask ); /* dunno */
+ }
return 0;
}
}
@@ -365,7 +469,7 @@
}
#endif
- if ( mFullscreen )
+ if ( mFullscreen || xv_doVM)
{
drwX=( vo_screenwidth - (dwidth > vo_screenwidth?vo_screenwidth:dwidth) ) / 2;
drwcX+=drwX;
@@ -509,6 +613,14 @@
saver_on(mDisplay); // screen saver back on
XDestroyWindow( mDisplay,mywindow );
}
+#ifdef HAVE_XF86VM
+ if(xv_doVM)
+ {
+ XF86VidModeSwitchToMode(mDisplay,mScreen,xv_vidmodes[0]);
+ XF86VidModeSwitchToMode(mDisplay,mScreen,xv_vidmodes[0]);
+ free(xv_vidmodes);
+ }
+#endif
for( i=0;i<num_buffers;i++ ) deallocate_xvimage( i );
}
More information about the MPlayer-dev-eng
mailing list