[MPlayer-dev-eng] [PATCH] xinerama fixes

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Sat Apr 15 18:29:28 CEST 2006


Hi,
the attached patch makes xinerama work for me.
since the current code produces no useable results at all for me, I
intend to apply very soon.
I moved the xinerama variables into video_out.c to avoid ifdefs and make
it easier to implement for other operating systems as well - and the
vo_directx specific -adapter option should probably be replaced as
well.
if you can, please test esp. more unusual vos like vo_xvidix.

Greetings,
Reimar Döffinger
-------------- next part --------------
diff -u libvo/video_out.c libvo/video_out.c
--- libvo/video_out.c	Fri Mar 17 12:26:22 2006
+++ libvo/video_out.c	Sat Apr 15 17:46:50 2006
@@ -19,6 +19,10 @@
 
 //int vo_flags=0;
 
+int xinerama_screen;
+int xinerama_x;
+int xinerama_y;
+
 // currect resolution/bpp on screen:  (should be autodetected by vo_init())
 int vo_depthonscreen=0;
 int vo_screenwidth=0;
diff -u libvo/video_out.h libvo/video_out.h
--- libvo/video_out.h	Fri Mar 17 12:26:22 2006
+++ libvo/video_out.h	Sat Apr 15 17:46:50 2006
@@ -179,6 +179,10 @@
 
 extern int vo_config_count;
 
+extern int xinerama_screen;
+extern int xinerama_x;
+extern int xinerama_y;
+
 // correct resolution/bpp on screen:  (should be autodetected by vo_init())
 extern int vo_depthonscreen;
 extern int vo_screenwidth;
diff -u libvo/vo_gl.c libvo/vo_gl.c
--- libvo/vo_gl.c	Wed Apr 12 16:26:30 2006
+++ libvo/vo_gl.c	Sat Apr 15 17:46:50 2006
@@ -311,13 +311,15 @@
 	panscan_init();
 	aspect_save_orig(width,height);
 	aspect_save_prescale(d_width,d_height);
-	aspect_save_screenres(vo_screenwidth,vo_screenheight);
+	update_xinerama_info();
 
 	aspect(&d_width,&d_height,A_NOZOOM);
 	vo_dx = (int)(vo_screenwidth - d_width) / 2;
 	vo_dy = (int)(vo_screenheight - d_height) / 2;
 	geometry(&vo_dx, &vo_dy, &d_width, &d_height,
 	          vo_screenwidth, vo_screenheight);
