Commit 4fbdd334 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

qt: move vout window initialization code

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.
Signed-off-by: Rémi Denis-Courmont's avatarRémi Denis-Courmont <remi@remlab.net>
parent 7e8b50a2
......@@ -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 */
......
......@@ -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
......
......@@ -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 );
......
......@@ -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 );
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment