[vlc-commits] qt: move window code

Rémi Denis-Courmont git at videolan.org
Sun Dec 2 19:00:25 CET 2018


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Dec  1 17:54:41 2018 +0200| [64fcc45a149bb553b59e6ed902edd6bc57a09ac5] | committer: Rémi Denis-Courmont

qt: move window code

This removes one layer of function calls. This also removes the old
check for interface destroyed before window, which would not work
properly, since most vout displays cannot cope with their window going
away asynchronously.

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

 modules/gui/qt/main_interface.cpp | 41 ++++++++++++++++++++++--------
 modules/gui/qt/main_interface.hpp |  7 +++---
 modules/gui/qt/qt.cpp             | 52 ---------------------------------------
 3 files changed, 35 insertions(+), 65 deletions(-)

diff --git a/modules/gui/qt/main_interface.cpp b/modules/gui/qt/main_interface.cpp
index 23472c7c7d..0a0e3b70f2 100644
--- a/modules/gui/qt/main_interface.cpp
+++ b/modules/gui/qt/main_interface.cpp
@@ -729,11 +729,27 @@ bool MainInterface::getVideo( struct vout_window_t *p_wnd,
                               unsigned int i_width, unsigned int i_height,
                               bool fullscreen )
 {
+    static const struct vout_window_operations ops = {
+        MainInterface::controlVideo,
+        MainInterface::releaseVideo,
+        MainInterface::requestVideoWindowed,
+        MainInterface::requestVideoFullScreen,
+    };
     bool result;
 
+    msg_Dbg( p_wnd, "requesting video window..." );
+
     /* This is a blocking call signal. Results are stored directly in the
      * vout_window_t and boolean pointers. Beware of deadlocks! */
     emit askGetVideo( p_wnd, i_width, i_height, fullscreen, &result );
+
+    if( result )
+    {
+        p_wnd->ops = &ops;
+        p_wnd->info.has_double_click = true;
+        p_wnd->sys = (vout_window_sys_t*)this;
+    }
+
     return result;
 }
 
@@ -773,12 +789,6 @@ void MainInterface::getVideoSlot( struct vout_window_t *p_wnd,
     }
 }
 
-/* Asynchronous call from the WindowClose function */
-void MainInterface::releaseVideo( void )
-{
-    emit askReleaseVideo();
-}
-
 /* Function that is CONNECTED to the previous emit */
 void MainInterface::releaseVideoSlot( void )
 {
@@ -987,8 +997,11 @@ void MainInterface::requestVideoFullScreen( vout_window_t *wnd, const char * )
     emit p_mi->askVideoSetFullScreen( true );
 }
 
-int MainInterface::controlVideo( int i_query, va_list args )
+int MainInterface::controlVideo( vout_window_t *p_wnd, int i_query,
+                                 va_list args )
 {
+    MainInterface *p_mi = (MainInterface *)p_wnd->sys;
+
     switch( i_query )
     {
     case VOUT_WINDOW_SET_SIZE:
@@ -996,7 +1009,7 @@ int MainInterface::controlVideo( int i_query, va_list args )
         unsigned int i_width  = va_arg( args, unsigned int );
         unsigned int i_height = va_arg( args, unsigned int );
 
-        emit askVideoToResize( i_width, i_height );
+        emit p_mi->askVideoToResize( i_width, i_height );
         return VLC_SUCCESS;
     }
     case VOUT_WINDOW_SET_STATE:
@@ -1004,15 +1017,23 @@ int MainInterface::controlVideo( int i_query, va_list args )
         unsigned i_arg = va_arg( args, unsigned );
         unsigned on_top = i_arg & VOUT_WINDOW_STATE_ABOVE;
 
-        emit askVideoOnTop( on_top != 0 );
+        emit p_mi->askVideoOnTop( on_top != 0 );
         return VLC_SUCCESS;
     }
     default:
-        msg_Warn( p_intf, "unsupported control query" );
+        msg_Warn( p_wnd, "unsupported control query" );
         return VLC_EGENERIC;
     }
 }
 
+void MainInterface::releaseVideo( vout_window_t *p_wnd )
+{
+    MainInterface *p_mi = (MainInterface *)p_wnd->sys;
+
+    msg_Dbg( p_wnd, "releasing video..." );
+    emit p_mi->askReleaseVideo();
+}
+
 /*****************************************************************************
  * Playlist, Visualisation and Menus handling
  *****************************************************************************/