+	vo_dx += xinerama_x;
+	vo_dy += xinerama_y;
 #ifdef HAVE_NEW_GUI
   if (use_gui) {
     // GUI creates and manages window for us
@@ -379,9 +381,6 @@
 	  XSetStandardProperties(mDisplay, vo_window, title, title, None, NULL, 0, &hint);
 	  /* Map window. */
 	  XMapWindow(mDisplay, vo_window);
-#ifdef HAVE_XINERAMA
-	  vo_x11_xinerama_move(mDisplay,vo_window);
-#endif
 
 	  /* Wait for map. */
 	  do 
diff -u libvo/vo_gl2.c libvo/vo_gl2.c
--- libvo/vo_gl2.c	Wed Apr 12 16:26:30 2006
+++ libvo/vo_gl2.c	Sat Apr 15 17:46:50 2006
@@ -706,9 +706,6 @@
 
 	/* Map window. */
 	XMapWindow(mDisplay, vo_window);
-#ifdef HAVE_XINERAMA
-	vo_x11_xinerama_move(mDisplay,vo_window);
-#endif
 	vo_x11_sizehint( hint.x, hint.y, hint.width, hint.height,0 );
         XClearWindow(mDisplay,vo_window);
 
@@ -810,13 +807,15 @@
 	panscan_init();
 	aspect_save_orig(width,height);
 	aspect_save_prescale(d_width,d_height);
-	aspect_save_screenres(vo_screenwidth,vo_screenheight);
+	update_xinerama_info();
 
 	aspect(&d_width,&d_height,A_NOZOOM);
 	vo_dx = (int)(vo_screenwidth - d_width) / 2;
 	vo_dy = (int)(vo_screenheight - d_height) / 2;
 	geometry(&vo_dx, &vo_dy, &d_width, &d_height,
 	          vo_screenwidth, vo_screenheight);
+	vo_dx += xinerama_x;
+	vo_dy += xinerama_y;
 
 #if defined(HAVE_NEW_GUI) && !defined(GL_WIN32)
 	if (use_gui) {
diff -u libvo/vo_x11.c libvo/vo_x11.c
--- libvo/vo_x11.c	Fri Mar 17 12:26:24 2006
+++ libvo/vo_x11.c	Sat Apr 15 17:46:50 2006
@@ -286,10 +286,13 @@
     in_format = format;
     srcW = width;
     srcH = height;
+    update_xinerama_info();
     vo_dx = (vo_screenwidth - d_width) / 2;
     vo_dy = (vo_screenheight - d_height) / 2;
     geometry(&vo_dx, &vo_dy, &d_width, &d_height, vo_screenwidth,
              vo_screenheight);
+    vo_dx += xinerama_x;
+    vo_dy += xinerama_y;
     vo_dwidth = d_width;
     vo_dheight = d_height;
 
@@ -422,9 +425,6 @@
 
                 if (fullscreen)
                     vo_x11_fullscreen();
-#ifdef HAVE_XINERAMA
-                vo_x11_xinerama_move(mDisplay, vo_window);
-#endif
             } else if (!fullscreen)
                 XMoveResizeWindow(mDisplay, vo_window, vo_dx, vo_dy,
                                   vo_dwidth, vo_dheight);
diff -u libvo/vo_xmga.c libvo/vo_xmga.c
--- libvo/vo_xmga.c	Sat Aug  6 11:48:22 2005
+++ libvo/vo_xmga.c	Sat Apr 15 17:46:50 2006
@@ -127,7 +127,7 @@
 
     aspect_save_orig(width, height);
     aspect_save_prescale(d_width, d_height);
-    aspect_save_screenres(vo_screenwidth, vo_screenheight);
+    update_xinerama_info();
 
     mvWidth = width;
     mvHeight = height;
@@ -138,6 +138,8 @@
     vo_dy = (vo_screenheight - d_height) / 2;
     geometry(&vo_dx, &vo_dy, &d_width, &d_height, vo_screenwidth,
              vo_screenheight);
+    vo_dx += xinerama_x;
+    vo_dy += xinerama_y;
     vo_dwidth = d_width;
     vo_dheight = d_height;
     vo_mouse_autohide = 1;
@@ -241,9 +243,6 @@
                 if (flags & VOFLAG_FULLSCREEN)
                     vo_x11_fullscreen();
 
-#ifdef HAVE_XINERAMA
-                vo_x11_xinerama_move(mDisplay, vo_window);
-#endif
             } else if (!(flags & VOFLAG_FULLSCREEN))
                 XMoveResizeWindow(mDisplay, vo_window, vo_dx, vo_dy,
                                   vo_dwidth, vo_dheight);
diff -u libvo/vo_xover.c libvo/vo_xover.c
--- libvo/vo_xover.c	Sat Aug  6 11:48:22 2005
+++ libvo/vo_xover.c	Sat Apr 15 17:46:50 2006
@@ -228,10 +228,8 @@
 
   aspect_save_orig(width, height);
   aspect_save_prescale(d_width, d_height);
-  aspect_save_screenres(vo_screenwidth, vo_screenheight);
+  update_xinerama_info();
 
-  vo_dx = 0;
-  vo_dy = 0;
   window_width = d_width;
   window_height = d_height;
 
@@ -261,6 +259,8 @@
   aspect(&d_width, &d_height, A_NOZOOM);
 
   vo_dx=( vo_screenwidth - d_width ) / 2; vo_dy=( vo_screenheight - d_height ) / 2;    
+  vo_dx += xinerama_x;
+  vo_dy += xinerama_y;
   vo_dwidth=d_width; vo_dheight=d_height;
 
 #ifdef HAVE_NEW_GUI
@@ -320,9 +320,6 @@
     
 	      if ( flags&VOFLAG_FULLSCREEN ) vo_x11_fullscreen();
     
-#ifdef HAVE_XINERAMA
-	      vo_x11_xinerama_move(mDisplay, vo_window);
-#endif
 	    } else if ( !(flags&VOFLAG_FULLSCREEN) ) XMoveResizeWindow( mDisplay,vo_window,vo_dx,vo_dy,vo_dwidth,vo_dheight );
 	}
 	 
diff -u libvo/vo_xv.c libvo/vo_xv.c
--- libvo/vo_xv.c	Thu Nov 10 20:08:02 2005
+++ libvo/vo_xv.c	Sat Apr 15 17:46:50 2006
@@ -190,10 +190,13 @@
     int_pause = 0;
     visible_buf = -1;
 
