[MPlayer-dev-eng] Patch for multi-screen xinerama setup.

daniel carter hedonist at win.co.nz
Thu Dec 13 15:35:15 CET 2001


Hello all,

I notice that someone has recently patched x11common.c, presumably to
try and fix the problem i reported on the users list.

  int disp_screen = mScreen;
  screens = XineramaQueryScreens(mDisplay, &num_screens);
  vo_screenwidth=screens[disp_screen].width;
  vo_screenheight=screens[disp_screen].height;

The problem with this scheme is that a Xlib screen <> a Xinerama
screen.  Using xinerama there is only one screen as far as Xlib is
concerned. The xinerama interface allows you to query what physical
screens there are.  So using the Xlib screen number as the index to the
struct returned by xinerama makes no sense, and doesn't solve the
problem.

As i posted on the user list, AFAICT there is no way for mplayer to tell
which xinerama screen the window is going to display on.  (Well actually
you could query the xy coordinates of a window after it is created, and
then iterate the array returned by XineramaQueryScreens to work out
which physical screen contained the window.  But that's ugly, and still
wouldn't solve some issues).

My solution is to add a new commandline parameter to tell mplayer which
xinerama screen to use.
This is used for two purposes:
1) When calculating the screen width and height, it uses the screen
specified rather than the current behaviour of using the first screen.
2) When creating a window, instead of opening the window at 0,0 (upper
left
of the first screen) it places it in the upper left of the screen
specified.

So ,under window managers such as window maker where there was
previously no
way to make the window display on a certain xinerama screen, you can now
make it
display on certain screen.
Under KDE, the window is always displayed on the screen with the mouse
pointer, overriding what is hinted, but when displaying fullscreen using

-fsmode 1 it is now displayed on the screen specified rather than always
on
the first screen.

Now, this is my first go at doing programming in C, so chances are you
might find my code rather ugly, I'd suggest giving it a good look over
before committing anything.

The patch add's the new commandline option in cfg-mplayer.h
It adds to x11_common.h a variable to store the requested screen, and
two variables to store the upper left xy of the requested screen.  Not
sure if this is the best place for them.  And i'm a bit confused as to
why i need to define vo_xineramascreen in both cfg-mplayer.h and
x11_common.. but it works...
It changes the screen width and height detection in x11_common.c to
detect the requested screen.
It changes the xy hinting in vo_x11.c and vo_xv.c to create the X window
in the upper left corner of the requested screen.

I'm not sure how to format a multifile patch, so i've just attached the
whole cvs diff -u output.

Regards,
dan.
-------------- next part --------------
[dantheperson at danski main]$ cvs diff -u
? encore/.depend
cvs server: Diffing .
Index: cfg-mplayer.h
===================================================================
RCS file: /cvsroot/mplayer/main/cfg-mplayer.h,v
retrieving revision 1.111
diff -u -r1.111 cfg-mplayer.h
--- cfg-mplayer.h       4 Dec 2001 21:04:17 -0000       1.111
+++ cfg-mplayer.h       13 Dec 2001 14:35:02 -0000
@@ -41,6 +41,10 @@
 extern int vo_dbpp;
 #endif

+#ifdef HAVE_XINERAMA
+extern int vo_xineramascreen;
+#endif
+
 #ifdef USE_SUB
 extern int sub_unicode;
 extern int sub_utf8;
@@ -222,6 +226,11 @@
        {"fsmode", &vo_fsmode, CONF_TYPE_INT, CONF_RANGE, 0, 15},
        {"double", &vo_doublebuffering, CONF_TYPE_FLAG, 0, 0, 1},
        {"nodouble", &vo_doublebuffering, CONF_TYPE_FLAG, 0, 1, 0},
+#endif
+
+#ifdef HAVE_XINERAMA
+//     need to find max possible number of screen for range but unlikey to be more than 100
+       {"xineramascreen", &vo_xineramascreen, CONF_TYPE_INT, CONF_RANGE, 0, 100},
 #endif

 #ifdef HAVE_AA
