[vlc-commits] vout: request resize directly from the window rather than display

Rémi Denis-Courmont git at videolan.org
Thu Oct 16 19:26:04 CEST 2014


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Oct 12 18:03:27 2014 +0300| [6d62ce573b8978ce81e9a2cc648a66791db3816c] | committer: Rémi Denis-Courmont

vout: request resize directly from the window rather than display

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

 src/video_output/display.c      |   37 +++++++++++++++++--------------------
 src/video_output/display.h      |    4 +++-
 src/video_output/video_output.c |   17 +++++++++++++++++
 3 files changed, 37 insertions(+), 21 deletions(-)

diff --git a/src/video_output/display.c b/src/video_output/display.c
index e428fe7..d548cbb 100644
--- a/src/video_output/display.c
+++ b/src/video_output/display.c
@@ -411,7 +411,6 @@ struct vout_display_owner_sys_t {
     bool ch_display_size;
     int  display_width;
     int  display_height;
-    bool display_is_forced;
 
     int  fit_window;
 
@@ -708,7 +707,6 @@ static void VoutDisplayEvent(vout_display_t *vd, int event, va_list args)
         osys->ch_display_size   = true;
         osys->display_width     = width;
         osys->display_height    = height;
-        osys->display_is_forced = false;
 
         vlc_mutex_unlock(&osys->lock);
         break;
@@ -793,14 +791,12 @@ static void VoutDisplayFitWindow(vout_display_t *vd, bool default_size)
     vout_display_GetDefaultDisplaySize(&display_width, &display_height,
                                        &vd->source, &cfg);
 
-    vlc_mutex_lock(&osys->lock);
-
-    osys->ch_display_size   = true;
-    osys->display_width     = display_width;
-    osys->display_height    = display_height;
-    osys->display_is_forced = true;
-
-    vlc_mutex_unlock(&osys->lock);
+#ifdef ALLOW_DUMMY_VOUT
+    if (!osys->vout->p)
+        vout_display_SendEventDisplaySize(vd, display_width, display_height);
+    else
+#endif
+        vout_SetDisplayWindowSize(osys->vout, display_width, display_height);
 }
 
 static void VoutDisplayCropRatio(int *left, int *top, int *right, int *bottom,
@@ -868,7 +864,6 @@ bool vout_ManageDisplay(vout_display_t *vd, bool allow_reset_pictures)
         bool ch_display_size       = osys->ch_display_size;
         int  display_width         = osys->display_width;
         int  display_height        = osys->display_height;
-        bool display_is_forced     = osys->display_is_forced;
         osys->ch_display_size = false;
 
         bool reset_pictures;
@@ -906,15 +901,18 @@ bool vout_ManageDisplay(vout_display_t *vd, bool allow_reset_pictures)
             cfg.display.width  = cfg.is_fullscreen ? 0 : osys->width_saved;
             cfg.display.height = cfg.is_fullscreen ? 0 : osys->height_saved;
 
-            if (vout_display_Control(vd, VOUT_DISPLAY_CHANGE_FULLSCREEN, &cfg)) {
-                msg_Err(vd, "Failed to set fullscreen");
+            if (vout_display_Control(vd, VOUT_DISPLAY_CHANGE_FULLSCREEN, &cfg) == VLC_SUCCESS) {
+                osys->cfg.is_fullscreen = is_fullscreen;
+
+                if (!is_fullscreen)
+                    vout_SetDisplayWindowSize(osys->vout, osys->width_saved,
+                                              osys->height_saved);
+            } else {
                 is_fullscreen = osys->cfg.is_fullscreen;
-            } else if (!is_fullscreen) {
-                vout_display_Control(vd, VOUT_DISPLAY_CHANGE_DISPLAY_SIZE, &cfg, true);
+
+                msg_Err(vd, "Failed to set fullscreen");
             }
-            osys->cfg.is_fullscreen = is_fullscreen;
 
-            /* */
             vout_SendEventFullscreen(osys->vout, osys->cfg.is_fullscreen);
         }
 
@@ -928,9 +926,8 @@ bool vout_ManageDisplay(vout_display_t *vd, bool allow_reset_pictures)
             osys->height_saved = osys->cfg.display.height;
 
             if (vout_display_Control(vd, VOUT_DISPLAY_CHANGE_DISPLAY_SIZE,
-                                     &cfg, display_is_forced)) {
-                if (!display_is_forced)
-                    msg_Err(vd, "Failed to resize display");
+                                     &cfg, false)) {
+                msg_Err(vd, "Failed to resize display");
 
                 /* We ignore the resized */
                 display_width  = osys->cfg.display.width;
diff --git a/src/video_output/display.h b/src/video_output/display.h
index 11daef2..337f881 100644
--- a/src/video_output/display.h
+++ b/src/video_output/display.h
@@ -33,7 +33,9 @@ vout_display_t *vout_NewSplitter(vout_thread_t *vout,
 
 /* FIXME should not be there */
 void vout_SendDisplayEventMouse(vout_thread_t *, const vlc_mouse_t *);
+
 vout_window_t *vout_NewDisplayWindow(vout_thread_t *, const vout_window_cfg_t *);
 void vout_DeleteDisplayWindow(vout_thread_t *, vout_window_t *);
-void vout_UpdateDisplaySourceProperties(vout_display_t *vd, const video_format_t *);
+void vout_SetDisplayWindowSize(vout_thread_t *, unsigned, unsigned);
 
+void vout_UpdateDisplaySourceProperties(vout_display_t *vd, const video_format_t *);
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 197096b..f928a77 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -648,6 +648,23 @@ void vout_DeleteDisplayWindow(vout_thread_t *vout, vout_window_t *window)
     assert(vout->p->window == window);
 }
 
+void vout_SetDisplayWindowSize(vout_thread_t *vout,
+                               unsigned width, unsigned height)
+{
+    vout_window_t *window = vout->p->window;
+
+    if (window != NULL)
+    /* Request a resize of the window. If it fails, there is nothing to do.
+     * If it succeeds, the window will emit a resize event later. */
+        vout_window_SetSize(window, width, height);
+    else
+    if (vout->p->display.vd != NULL)
+    /* Force a resize of window-less display. This is not allowed to fail,
+     * although the display is allowed to ignore the size anyway. */
+        /* FIXME: remove this, fix MSW and OS/2 window providers */
+        vout_display_SendEventDisplaySize(vout->p->display.vd, width, height);
+}
+
 /* */
 static picture_t *VoutVideoFilterInteractiveNewPicture(filter_t *filter)
 {



More information about the vlc-commits mailing list