+    update_xinerama_info();
     vo_dx = (vo_screenwidth - d_width) / 2;
     vo_dy = (vo_screenheight - d_height) / 2;
     geometry(&vo_dx, &vo_dy, &d_width, &d_height, vo_screenwidth,
              vo_screenheight);
+    vo_dx += xinerama_x;
+    vo_dy += xinerama_y;
     vo_dwidth = d_width;
     vo_dheight = d_height;
 
@@ -222,7 +225,6 @@
         if (!xv_format)
             return -1;
     }
-    aspect_save_screenres(vo_screenwidth, vo_screenheight);
 
 #ifdef HAVE_NEW_GUI
     if (use_gui)
@@ -348,12 +350,6 @@
             XMapWindow(mDisplay, vo_window);
             if (flags & VOFLAG_FULLSCREEN)
                 vo_x11_fullscreen();
-            else
-            {
-#ifdef HAVE_XINERAMA
-                vo_x11_xinerama_move(mDisplay, vo_window);
-#endif
-            }
         } else
         {
             // vo_fs set means we were already at fullscreen
diff -u libvo/vo_xvidix.c libvo/vo_xvidix.c
--- libvo/vo_xvidix.c	Sat Aug  6 11:48:22 2005
+++ libvo/vo_xvidix.c	Sat Apr 15 17:46:50 2006
@@ -371,9 +371,6 @@
                 if (flags & VOFLAG_FULLSCREEN)
                     vo_x11_fullscreen();
 
-#ifdef HAVE_XINERAMA
-                vo_x11_xinerama_move(mDisplay, vo_window);
-#endif
             } else if (!(flags & VOFLAG_FULLSCREEN))
                 XMoveResizeWindow(mDisplay, vo_window, vo_dx, vo_dy,
                                   vo_dwidth, vo_dheight);
diff -u libvo/vo_xvmc.c libvo/vo_xvmc.c
--- libvo/vo_xvmc.c	Sat Mar 25 20:38:38 2006
+++ libvo/vo_xvmc.c	Sat Apr 15 17:46:50 2006
@@ -604,16 +604,17 @@
 
    vo_mouse_autohide = 1;
 
+   update_xinerama_info();
    vo_dx=( vo_screenwidth - d_width ) / 2; vo_dy=( vo_screenheight - d_height ) / 2;
    geometry(&vo_dx, &vo_dy, &d_width, &d_height, vo_screenwidth, vo_screenheight);
+   vo_dx += xinerama_x;
+   vo_dy += xinerama_y;
    vo_dwidth=d_width; vo_dheight=d_height;
 
 #ifdef HAVE_XF86VM
    if( flags&VOFLAG_MODESWITCHING ) vm = 1;
 #endif
 
-   aspect_save_screenres(vo_screenwidth,vo_screenheight);
-
 #ifdef HAVE_NEW_GUI
    if(use_gui)
       guiGetEvent( guiSetShVideo,0 ); // let the GUI to setup/resize our window
@@ -702,9 +703,6 @@
 	 XMapWindow(mDisplay, vo_window);
 	 if ( flags&VOFLAG_FULLSCREEN ) vo_x11_fullscreen();
 	 else {
-#ifdef HAVE_XINERAMA
-	    vo_x11_xinerama_move(mDisplay,vo_window);
-#endif
 	    vo_x11_sizehint( hint.x, hint.y, hint.width, hint.height,0 );
 	 }
       } else {
diff -u libvo/w32_common.c libvo/w32_common.c
--- libvo/w32_common.c	Fri Apr 14 15:30:40 2006
+++ libvo/w32_common.c	Sat Apr 15 16:04:12 2006
@@ -25,10 +25,6 @@
 int prev_x;
 int prev_y;
 
-// top left coordinates of current monitor
-int vo_screenx;
-int vo_screeny;
-
 uint32_t o_dwidth;
 uint32_t o_dheight;
 
@@ -135,6 +131,21 @@
     return event_flags;
 }
 