cvs server: Diffing DOCS
cvs server: Diffing DOCS/French
cvs server: Diffing DOCS/German
cvs server: Diffing DOCS/Hungarian
cvs server: Diffing DOCS/Polish
cvs server: Diffing DOCS/Russian
cvs server: Diffing DOCS/Spanish
cvs server: Diffing DOCS/tech
cvs server: Diffing Gui
cvs server: Diffing Gui/bitmap
cvs server: Diffing Gui/bitmap/bmp
cvs server: Diffing Gui/bitmap/png
cvs server: Diffing Gui/bitmap/tga
cvs server: Diffing Gui/mplayer
cvs server: Diffing Gui/mplayer/gtk
cvs server: Diffing Gui/mplayer/pixmaps
cvs server: Diffing Gui/skin
cvs server: Diffing Gui/wm
cvs server: Diffing TOOLS
cvs server: Diffing TOOLS/GL-test
cvs server: Diffing TOOLS/benchmark
cvs server: Diffing TOOLS/mpfc
cvs server: Diffing TOOLS/subfont-c
cvs server: Diffing TOOLS/subfont-c/encodings
cvs server: Diffing TOOLS/subfont-c/osd
cvs server: Diffing TOOLS/subfont-gimp
cvs server: Diffing TVout
cvs server: Diffing TVout/con2fb
cvs server: Diffing TVout/fbset
cvs server: Diffing TVout/matroxset
cvs server: Diffing debian
cvs server: Diffing drivers
cvs server: Diffing drivers/radeon
cvs server: Diffing drivers/syncfb
cvs server: Diffing encore
cvs server: Diffing etc
cvs server: Diffing g72x
cvs server: Diffing liba52
cvs server: Diffing libac3
cvs server: Diffing libac3/downmix
cvs server: Diffing libac3/mmx
cvs server: Diffing libao2
cvs server: Diffing libavcodec
cvs server: Diffing libmp1e
cvs server: Diffing libmp1e/audio
cvs server: Diffing libmp1e/common
cvs server: Diffing libmp1e/systems
cvs server: Diffing libmp1e/video
cvs server: Diffing libmpdemux
cvs server: Diffing libmpeg2
cvs server: Diffing libvo
Index: libvo/vo_x11.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_x11.c,v
retrieving revision 1.43
diff -u -r1.43 vo_x11.c
--- libvo/vo_x11.c      11 Dec 2001 15:34:21 -0000      1.43
+++ libvo/vo_x11.c      13 Dec 2001 14:35:05 -0000
@@ -191,8 +191,18 @@
    {
     if( !vo_init() ) return 0; // Can't open X11

+#ifdef HAVE_XINERAMA
+    if(XineramaIsActive(mDisplay))
+     {
+      hint.x = vo_xinerama_x;
+      hint.y = vo_xinerama_y;
+     }
+    else
+#endif
+    {
     hint.x=0;
     hint.y=0;
+    }
     hint.width=image_width;
     hint.height=image_height;

Index: libvo/vo_xv.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_xv.c,v
retrieving revision 1.37
diff -u -r1.37 vo_xv.c
--- libvo/vo_xv.c       18 Oct 2001 02:42:20 -0000      1.37
+++ libvo/vo_xv.c       13 Dec 2001 14:35:06 -0000
@@ -155,8 +155,19 @@
  if ( vo_window == None )
   {
 #endif
+
+#ifdef HAVE_XINERAMA
+   if(XineramaIsActive(mDisplay))
+    {
+     hint.x = vo_xinerama_x;
+     hint.y = vo_xinerama_y;
+    }
+   else
+#endif
+   {
    hint.x = 0;
    hint.y = 0;
+   }
    hint.width = d_width;
    hint.height = d_height;
    aspect(&d_width,&d_height,A_NOZOOM);
Index: libvo/x11_common.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/x11_common.c,v
retrieving revision 1.36
diff -u -r1.36 x11_common.c
--- libvo/x11_common.c  11 Dec 2001 16:45:25 -0000      1.36
+++ libvo/x11_common.c  13 Dec 2001 14:35:06 -0000
@@ -44,6 +44,11 @@
 Window   mRootWin;
 int mScreen;
 int mLocalDisplay;
+#ifdef HAVE_XINERAMA
+int vo_xineramascreen = 1;
+int vo_xinerama_x;
+int vo_xinerama_y;
+#endif


 void vo_hidecursor ( Display *disp , Window win )
@@ -147,12 +152,15 @@
   int disp_screen = mScreen;

   screens = XineramaQueryScreens(mDisplay, &num_screens);
-  if (disp_screen > num_screens)
-    disp_screen = 0;
-  if (! vo_screenwidth)
-    vo_screenwidth=screens[disp_screen].width;
-  if (! vo_screenheight)
-    vo_screenheight=screens[disp_screen].height;
+  if( vo_xineramascreen > num_screens )
+    {
+     printf( "vo: requested xinerama screen %d, only %d screens available, using first screen\n",vo_xineramascreen,num_screens);
+     vo_xineramascreen = 1;
+    }
+  vo_xinerama_x = screens[vo_xineramascreen-1].x_org;
+  vo_xinerama_y = screens[vo_xineramascreen-1].y_org;
+  vo_screenwidth=screens[vo_xineramascreen-1].width;
+  vo_screenheight=screens[vo_xineramascreen-1].height;
   }
  else
 #endif
Index: libvo/x11_common.h
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/x11_common.h,v
retrieving revision 1.11
diff -u -r1.11 x11_common.h
--- libvo/x11_common.h  24 Oct 2001 17:04:08 -0000      1.11
+++ libvo/x11_common.h  13 Dec 2001 14:35:06 -0000
@@ -34,5 +34,11 @@
  extern Display * vo_display;
 #endif

+#ifdef HAVE_XINERAMA
+ extern int vo_xineramascreen;
+ extern int vo_xinerama_x;
+ extern int vo_xinerama_y;
+#endif
+
 void saver_off( Display * );
 void saver_on( Display * );
cvs server: Diffing libvo2
cvs server: Diffing linux
cvs server: Diffing loader
cvs server: Diffing loader/DirectShow
cvs server: Diffing loader/dshow
cvs server: Diffing loader/qtx
cvs server: Diffing loader/qtx/qtxsdk
cvs server: Diffing loader/wine
cvs server: Diffing mp3lib
cvs server: Diffing opendivx
cvs server: Diffing postproc
cvs server: Diffing xa
[dantheperson at danski main]$


More information about the MPlayer-dev-eng mailing list