diff --git a/modules/gui/qt/main_interface.hpp b/modules/gui/qt/main_interface.hpp
index 87f5fc9aae..2f769409d2 100644
--- a/modules/gui/qt/main_interface.hpp
+++ b/modules/gui/qt/main_interface.hpp
@@ -72,12 +72,13 @@ public:
     /* Video requests from core */
     bool getVideo( struct vout_window_t *,
                    unsigned int i_width, unsigned int i_height, bool );
-    void releaseVideo( void );
-
-    int  controlVideo( int i_query, va_list args );
+private:
+    static void releaseVideo( struct vout_window_t * );
+    static int controlVideo( struct vout_window_t *, int, va_list );
     static void requestVideoWindowed( struct vout_window_t * );
     static void requestVideoFullScreen( struct vout_window_t *, const char * );
 
+public:
     /* Getters */
     QSystemTrayIcon *getSysTray() { return sysTray; }
     QMenu *getSysTrayMenu() { return systrayMenu; }
diff --git a/modules/gui/qt/qt.cpp b/modules/gui/qt/qt.cpp
index e6960a1b8b..a63453e1ea 100644
--- a/modules/gui/qt/qt.cpp
+++ b/modules/gui/qt/qt.cpp
@@ -91,7 +91,6 @@ static int  OpenDialogs  ( vlc_object_t * );
 static int  Open         ( vlc_object_t *, bool );
 static void Close        ( vlc_object_t * );
 static int  WindowOpen   ( vout_window_t *, const vout_window_cfg_t * );
-static void WindowClose  ( vout_window_t * );
 static void ShowDialog   ( intf_thread_t *, int, int, intf_dialog_args_t * );
 
 /*****************************************************************************
@@ -689,18 +688,7 @@ static void ShowDialog( intf_thread_t *p_intf, int i_dialog_event, int i_arg,
 
 /**
  * Video output window provider
- *
- * TODO move it out of here ?
  */
-static int WindowControl( vout_window_t *, int i_query, va_list );
-
-static const struct vout_window_operations window_ops = {
-    WindowControl,
-    WindowClose,
-    MainInterface::requestVideoWindowed,
-    MainInterface::requestVideoFullScreen,
-};
-
 static int WindowOpen( vout_window_t *p_wnd, const vout_window_cfg_t *cfg )
 {
     if( cfg->is_standalone )
@@ -728,49 +716,9 @@ static int WindowOpen( vout_window_t *p_wnd, const vout_window_cfg_t *cfg )
         return VLC_EGENERIC;
 
     MainInterface *p_mi = p_intf->p_sys->p_mi;
-    msg_Dbg( p_wnd, "requesting video window..." );
 
     if( !p_mi->getVideo( p_wnd, cfg->width, cfg->height, cfg->is_fullscreen ) )
         return VLC_EGENERIC;
 
-    p_wnd->info.has_double_click = true;
-    p_wnd->ops = &window_ops;
-    p_wnd->sys = (vout_window_sys_t*)p_mi;
     return VLC_SUCCESS;
 }
-
-static int WindowControl( vout_window_t *p_wnd, int i_query, va_list args )
-{
-    MainInterface *p_mi = (MainInterface *)p_wnd->sys;
-    QMutexLocker locker (&lock);
-
-    if (unlikely(!active))
-    {
-        msg_Warn (p_wnd, "video already released before control");
-        return VLC_EGENERIC;
-    }
-    return p_mi->controlVideo( i_query, args );
-}
-
-static void WindowClose( vout_window_t *p_wnd )
-{
-    MainInterface *p_mi = (MainInterface *)p_wnd->sys;
-    QMutexLocker locker (&lock);
-
-    /* Normally, the interface terminates after the video. In the contrary, the
-     * Qt main loop is gone, so we cannot send any event to the user interface
-     * widgets. Ideally, we would keep the Qt main loop running until after
-     * the video window is released. But it is far simpler to just have the Qt
-     * thread destroy the window early, and to turn this function into a stub.
-     *
-     * That assumes the video output will behave sanely if it window is
-     * destroyed asynchronously.
-     * XCB and Xlib-XCB are fine with that. Plain Xlib wouldn't, */
-    if (unlikely(!active))
-    {
-        msg_Warn (p_wnd, "video already released");
-        return;
-    }
-    msg_Dbg (p_wnd, "releasing video...");
-    p_mi->releaseVideo();
-}



More information about the vlc-commits mailing list