+void update_xinerama_info(void) {
+    xinerama_x = xinerama_y = 0;
+    if (myMonitorFromWindow && myGetMonitorInfo) {
+        MONITORINFO mi;
+        HMONITOR m = myMonitorFromWindow(vo_window, MONITOR_DEFAULTTOPRIMARY);
+        mi.cbSize = sizeof(mi);
+        myGetMonitorInfo(m, &mi);
+        xinerama_x = mi.rcMonitor.left;
+        xinerama_y = mi.rcMonitor.top;
+        vo_screenwidth = mi.rcMonitor.right - mi.rcMonitor.left;
+        vo_screenheight = mi.rcMonitor.bottom - mi.rcMonitor.top;
+    }
+    aspect_save_screenres(vo_screenwidth, vo_screenheight);
+}
+
 static void updateScreenProperties() {
     DEVMODE dm;
     dm.dmSize = sizeof dm;
@@ -148,18 +159,7 @@
     vo_screenwidth = dm.dmPelsWidth;
     vo_screenheight = dm.dmPelsHeight;
     vo_depthonscreen = dm.dmBitsPerPel;
-    vo_screenx = vo_screeny = 0;
-    if (myMonitorFromWindow && myGetMonitorInfo) {
-        MONITORINFO mi;
-        HMONITOR m = myMonitorFromWindow(vo_window, MONITOR_DEFAULTTOPRIMARY);
-        mi.cbSize = sizeof(mi);
-        myGetMonitorInfo(m, &mi);
-        vo_screenx = mi.rcMonitor.left;
-        vo_screeny = mi.rcMonitor.top;
-        vo_screenwidth = mi.rcMonitor.right - mi.rcMonitor.left;
-        vo_screenheight = mi.rcMonitor.bottom - mi.rcMonitor.top;
-    }
-    aspect_save_screenres(vo_screenwidth, vo_screenheight);
+    update_xinerama_info();
 }
 
 static void changeMode(void) {
@@ -232,8 +232,8 @@
         prev_y = vo_dy;
         vo_dwidth = vo_screenwidth;
         vo_dheight = vo_screenheight;
-        vo_dx = vo_screenx;
-        vo_dy = vo_screeny;
+        vo_dx = xinerama_x;
+        vo_dy = xinerama_y;
     } else {
         vo_dwidth = prev_width;
         vo_dheight = prev_height;
diff -u libvo/x11_common.c libvo/x11_common.c
--- libvo/x11_common.c	Fri Mar 17 12:26:24 2006
+++ libvo/x11_common.c	Sat Apr 15 17:46:50 2006
@@ -108,11 +108,6 @@
 static int vo_old_width = 0;
 static int vo_old_height = 0;
 
-#ifdef HAVE_XINERAMA
-int xinerama_screen = 0;
-int xinerama_x = 0;
-int xinerama_y = 0;
-#endif
 #ifdef HAVE_XF86VM
 XF86VidModeModeInfo **vidmodes = NULL;
 XF86VidModeModeLine modeline;
@@ -364,6 +360,43 @@
     XA_INIT(_BLACKBOX_PID);
 }
 
+void update_xinerama_info(void) {
+    int screen = xinerama_screen;
+    xinerama_x = xinerama_y = 0;
+#ifdef HAVE_XINERAMA
+    if (screen >= -1 && XineramaIsActive(mDisplay))
+    {
+        XineramaScreenInfo *screens;
+        int num_screens;
+
+        screens = XineramaQueryScreens(mDisplay, &num_screens);
+        if (screen >= num_screens)
+            screen = num_screens - 1;
+        if (screen == -1) {
+            int x = vo_dx + vo_dwidth / 2;
+            int y = vo_dy + vo_dheight / 2;
+            for (screen = num_screens - 1; screen > 0; screen--) {
+               int left = screens[screen].x_org;
+               int right = left + screens[screen].width;
+               int top = screens[screen].y_org;
+               int bottom = top + screens[screen].height;
+               if (left <= x && x <= right && top <= y && y <= bottom)
+                   break;
+            }
+        }
+        if (screen < 0)
+            screen = 0;
+        vo_screenwidth = screens[screen].width;
+        vo_screenheight = screens[screen].height;
+        xinerama_x = screens[screen].x_org;
+        xinerama_y = screens[screen].y_org;
+
+        XFree(screens);
+    }
+    aspect_save_screenres(vo_screenwidth, vo_screenheight);
+#endif
+}
+
 int vo_init(void)
 {
 // int       mScreen;
@@ -411,25 +444,6 @@
 
     init_atoms();
 
-#ifdef HAVE_XINERAMA
-    if (XineramaIsActive(mDisplay))
-    {
-        XineramaScreenInfo *screens;
-        int num_screens;
-
-        screens = XineramaQueryScreens(mDisplay, &num_screens);
-        if (xinerama_screen >= num_screens)
-            xinerama_screen = 0;
-        if (!vo_screenwidth)
-            vo_screenwidth = screens[xinerama_screen].width;
-        if (!vo_screenheight)
-            vo_screenheight = screens[xinerama_screen].height;
-        xinerama_x = screens[xinerama_screen].x_org;
-        xinerama_y = screens[xinerama_screen].y_org;
-
-        XFree(screens);
-    } else
-#endif
 #ifdef HAVE_XF86VM
     {
         int clock;
@@ -1447,8 +1461,9 @@
             vo_old_y = vo_dy;
             vo_old_width = vo_dwidth;
             vo_old_height = vo_dheight;
-            x = 0;
-            y = 0;
+            update_xinerama_info();
+            x = xinerama_x;
+            y = xinerama_y;
             w = vo_screenwidth;
             h = vo_screenheight;
         }
@@ -1482,10 +1497,6 @@
     if ((!(vo_fs)) & vo_ontop)
         vo_x11_setlayer(mDisplay, vo_window, vo_ontop);
 
-#ifdef HAVE_XINERAMA
-    vo_x11_xinerama_move(mDisplay, vo_window);
-#endif
-
     XMapRaised(mDisplay, vo_window);
     XRaiseWindow(mDisplay, vo_window);
     XFlush(mDisplay);
@@ -1778,17 +1789,6 @@
     }
 }
 
