]> git.sesse.net Git - vlc/blobdiff - modules/video_output/x11/xcommon.c
ALL: backport of 13001,13004,13005,13011,13012,13019,13020,13025 from trunk.
[vlc] / modules / video_output / x11 / xcommon.c
index 54b51d81413db09166e8431ae49ff7f1db70adb3..8533aff8072717efbc1de22be09894429b9e2699 100644 (file)
@@ -405,11 +405,33 @@ static int InitVideo( vout_thread_t *p_vout )
     vout_PlacePicture( p_vout, p_vout->p_sys->p_win->i_width,
                        p_vout->p_sys->p_win->i_height,
                        &i_index, &i_index,
-                       &p_vout->output.i_width, &p_vout->output.i_height );
+                       &p_vout->fmt_out.i_visible_width,
+                       &p_vout->fmt_out.i_visible_height );
 
-    /* Assume we have square pixels */
-    p_vout->output.i_aspect = p_vout->output.i_width
-                               * VOUT_ASPECT_FACTOR / p_vout->output.i_height;
+    p_vout->fmt_out.i_chroma = p_vout->output.i_chroma;
+
+    p_vout->output.i_width = p_vout->fmt_out.i_width =
+        p_vout->fmt_out.i_visible_width * p_vout->fmt_in.i_width /
+        p_vout->fmt_in.i_visible_width;
+    p_vout->output.i_height = p_vout->fmt_out.i_height =
+        p_vout->fmt_out.i_visible_height * p_vout->fmt_in.i_height /
+        p_vout->fmt_in.i_visible_height;
+    p_vout->fmt_out.i_x_offset =
+        p_vout->fmt_out.i_visible_width * p_vout->fmt_in.i_x_offset /
+        p_vout->fmt_in.i_visible_width;
+    p_vout->fmt_out.i_y_offset =
+        p_vout->fmt_out.i_visible_height * p_vout->fmt_in.i_y_offset /
+        p_vout->fmt_in.i_visible_height;
+
+    p_vout->fmt_out.i_sar_num = p_vout->fmt_out.i_sar_den = 1;
+    p_vout->output.i_aspect = p_vout->fmt_out.i_aspect =
+        p_vout->fmt_out.i_width * VOUT_ASPECT_FACTOR /p_vout->fmt_out.i_height;
+
+    msg_Dbg( p_vout, "x11 image size %ix%i (%i,%i,%ix%i)",
+             p_vout->fmt_out.i_width, p_vout->fmt_out.i_height,
+             p_vout->fmt_out.i_x_offset, p_vout->fmt_out.i_y_offset,
+             p_vout->fmt_out.i_visible_width,
+             p_vout->fmt_out.i_visible_height );
 #endif
 
     /* Try to initialize up to MAX_DIRECTBUFFERS direct buffers */
@@ -486,8 +508,11 @@ static void DisplayVideo( vout_thread_t *p_vout, picture_t *p_pic )
         XShmPutImage( p_vout->p_sys->p_display,
                       p_vout->p_sys->p_win->video_window,
                       p_vout->p_sys->p_win->gc, p_pic->p_sys->p_image,
-                      0 /*src_x*/, 0 /*src_y*/, 0 /*dest_x*/, 0 /*dest_y*/,
-                      p_vout->output.i_width, p_vout->output.i_height,
+                      p_vout->fmt_out.i_x_offset,
+                      p_vout->fmt_out.i_y_offset,
+                      0 /*dest_x*/, 0 /*dest_y*/,
+                      p_vout->fmt_out.i_visible_width,
+                      p_vout->fmt_out.i_visible_height,
                       False /* Don't put True here ! */ );
 #   endif
     }
@@ -508,8 +533,11 @@ static void DisplayVideo( vout_thread_t *p_vout, picture_t *p_pic )
         XPutImage( p_vout->p_sys->p_display,
                    p_vout->p_sys->p_win->video_window,
                    p_vout->p_sys->p_win->gc, p_pic->p_sys->p_image,
-                   0 /*src_x*/, 0 /*src_y*/, 0 /*dest_x*/, 0 /*dest_y*/,
-                   p_vout->output.i_width, p_vout->output.i_height );
+                   p_vout->fmt_out.i_x_offset,
+                   p_vout->fmt_out.i_y_offset,
+                   0 /*dest_x*/, 0 /*dest_y*/,
+                   p_vout->fmt_out.i_visible_width,
+                   p_vout->fmt_out.i_visible_height );
 #endif
     }
 
@@ -757,11 +785,13 @@ static int ManageVideo( vout_thread_t *p_vout )
                                p_vout->p_sys->p_win->i_height,
                                &i_x, &i_y, &i_width, &i_height );
 
-            val.i_int = ( xevent.xmotion.x - i_x )
-                         * p_vout->render.i_width / i_width;
+            val.i_int = ( xevent.xmotion.x - i_x ) *
+                p_vout->fmt_in.i_visible_width / i_width +
+                p_vout->fmt_in.i_x_offset;
             var_Set( p_vout, "mouse-x", val );
-            val.i_int = ( xevent.xmotion.y - i_y )
-                         * p_vout->render.i_height / i_height;
+            val.i_int = ( xevent.xmotion.y - i_y ) *
+                p_vout->fmt_in.i_visible_height / i_height +
+                p_vout->fmt_in.i_y_offset;
             var_Set( p_vout, "mouse-y", val );
 
             val.b_bool = VLC_TRUE;
@@ -847,7 +877,6 @@ static int ManageVideo( vout_thread_t *p_vout )
         p_vout->i_changes &= ~VOUT_FULLSCREEN_CHANGE;
     }
 
-#ifndef MODULE_NAME_IS_x11
     if( p_vout->i_changes & VOUT_CROP_CHANGE ||
         p_vout->i_changes & VOUT_ASPECT_CHANGE )
     {
@@ -862,9 +891,9 @@ static int ManageVideo( vout_thread_t *p_vout )
         p_vout->fmt_out.i_sar_num = p_vout->fmt_in.i_sar_num;
         p_vout->fmt_out.i_sar_den = p_vout->fmt_in.i_sar_den;
         p_vout->output.i_aspect = p_vout->fmt_in.i_aspect;
+
         p_vout->i_changes |= VOUT_SIZE_CHANGE;
     }
-#endif
 
     /*
      * Size change