[MPlayer-cvslog] CVS: main/libvo video_out.c, 1.104, 1.105 video_out.h, 1.63, 1.64 vo_gl.c, 1.118, 1.119 vo_gl2.c, 1.88, 1.89 vo_x11.c, 1.146, 1.147 vo_xmga.c, 1.94, 1.95 vo_xover.c, 1.14, 1.15 vo_xv.c, 1.169, 1.170 vo_xvidix.c, 1.74, 1.75 vo_xvmc.c, 1.26, 1.27 w32_common.c, 1.23, 1.24 x11_common.c, 1.205, 1.206 x11_common.h, 1.45, 1.46

Reimar Döffinger CVS syncmail at mplayerhq.hu
Sun Apr 16 15:38:31 CEST 2006


CVS change done by Reimar Döffinger CVS

Update of /cvsroot/mplayer/main/libvo
In directory mail:/var2/tmp/cvs-serv25793/libvo

Modified Files:
	video_out.c video_out.h vo_gl.c vo_gl2.c vo_x11.c vo_xmga.c 
	vo_xover.c vo_xv.c vo_xvidix.c vo_xvmc.c w32_common.c 
	x11_common.c x11_common.h 
Log Message:
Fix and improve xinerama support


Index: video_out.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/video_out.c,v
retrieving revision 1.104
retrieving revision 1.105
diff -u -r1.104 -r1.105
--- video_out.c	9 Feb 2006 14:07:59 -0000	1.104
+++ video_out.c	16 Apr 2006 13:38:28 -0000	1.105
@@ -19,6 +19,10 @@
 
 //int vo_flags=0;
 
+int xinerama_screen = -1;
+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;

Index: video_out.h
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/video_out.h,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -r1.63 -r1.64
--- video_out.h	9 Feb 2006 14:07:59 -0000	1.63
+++ video_out.h	16 Apr 2006 13:38:28 -0000	1.64
@@ -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;

Index: vo_gl.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_gl.c,v
retrieving revision 1.118
retrieving revision 1.119
diff -u -r1.118 -r1.119
--- vo_gl.c	12 Apr 2006 14:11:26 -0000	1.118
+++ vo_gl.c	16 Apr 2006 13:38:28 -0000	1.119
@@ -310,13 +310,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
@@ -378,9 +380,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 

Index: vo_gl2.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_gl2.c,v
retrieving revision 1.88
retrieving revision 1.89
diff -u -r1.88 -r1.89
--- vo_gl2.c	12 Apr 2006 14:11:26 -0000	1.88
+++ vo_gl2.c	16 Apr 2006 13:38:28 -0000	1.89
@@ -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) {

Index: vo_x11.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_x11.c,v
retrieving revision 1.146
retrieving revision 1.147
diff -u -r1.146 -r1.147
--- vo_x11.c	9 Mar 2006 18:05:38 -0000	1.146
+++ vo_x11.c	16 Apr 2006 13:38:28 -0000	1.147
@@ -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);

Index: vo_xmga.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_xmga.c,v
retrieving revision 1.94
retrieving revision 1.95
diff -u -r1.94 -r1.95
--- vo_xmga.c	5 Aug 2005 01:24:37 -0000	1.94
+++ vo_xmga.c	16 Apr 2006 13:38:28 -0000	1.95
@@ -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);

Index: vo_xover.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_xover.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- vo_xover.c	5 Aug 2005 01:24:37 -0000	1.14
+++ vo_xover.c	16 Apr 2006 13:38:28 -0000	1.15
@@ -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 );
 	}
 	 

Index: vo_xv.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_xv.c,v
retrieving revision 1.169
retrieving revision 1.170
diff -u -r1.169 -r1.170
--- vo_xv.c	10 Nov 2005 02:39:31 -0000	1.169
+++ vo_xv.c	16 Apr 2006 13:38:28 -0000	1.170
@@ -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

Index: vo_xvidix.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_xvidix.c,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -r1.74 -r1.75
--- vo_xvidix.c	5 Aug 2005 01:24:37 -0000	1.74
+++ vo_xvidix.c	16 Apr 2006 13:38:28 -0000	1.75
@@ -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);