-#ifdef HAVE_XINERAMA
-void vo_x11_xinerama_move(Display * dsp, Window w)
-{
-    if (XineramaIsActive(dsp) && !geometry_xy_changed)
-    {
-        /* printf("XXXX Xinerama screen: x: %hd y: %hd\n",xinerama_x,xinerama_y); */
-        XMoveWindow(dsp, w, xinerama_x, xinerama_y);
-    }
-}
-#endif
-
 #ifdef HAVE_XF86VM
 void vo_vm_switch(uint32_t X, uint32_t Y, int *modeline_width,
                   int *modeline_height)
diff -u libvo/x11_common.h libvo/x11_common.h
--- libvo/x11_common.h	Fri Mar 17 12:26:24 2006
+++ libvo/x11_common.h	Sat Apr 15 17:46:50 2006
@@ -114,10 +114,6 @@
 void saver_off( Display * );
 void saver_on( Display * );
 
-#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*);
Index: cfg-mplayer.h
===================================================================
RCS file: /cvsroot/mplayer/main/cfg-mplayer.h,v
retrieving revision 1.259
diff -u -r1.259 cfg-mplayer.h
--- cfg-mplayer.h	22 Mar 2006 16:35:16 -0000	1.259
+++ cfg-mplayer.h	15 Apr 2006 16:18:55 -0000
@@ -262,9 +264,7 @@
 	{"nomouseinput", &vo_nomouse_input, CONF_TYPE_FLAG,0,0,-1,NULL},
 #endif
 
-#ifdef HAVE_XINERAMA
-	{"xineramascreen", &xinerama_screen, CONF_TYPE_INT, CONF_RANGE, 0, 32, NULL},
-#endif
+	{"xineramascreen", &xinerama_screen, CONF_TYPE_INT, CONF_RANGE, -2, 32, NULL},
 
 	{"brightness",&vo_gamma_brightness, CONF_TYPE_INT, CONF_RANGE, -100, 100, NULL},
 	{"saturation",&vo_gamma_saturation, CONF_TYPE_INT, CONF_RANGE, -100, 100, NULL},
Index: DOCS/man/en/mplayer.1
===================================================================
RCS file: /cvsroot/mplayer/main/DOCS/man/en/mplayer.1,v
retrieving revision 1.1255
diff -u -r1.1255 mplayer.1
--- DOCS/man/en/mplayer.1	14 Apr 2006 13:27:55 -0000	1.1255
+++ DOCS/man/en/mplayer.1	15 Apr 2006 16:28:31 -0000
@@ -2594,9 +2601,14 @@
 Useful to embed MPlayer in a browser (e.g.\& the plugger extension).
 .
 .TP
-.B \-xineramascreen <0\-...>
+.B \-xineramascreen <\-2\-...> (X11 only)
 In Xinerama configurations (i.e.\& a single desktop that spans across multiple
 displays) this option tells MPlayer which screen to display the movie on.
+A value of -2 means fullscreen across the whole virtual display, -1 means
+fullscreen on the display the window currently is on.
+The initial position set via the -geometry option is relative to the
+specified screen.
+Will usually only work with "\-fstype \-fullscreen" or "\-fstype none".
 .
 .TP
 .B \-zrbw (\-vo zr only)


More information about the MPlayer-dev-eng mailing list