[vlc-devel] commit: Calculate position for videowindow to use current screen in xinerama-setup also . (Ilkka Ollakka )

git version control git at videolan.org
Wed Oct 15 20:22:24 CEST 2008


vlc | branch: master | Ilkka Ollakka <ileoo at videolan.org> | Wed Oct 15 20:56:56 2008 +0300| [a0a1a207bfd38f497d490a5b1086a0f0bdd5427d] | committer: Ilkka Ollakka 

Calculate position for videowindow to use current screen in xinerama-setup also.

Basicly same as mplayer/libvo/x11_common.c does.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a0a1a207bfd38f497d490a5b1086a0f0bdd5427d
---

 modules/video_output/x11/glx.c     |    2 +-
 modules/video_output/x11/x11.c     |    2 +-
 modules/video_output/x11/xcommon.c |   52 ++++++++++++++++++++++++++++++++++-
 modules/video_output/x11/xvideo.c  |    2 +-
 modules/video_output/x11/xvmc.c    |    2 +-
 5 files changed, 54 insertions(+), 6 deletions(-)

diff --git a/modules/video_output/x11/glx.c b/modules/video_output/x11/glx.c
index f151a64..8e56c54 100644
--- a/modules/video_output/x11/glx.c
+++ b/modules/video_output/x11/glx.c
@@ -130,7 +130,7 @@ vlc_module_begin();
     add_bool( "glx-shm", 1, NULL, SHM_TEXT, SHM_LONGTEXT, true );
 #endif
 #ifdef HAVE_XINERAMA
-    add_integer ( "glx-xineramascreen", 0, NULL, SCREEN_TEXT, SCREEN_LONGTEXT, true );
+    add_integer ( "glx-xineramascreen", -1, NULL, SCREEN_TEXT, SCREEN_LONGTEXT, true );
 #endif
 vlc_module_end();
 
diff --git a/modules/video_output/x11/x11.c b/modules/video_output/x11/x11.c
index 9da6f10..a67a264 100644
--- a/modules/video_output/x11/x11.c
+++ b/modules/video_output/x11/x11.c
@@ -76,7 +76,7 @@ vlc_module_begin();
     add_bool( "x11-shm", 1, NULL, SHM_TEXT, SHM_LONGTEXT, true );
 #endif
 #ifdef HAVE_XINERAMA
-    add_integer ( "x11-xineramascreen", 0, NULL, SCREEN_TEXT, SCREEN_LONGTEXT, true );
+    add_integer ( "x11-xineramascreen", -1, NULL, SCREEN_TEXT, SCREEN_LONGTEXT, true );
 #endif
     set_description( N_("X11 video output") );
     set_capability( "video output", 70 );
diff --git a/modules/video_output/x11/xcommon.c b/modules/video_output/x11/xcommon.c
index 28f2ddc..4f47435 100644
--- a/modules/video_output/x11/xcommon.c
+++ b/modules/video_output/x11/xcommon.c
@@ -2094,6 +2094,39 @@ static void ToggleFullScreen ( vout_thread_t *p_vout )
     {
         msg_Dbg( p_vout, "entering fullscreen mode" );
 
+        /* Getting current window position */
+        Window root_win;
+        Window* child_windows;
+        int num_child_windows;
+        Window parent_win;
+        Window child_win;
+        XWindowAttributes win_attr;
+        int screen_x,screen_y;
+
+        XGetWindowAttributes(
+                p_vout->p_sys->p_display,
+                p_vout->p_sys->p_win->video_window,
+                &win_attr);
+
+        XQueryTree(
+                p_vout->p_sys->p_display,
+                p_vout->p_sys->p_win->video_window,
+                &root_win,
+                &parent_win,
+                &child_windows,
+                &num_child_windows);
+        XFree(child_windows);
+
+        XTranslateCoordinates(
+                p_vout->p_sys->p_display,
+                parent_win, win_attr.root,
+                win_attr.x,win_attr.y,
+                &screen_x,&screen_y,
+                &child_win);
+
+        msg_Dbg( p_vout, "X %d/%d Y %d/%d", win_attr.x,screen_x,win_attr.y,screen_y);
+        /* screen_x and screen_y are current position */
+
         p_vout->p_sys->b_altfullscreen =
             config_GetInt( p_vout, MODULE_STRING "-altfullscreen" );
 
@@ -2190,11 +2223,26 @@ static void ToggleFullScreen ( vout_thread_t *p_vout )
             SCREEN = config_GetInt( p_vout,
                                         MODULE_STRING "-xineramascreen" );
 
-            /* just check that user has entered a good value */
+            /* just check that user has entered a good value,
+             * otherwise use that screen where window is */
             if( SCREEN >= i_num_screens || SCREEN < 0 )
             {
                 msg_Dbg( p_vout, "requested screen number invalid (%d/%d)", SCREEN, i_num_screens );
-                SCREEN = 0;
+#define left screens[SCREEN].x_org
+#define right left + screens[SCREEN].width
+#define top screens[SCREEN].y_org
+#define bottom top + screens[SCREEN].height
+
+                 for( SCREEN = i_num_screens-1; SCREEN > 0; SCREEN--)
+                 {
+                     if( left <= screen_x && screen_x <= right &&
+                             top <= screen_y && screen_y <= bottom )
+                         break;
+                 }
+#undef bottom
+#undef top
+#undef right
+#undef left
             }
 
             /* Get the X/Y upper left corner coordinate of the above screen */
diff --git a/modules/video_output/x11/xvideo.c b/modules/video_output/x11/xvideo.c
index 787a9df..2b05b97 100644
--- a/modules/video_output/x11/xvideo.c
+++ b/modules/video_output/x11/xvideo.c
@@ -89,7 +89,7 @@ vlc_module_begin();
     add_bool( "xvideo-shm", 1, NULL, SHM_TEXT, SHM_LONGTEXT, true );
 #endif
 #ifdef HAVE_XINERAMA
-    add_integer ( "xvideo-xineramascreen", 0, NULL, SCREEN_TEXT, SCREEN_LONGTEXT, true );
+    add_integer ( "xvideo-xineramascreen", -1, NULL, SCREEN_TEXT, SCREEN_LONGTEXT, true );
 #endif
 
     set_description( N_("XVideo extension video output") );
diff --git a/modules/video_output/x11/xvmc.c b/modules/video_output/x11/xvmc.c
index 03c0a49..166ef6e 100644
--- a/modules/video_output/x11/xvmc.c
+++ b/modules/video_output/x11/xvmc.c
@@ -143,7 +143,7 @@ vlc_module_begin();
     add_bool( "xvmc-shm", 1, NULL, SHM_TEXT, SHM_LONGTEXT, true );
 #endif
 #ifdef HAVE_XINERAMA
-    add_integer ( "xvmc-xineramascreen", 0, NULL, SCREEN_TEXT, SCREEN_LONGTEXT, true );
+    add_integer ( "xvmc-xineramascreen", -1, NULL, SCREEN_TEXT, SCREEN_LONGTEXT, true );
 #endif
     add_string( "xvmc-deinterlace-mode", "bob", NULL, MODE_TEXT, MODE_LONGTEXT, false );
     add_string( "xvmc-crop-style", "eq", NULL, CROP_TEXT, CROP_LONGTEXT, false );




More information about the vlc-devel mailing list