Index: vo_xvmc.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_xvmc.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- vo_xvmc.c	24 Mar 2006 08:12:02 -0000	1.26
+++ vo_xvmc.c	16 Apr 2006 13:38:28 -0000	1.27
@@ -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 {

Index: w32_common.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/w32_common.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- w32_common.c	14 Apr 2006 11:23:03 -0000	1.23
+++ w32_common.c	16 Apr 2006 13:38:28 -0000	1.24
@@ -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;
 
@@ -36,9 +32,11 @@
 HWND vo_window = 0;
 static int cursor = 1;
 static int event_flags;
+static int mon_cnt;
 
 static HMONITOR (WINAPI* myMonitorFromWindow)(HWND, DWORD);
 static BOOL (WINAPI* myGetMonitorInfo)(HMONITOR, LPMONITORINFO);
+static BOOL (WINAPI* myEnumDisplayMonitors)(HDC, LPCRECT, MONITORENUMPROC, LPARAM);
 
 static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
     RECT r;
@@ -135,6 +133,44 @@
     return event_flags;
 }
 
+static BOOL CALLBACK mon_enum(HMONITOR hmon, HDC hdc, LPRECT r, LPARAM p) {
+    // this defaults to the last screen if specified number does not exist
+    xinerama_x = r->left;
+    xinerama_y = r->top;
+    vo_screenwidth = r->right - r->left;
+    vo_screenheight = r->bottom - r->top;
+    if (mon_cnt == xinerama_screen)
+        return FALSE;
+    mon_cnt++;
+    return TRUE;
+}
+
+void update_xinerama_info(void) {
+    xinerama_x = xinerama_y = 0;
+    if (xinerama_screen < -1) {
+        int tmp;
+        xinerama_x = GetSystemMetrics(SM_XVIRTUALSCREEN);
+        xinerama_y = GetSystemMetrics(SM_YVIRTUALSCREEN);
+        tmp = GetSystemMetrics(SM_CXVIRTUALSCREEN);
+        if (tmp) vo_screenwidth = tmp;
+        tmp = GetSystemMetrics(SM_CYVIRTUALSCREEN);
+        if (tmp) vo_screenheight = tmp;
+    } else if (xinerama_screen == -1 && 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;
+    } else if (xinerama_screen > 0 && myEnumDisplayMonitors) {
+        mon_cnt = 0;
+        myEnumDisplayMonitors(NULL, NULL, mon_enum, 0);
+    }
+    aspect_save_screenres(vo_screenwidth, vo_screenheight);
+}
+
 static void updateScreenProperties() {
     DEVMODE dm;
     dm.dmSize = sizeof dm;
@@ -148,18 +184,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 +257,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;
@@ -322,10 +347,12 @@
 
     myMonitorFromWindow = NULL;
     myGetMonitorInfo = NULL;
+    myEnumDisplayMonitors = NULL;
     user32 = GetModuleHandle("user32.dll");
     if (user32) {
         myMonitorFromWindow = GetProcAddress(user32, "MonitorFromWindow");
         myGetMonitorInfo = GetProcAddress(user32, "GetMonitorInfoA");
+        myEnumDisplayMonitors = GetProcAddress(user32, "EnumDisplayMonitors");
     }
     updateScreenProperties();
 

Index: x11_common.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/x11_common.c,v
retrieving revision 1.205
retrieving revision 1.206
diff -u -r1.205 -r1.206
--- x11_common.c	4 Mar 2006 17:33:56 -0000	1.205
+++ x11_common.c	16 Apr 2006 13:38:28 -0000	1.206
@@ -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 +359,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 +443,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 +1460,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 +1496,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 +1788,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)

Index: x11_common.h
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/x11_common.h,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -r1.45 -r1.46
--- x11_common.h	9 Feb 2006 14:07:59 -0000	1.45
+++ x11_common.h	16 Apr 2006 13:38:28 -0000	1.46
@@ -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*);




More information about the MPlayer-cvslog mailing list