[vlc-devel] [PATCH 1/2] qt: move vout window initialization code

Jean-Baptiste Kempf jb at videolan.org
Sat Feb 4 10:51:56 CET 2017


No objection from me

On Fri, 3 Feb 2017, at 18:13, RĂ©mi Denis-Courmont wrote:
> Returning the WId is not adequate for a certain window type. Since the
> interface widget already has platform-specific code, and already has
> access to the vout window VLC object pointer, move the initialization
> there. Then we do not have to worry about what to return.
> ---
>  modules/gui/qt/components/interface_widgets.cpp | 23 +++++++++++++++---
>  modules/gui/qt/components/interface_widgets.hpp |  6 ++---
>  modules/gui/qt/main_interface.cpp               | 31
>  +++++++++++--------------
>  modules/gui/qt/main_interface.hpp               |  9 +++----
>  modules/gui/qt/qt.cpp                           | 21 +----------------
>  5 files changed, 43 insertions(+), 47 deletions(-)
> 
> diff --git a/modules/gui/qt/components/interface_widgets.cpp
> b/modules/gui/qt/components/interface_widgets.cpp
> index b6026aac1e..5226addb72 100644
> --- a/modules/gui/qt/components/interface_widgets.cpp
> +++ b/modules/gui/qt/components/interface_widgets.cpp
> @@ -100,12 +100,12 @@ void VideoWidget::sync( void )
>  /**
>   * Request the video to avoid the conflicts
>   **/
> -WId VideoWidget::request( struct vout_window_t *p_wnd )
> +bool VideoWidget::request( struct vout_window_t *p_wnd )
>  {
>      if( stable )
>      {
>          msg_Dbg( p_intf, "embedded video already in use" );
> -        return 0;
> +        return false;
>      }
>      assert( !p_window );
>  
> @@ -134,7 +134,24 @@ WId VideoWidget::request( struct vout_window_t
> *p_wnd )
>  
>      sync();
>      p_window = p_wnd;
> -    return stable->winId();
> +
> +    p_wnd->type = p_intf->p_sys->voutWindowType;
> +    switch( p_wnd->type )
> +    {
> +        case VOUT_WINDOW_TYPE_XID:
> +            p_wnd->handle.xid = stable->winId();
> +            p_wnd->display.x11 = NULL;
> +            break;
> +        case VOUT_WINDOW_TYPE_HWND:
> +            p_wnd->handle.hwnd = (void *)stable->winId();
> +            break;
> +        case VOUT_WINDOW_TYPE_NSOBJECT:
> +            p_wnd->handle.nsobject = (void *)stable->winId();
> +            break;
> +        default:
> +            vlc_assert_unreachable();
> +    }
> +    return true;
>  }
>  
>  /* Set the Widget to the correct Size */
> diff --git a/modules/gui/qt/components/interface_widgets.hpp
> b/modules/gui/qt/components/interface_widgets.hpp
> index b2cbf8059b..e41cdfb0ce 100644
> --- a/modules/gui/qt/components/interface_widgets.hpp
> +++ b/modules/gui/qt/components/interface_widgets.hpp
> @@ -59,9 +59,9 @@ public:
>      VideoWidget( intf_thread_t *, QWidget* p_parent );
>      virtual ~VideoWidget();
>  
> -    WId request( struct vout_window_t * );
> -    void  release( void );
> -    void  sync( void );
> +    bool request( struct vout_window_t * );
> +    void release( void );
> +    void sync( void );
>  
>  protected:
>      QPaintEngine *paintEngine() const Q_DECL_OVERRIDE
> diff --git a/modules/gui/qt/main_interface.cpp
> b/modules/gui/qt/main_interface.cpp
> index fa5da3bbd1..f44a872bc1 100644
> --- a/modules/gui/qt/main_interface.cpp
> +++ b/modules/gui/qt/main_interface.cpp
> @@ -191,8 +191,8 @@ MainInterface::MainInterface( intf_thread_t *_p_intf
> ) : QVLCMW( _p_intf )
>  
>      /* VideoWidget connects for asynchronous calls */
>      b_videoFullScreen = false;
> -    connect( this, SIGNAL(askGetVideo(WId*, struct vout_window_t*,
> unsigned, unsigned, bool)),
> -             this, SLOT(getVideoSlot(WId*, struct vout_window_t*,
> unsigned, unsigned, bool)),
> +    connect( this, SIGNAL(askGetVideo(struct vout_window_t*, unsigned,
> unsigned, bool, bool*)),
> +             this, SLOT(getVideoSlot(struct vout_window_t*, unsigned,
> unsigned, bool, bool*)),
>               Qt::BlockingQueuedConnection );
>      connect( this, SIGNAL(askReleaseVideo( void )),
>               this, SLOT(releaseVideoSlot( void )),
> @@ -703,32 +703,29 @@ void MainInterface::toggleFSC()
>   * All window provider queries must be handled through signals or
>   events.
>   * That's why we have all those emit statements...
>   */
> -WId MainInterface::getVideo( struct vout_window_t *p_wnd,
> -                             unsigned int i_width, unsigned int
> i_height,
> -                             bool fullscreen )
> +bool MainInterface::getVideo( struct vout_window_t *p_wnd,
> +                              unsigned int i_width, unsigned int
> i_height,
> +                              bool fullscreen )
>  {
> -    if( !videoWidget )
> -        return 0;
> +    bool result;
>  
> -    /* This is a blocking call signal. Results are returned through
> pointers.
> -     * Beware of deadlocks! */
> -    WId id;
> -    emit askGetVideo( &id, p_wnd, i_width, i_height, fullscreen );
> -    return id;
> +    /* 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 );
> +    return result;
>  }
>  
> -void MainInterface::getVideoSlot( WId *p_id, struct vout_window_t
> *p_wnd,
> +void MainInterface::getVideoSlot( struct vout_window_t *p_wnd,
>                                    unsigned i_width, unsigned i_height,
> -                                  bool fullscreen )
> +                                  bool fullscreen, bool *res )
>  {
>      /* Hidden or minimized, activate */
>      if( isHidden() || isMinimized() )
>          toggleUpdateSystrayMenu();
>  
>      /* Request the videoWidget */
> -    WId ret = videoWidget->request( p_wnd );
> -    *p_id = ret;
> -    if( ret ) /* The videoWidget is available */
> +    *res = videoWidget->request( p_wnd );
> +    if( *res ) /* The videoWidget is available */
>      {
>          setVideoFullScreen( fullscreen );
>  
> diff --git a/modules/gui/qt/main_interface.hpp
> b/modules/gui/qt/main_interface.hpp
> index 03e78d37de..6e3d96aef3 100644
> --- a/modules/gui/qt/main_interface.hpp
> +++ b/modules/gui/qt/main_interface.hpp
> @@ -69,7 +69,7 @@ public:
>      static const QEvent::Type ToolbarsNeedRebuild;
>  
>      /* Video requests from core */
> -    WId  getVideo( struct vout_window_t *,
> +    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 );
> @@ -206,8 +206,8 @@ public slots:
>      void setPlaylistVisibility(bool b_visible);
>  
>      /* Manage the Video Functions from the vout threads */
> -    void getVideoSlot( WId *p_id, struct vout_window_t *,
> -                       unsigned pi_width, unsigned pi_height, bool );
> +    void getVideoSlot( struct vout_window_t *,
> +                       unsigned i_width, unsigned i_height, bool, bool *
> );
>      void releaseVideoSlot( void );
>  
>      void emitBoss();
> @@ -261,7 +261,8 @@ protected slots:
>      void onInputChanged( bool );
>  
>  signals:
> -    void askGetVideo( WId *, struct vout_window_t *, unsigned, unsigned,
> bool );
> +    void askGetVideo( struct vout_window_t *, unsigned, unsigned, bool,
> +                      bool * );
>      void askReleaseVideo( );
>      void askVideoToResize( unsigned int, unsigned int );
>      void askVideoSetFullScreen( bool );
> diff --git a/modules/gui/qt/qt.cpp b/modules/gui/qt/qt.cpp
> index 43439f188d..b86b7e507f 100644
> --- a/modules/gui/qt/qt.cpp
> +++ b/modules/gui/qt/qt.cpp
> @@ -749,28 +749,9 @@ static int WindowOpen( vout_window_t *p_wnd, const
> vout_window_cfg_t *cfg )
>      MainInterface *p_mi = p_intf->p_sys->p_mi;
>      msg_Dbg( p_wnd, "requesting video window..." );
>  
> -    WId wid = p_mi->getVideo( p_wnd, cfg->width, cfg->height,
> cfg->is_fullscreen );
> -    if( !wid )
> +    if( !p_mi->getVideo( p_wnd, cfg->width, cfg->height,
> cfg->is_fullscreen ) )
>          return VLC_EGENERIC;
>  
> -    p_wnd->type = p_intf->p_sys->voutWindowType;
> -
> -    switch( p_wnd->type )
> -    {
> -        case VOUT_WINDOW_TYPE_XID:
> -            p_wnd->handle.xid = (uintptr_t)wid;
> -            p_wnd->display.x11 = NULL;
> -            break;
> -        case VOUT_WINDOW_TYPE_HWND:
> -            p_wnd->handle.hwnd = (void *)wid;
> -            break;
> -        case VOUT_WINDOW_TYPE_NSOBJECT:
> -            p_wnd->handle.nsobject = (void *)wid;
> -            break;
> -        default:
> -            vlc_assert_unreachable();
> -    }
> -
>      p_wnd->control = WindowControl;
>      p_wnd->sys = (vout_window_sys_t*)p_mi;
>      return VLC_SUCCESS;
> -- 
> 2.11.0
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


-- 
Jean-Baptiste Kempf -  President
+33 672 704 734


More information about the vlc-devel mailing list