Commit d8f54d49 authored by Gildas Bazin's avatar Gildas Bazin

* src/video_output/vout_intf.c: new vout_ControlWindow() function.

* modules/gui/wxwindows/video.cpp: implement vout_ControlWindow().
* modules/video_output/directx/events.c, modules/video_output/x11/xcommon.c:
  + call vout_ControlWindow() when resizing in embedded mode.
  + implemented a VOUT_REPARENT/CLOSE mode in Control() so the interface can signal that it closes its video window.
parent c541cec6
...@@ -218,6 +218,7 @@ picture_t * vout_RenderPicture ( vout_thread_t *, picture_t *, ...@@ -218,6 +218,7 @@ picture_t * vout_RenderPicture ( vout_thread_t *, picture_t *,
subpicture_t * ); subpicture_t * );
VLC_EXPORT( void *, vout_RequestWindow, ( vout_thread_t *, int *, int *, unsigned int *, unsigned int * ) ); VLC_EXPORT( void *, vout_RequestWindow, ( vout_thread_t *, int *, int *, unsigned int *, unsigned int * ) );
VLC_EXPORT( void, vout_ReleaseWindow, ( vout_thread_t *, void * ) ); VLC_EXPORT( void, vout_ReleaseWindow, ( vout_thread_t *, void * ) );
VLC_EXPORT( int, vout_ControlWindow, ( vout_thread_t *, void *, int, va_list ) );
static inline int vout_vaControl( vout_thread_t *p_vout, int i_query, static inline int vout_vaControl( vout_thread_t *p_vout, int i_query,
va_list args ) va_list args )
...@@ -242,7 +243,8 @@ static inline int vout_Control( vout_thread_t *p_vout, int i_query, ... ) ...@@ -242,7 +243,8 @@ static inline int vout_Control( vout_thread_t *p_vout, int i_query, ... )
enum output_query_e enum output_query_e
{ {
VOUT_SET_ZOOM, /* arg1= double * res= */ VOUT_SET_ZOOM, /* arg1= double * res= */
VOUT_REPARENT VOUT_REPARENT,
VOUT_CLOSE
}; };
/** /**
......
...@@ -64,9 +64,11 @@ struct intf_thread_t ...@@ -64,9 +64,11 @@ struct intf_thread_t
intf_dialog_args_t * ); intf_dialog_args_t * );
/** Video window callbacks */ /** Video window callbacks */
void * ( *pf_request_window ) ( intf_thread_t *, int *, int *, void * ( *pf_request_window ) ( intf_thread_t *, vout_thread_t *,
int *, int *,
unsigned int *, unsigned int * ); unsigned int *, unsigned int * );
void ( *pf_release_window ) ( intf_thread_t *, void * ); void ( *pf_release_window ) ( intf_thread_t *, void * );
int ( *pf_control_window ) ( intf_thread_t *, void *, int, va_list );
/* XXX: new message passing stuff will go here */ /* XXX: new message passing stuff will go here */
vlc_mutex_t change_lock; vlc_mutex_t change_lock;
......
...@@ -31,11 +31,16 @@ ...@@ -31,11 +31,16 @@
#include "wxwindows.h" #include "wxwindows.h"
static void *GetWindow( intf_thread_t *p_intf, int *pi_x_hint, int *pi_y_hint, static void *GetWindow( intf_thread_t *p_intf, vout_thread_t *,
int *pi_x_hint, int *pi_y_hint,
unsigned int *pi_width_hint, unsigned int *pi_width_hint,
unsigned int *pi_height_hint ); unsigned int *pi_height_hint );
static void ReleaseWindow( intf_thread_t *p_intf, void *p_window ); static void ReleaseWindow( intf_thread_t *p_intf, void *p_window );
static int ControlWindow( intf_thread_t *p_intf, void *p_window,
int i_query, va_list args );
/* IDs for the controls and the menu commands */ /* IDs for the controls and the menu commands */
enum enum
{ {
...@@ -50,14 +55,16 @@ public: ...@@ -50,14 +55,16 @@ public:
VideoWindow( intf_thread_t *_p_intf, wxWindow *p_parent ); VideoWindow( intf_thread_t *_p_intf, wxWindow *p_parent );
virtual ~VideoWindow(); virtual ~VideoWindow();
void *GetWindow( int *, int *, unsigned int *, unsigned int * ); void *GetWindow( vout_thread_t *p_vout, int *, int *,
unsigned int *, unsigned int * );
void ReleaseWindow( void * ); void ReleaseWindow( void * );
int ControlWindow( void *, int, va_list );
private: private:
intf_thread_t *p_intf; intf_thread_t *p_intf;
vout_thread_t *p_vout;
wxWindow *p_parent; wxWindow *p_parent;
vlc_mutex_t lock; vlc_mutex_t lock;
vlc_bool_t b_in_use;
wxWindow *p_child_window; wxWindow *p_child_window;
...@@ -91,10 +98,12 @@ VideoWindow::VideoWindow( intf_thread_t *_p_intf, wxWindow *_p_parent ): ...@@ -91,10 +98,12 @@ VideoWindow::VideoWindow( intf_thread_t *_p_intf, wxWindow *_p_parent ):
p_parent = _p_parent; p_parent = _p_parent;
vlc_mutex_init( p_intf, &lock ); vlc_mutex_init( p_intf, &lock );
b_in_use = VLC_FALSE;
p_vout = NULL;
p_intf->pf_request_window = ::GetWindow; p_intf->pf_request_window = ::GetWindow;
p_intf->pf_release_window = ::ReleaseWindow; p_intf->pf_release_window = ::ReleaseWindow;
p_intf->pf_control_window = ::ControlWindow;
p_intf->p_sys->p_video_window = this; p_intf->p_sys->p_video_window = this;
p_child_window = new wxWindow( this, -1, wxDefaultPosition, wxSize(0,0) ); p_child_window = new wxWindow( this, -1, wxDefaultPosition, wxSize(0,0) );
...@@ -109,17 +118,27 @@ VideoWindow::VideoWindow( intf_thread_t *_p_intf, wxWindow *_p_parent ): ...@@ -109,17 +118,27 @@ VideoWindow::VideoWindow( intf_thread_t *_p_intf, wxWindow *_p_parent ):
VideoWindow::~VideoWindow() VideoWindow::~VideoWindow()
{ {
vlc_mutex_lock( &lock );
if( p_vout )
{
if( vout_Control( p_vout, VOUT_REPARENT ) != VLC_SUCCESS )
vout_Control( p_vout, VOUT_CLOSE );
}
vlc_mutex_unlock( &lock );
vlc_mutex_destroy( &lock ); vlc_mutex_destroy( &lock );
} }
/***************************************************************************** /*****************************************************************************
* Private methods. * Private methods.
*****************************************************************************/ *****************************************************************************/
static void *GetWindow( intf_thread_t *p_intf, int *pi_x_hint, int *pi_y_hint, static void *GetWindow( intf_thread_t *p_intf, vout_thread_t *p_vout,
int *pi_x_hint, int *pi_y_hint,
unsigned int *pi_width_hint, unsigned int *pi_width_hint,
unsigned int *pi_height_hint ) unsigned int *pi_height_hint )
{ {
return p_intf->p_sys->p_video_window->GetWindow( pi_x_hint, pi_y_hint, return p_intf->p_sys->p_video_window->GetWindow( p_vout,
pi_x_hint, pi_y_hint,
pi_width_hint, pi_width_hint,
pi_height_hint ); pi_height_hint );
} }
...@@ -134,23 +153,24 @@ extern "C" { ...@@ -134,23 +153,24 @@ extern "C" {
} }
#endif #endif
void *VideoWindow::GetWindow( int *pi_x_hint, int *pi_y_hint, void *VideoWindow::GetWindow( vout_thread_t *_p_vout,
int *pi_x_hint, int *pi_y_hint,
unsigned int *pi_width_hint, unsigned int *pi_width_hint,
unsigned int *pi_height_hint ) unsigned int *pi_height_hint )
{ {
#if defined(__WXGTK__) || defined(WIN32) #if defined(__WXGTK__) || defined(WIN32)
vlc_mutex_lock( &lock ); vlc_mutex_lock( &lock );
if( b_in_use ) if( p_vout )
{ {
msg_Dbg( p_intf, "Video window already in use" ); msg_Dbg( p_intf, "Video window already in use" );
return NULL; return NULL;
} }
b_in_use = VLC_TRUE; p_vout = _p_vout;
wxSizeEvent event( wxSize(*pi_width_hint, *pi_height_hint), wxSizeEvent event( wxSize(*pi_width_hint, *pi_height_hint),
UpdateSize_Event ); UpdateSize_Event );
AddPendingEvent( event ); AddPendingEvent( event );
vlc_mutex_unlock( &lock ); vlc_mutex_unlock( &lock );
...@@ -185,7 +205,7 @@ void VideoWindow::ReleaseWindow( void *p_window ) ...@@ -185,7 +205,7 @@ void VideoWindow::ReleaseWindow( void *p_window )
{ {
vlc_mutex_lock( &lock ); vlc_mutex_lock( &lock );
b_in_use = VLC_FALSE; p_vout = NULL;
#if defined(__WXGTK__) || defined(WIN32) #if defined(__WXGTK__) || defined(WIN32)
wxSizeEvent event( wxSize(0, 0), UpdateHide_Event ); wxSizeEvent event( wxSize(0, 0), UpdateHide_Event );
...@@ -221,3 +241,42 @@ void VideoWindow::UpdateHide( wxSizeEvent &event ) ...@@ -221,3 +241,42 @@ void VideoWindow::UpdateHide( wxSizeEvent &event )
wxCommandEvent intf_event( wxEVT_INTF, 0 ); wxCommandEvent intf_event( wxEVT_INTF, 0 );
p_parent->AddPendingEvent( intf_event ); p_parent->AddPendingEvent( intf_event );
} }
static int ControlWindow( intf_thread_t *p_intf, void *p_window,
int i_query, va_list args )
{
return p_intf->p_sys->p_video_window->ControlWindow( p_window, i_query,
args );
}
int VideoWindow::ControlWindow( void *p_window, int i_query, va_list args )
{
int i_ret = VLC_EGENERIC;
vlc_mutex_lock( &lock );
switch( i_query )
{
case VOUT_SET_ZOOM:
{
double f_arg = va_arg( args, double );
/* Update dimensions */
wxSizeEvent event( wxSize(p_vout->render.i_width * f_arg,
p_vout->render.i_height * f_arg),
UpdateSize_Event );
AddPendingEvent( event );
i_ret = VLC_SUCCESS;
}
break;
default:
msg_Dbg( p_intf, "control query not supported" );
break;
}
vlc_mutex_unlock( &lock );
return i_ret;
}
...@@ -927,6 +927,10 @@ static int Control( vout_thread_t *p_vout, int i_query, va_list args ) ...@@ -927,6 +927,10 @@ static int Control( vout_thread_t *p_vout, int i_query, va_list args )
switch( i_query ) switch( i_query )
{ {
case VOUT_SET_ZOOM: case VOUT_SET_ZOOM:
if( p_vout->p_sys->p_win->owner_window )
return vout_ControlWindow( p_vout,
(void *)p_vout->p_sys->hparent, i_query, args );
f_arg = va_arg( args, double ); f_arg = va_arg( args, double );
/* Update dimensions */ /* Update dimensions */
...@@ -941,6 +945,9 @@ static int Control( vout_thread_t *p_vout, int i_query, va_list args ) ...@@ -941,6 +945,9 @@ static int Control( vout_thread_t *p_vout, int i_query, va_list args )
return VLC_SUCCESS; return VLC_SUCCESS;
case VOUT_CLOSE:
return VLC_SUCCESS;
default: default:
msg_Dbg( p_vout, "control query not supported" ); msg_Dbg( p_vout, "control query not supported" );
return VLC_EGENERIC; return VLC_EGENERIC;
......
...@@ -2126,6 +2126,10 @@ static int Control( vout_thread_t *p_vout, int i_query, va_list args ) ...@@ -2126,6 +2126,10 @@ static int Control( vout_thread_t *p_vout, int i_query, va_list args )
switch( i_query ) switch( i_query )
{ {
case VOUT_SET_ZOOM: case VOUT_SET_ZOOM:
if( p_vout->p_sys->p_win->owner_window )
return vout_ControlWindow( p_vout,
(void *)p_vout->p_sys->p_win->owner_window, i_query, args);
f_arg = va_arg( args, double ); f_arg = va_arg( args, double );
/* Update dimensions */ /* Update dimensions */
...@@ -2136,7 +2140,16 @@ static int Control( vout_thread_t *p_vout, int i_query, va_list args ) ...@@ -2136,7 +2140,16 @@ static int Control( vout_thread_t *p_vout, int i_query, va_list args )
return VLC_SUCCESS; return VLC_SUCCESS;
default: case VOUT_REPARENT:
XReparentWindow( p_vout->p_sys->p_display,
p_vout->p_sys->p_win->base_window,
DefaultRootWindow( p_vout->p_sys->p_display ),
0, 0 );
XSync( p_vout->p_sys->p_display, False );
p_vout->p_sys->p_win->owner_window = 0;
return VLC_SUCCESS;
default:
msg_Dbg( p_vout, "control query not supported" ); msg_Dbg( p_vout, "control query not supported" );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
......
...@@ -85,6 +85,7 @@ intf_thread_t* __intf_Create( vlc_object_t *p_this, const char *psz_module ) ...@@ -85,6 +85,7 @@ intf_thread_t* __intf_Create( vlc_object_t *p_this, const char *psz_module )
} }
p_intf->pf_request_window = NULL; p_intf->pf_request_window = NULL;
p_intf->pf_release_window = NULL; p_intf->pf_release_window = NULL;
p_intf->pf_control_window = NULL;
/* Choose the best module */ /* Choose the best module */
p_intf->p_module = module_Need( p_intf, "interface", psz_module, 0 ); p_intf->p_module = module_Need( p_intf, "interface", psz_module, 0 );
......
...@@ -79,7 +79,7 @@ void *vout_RequestWindow( vout_thread_t *p_vout, ...@@ -79,7 +79,7 @@ void *vout_RequestWindow( vout_thread_t *p_vout,
return NULL; return NULL;
} }
p_window = p_intf->pf_request_window( p_intf, pi_x_hint, pi_y_hint, p_window = p_intf->pf_request_window( p_intf, p_vout, pi_x_hint, pi_y_hint,
pi_width_hint, pi_height_hint ); pi_width_hint, pi_height_hint );
vlc_object_release( p_intf ); vlc_object_release( p_intf );
...@@ -105,6 +105,28 @@ void vout_ReleaseWindow( vout_thread_t *p_vout, void *p_window ) ...@@ -105,6 +105,28 @@ void vout_ReleaseWindow( vout_thread_t *p_vout, void *p_window )
vlc_object_release( p_intf ); vlc_object_release( p_intf );
} }
int vout_ControlWindow( vout_thread_t *p_vout, void *p_window,
int i_query, va_list args )
{
intf_thread_t *p_intf;
int i_ret;
/* Find the main interface */
p_intf = vlc_object_find( p_vout, VLC_OBJECT_INTF, FIND_ANYWHERE );
if( !p_intf ) return VLC_EGENERIC;
if( !p_intf->pf_control_window )
{
msg_Err( p_vout, "no pf_control_window");
vlc_object_release( p_intf );
return VLC_EGENERIC;
}
i_ret = p_intf->pf_control_window( p_intf, p_window, i_query, args );
vlc_object_release( p_intf );
return i_ret;
}
/***************************************************************************** /*****************************************************************************
* vout_IntfInit: called during the vout creation to initialise misc things. * vout_IntfInit: called during the vout creation to initialise misc things.
*****************************************************************************/ *****************************************************************************/
......
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