Commit 5e0dd9dd authored by Gildas Bazin's avatar Gildas Bazin

* modules/gui/wxwindows/video.cpp: some fixes for the recent breakage.

parent 8e0a5a24
...@@ -67,6 +67,7 @@ private: ...@@ -67,6 +67,7 @@ private:
wxWindow *p_parent; wxWindow *p_parent;
vlc_mutex_t lock; vlc_mutex_t lock;
vlc_bool_t b_shown; vlc_bool_t b_shown;
vlc_bool_t b_auto_size;
wxWindow *p_child_window; wxWindow *p_child_window;
...@@ -110,49 +111,36 @@ VideoWindow::VideoWindow( intf_thread_t *_p_intf, wxWindow *_p_parent ): ...@@ -110,49 +111,36 @@ VideoWindow::VideoWindow( intf_thread_t *_p_intf, wxWindow *_p_parent ):
vlc_mutex_init( p_intf, &lock ); vlc_mutex_init( p_intf, &lock );
int size_to_video = config_GetInt( p_intf, "wxwin-size-to-video" ); b_auto_size = config_GetInt( p_intf, "wxwin-size-to-video" );
p_vout = NULL; p_vout = NULL;
m_hide_timer.SetOwner(this, ID_HIDE_TIMER); m_hide_timer.SetOwner( this, ID_HIDE_TIMER );
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->pf_control_window = ::ControlWindow;
p_intf->p_sys->p_video_window = this; p_intf->p_sys->p_video_window = this;
wxSize child_size = wxSize(0,0); wxSize child_size = wxSize(0,0);
if (!size_to_video) if( !b_auto_size )
{ {
//maybe this size should be an option // Maybe this size should be an option
child_size = wxSize( wxSystemSettings::GetMetric( wxSYS_SCREEN_X ) / 2, child_size = wxSize( wxSystemSettings::GetMetric(wxSYS_SCREEN_X) / 2,
wxSystemSettings::GetMetric( wxSYS_SCREEN_Y ) / 2); wxSystemSettings::GetMetric(wxSYS_SCREEN_Y) / 2 );
SetSize(child_size); SetSize( child_size );
} }
p_child_window = new wxWindow( this, -1, wxDefaultPosition, child_size ); p_child_window = new wxWindow( this, -1, wxDefaultPosition, child_size );
if (!size_to_video)
{
//show the window so we can see the background where the video will be
p_child_window->Show(); p_child_window->Show();
Show(); Show();
b_shown = VLC_TRUE; b_shown = VLC_TRUE;
}
else
{
//othewise the video window is shown when a video starts
//but hide it now, so we can set the background color without it showing
p_child_window->Hide();
Hide();
b_shown = VLC_FALSE;
}
p_child_window->SetBackgroundColour(*wxBLACK); p_child_window->SetBackgroundColour( *wxBLACK );
SetBackgroundColour(*wxBLACK); SetBackgroundColour( *wxBLACK );
p_intf->p_sys->p_video_sizer = new wxBoxSizer( wxHORIZONTAL ); p_intf->p_sys->p_video_sizer = new wxBoxSizer( wxHORIZONTAL );
p_intf->p_sys->p_video_sizer->Add( this, 1, wxEXPAND ); p_intf->p_sys->p_video_sizer->Add( this, 1, wxEXPAND );
...@@ -260,31 +248,26 @@ static void ReleaseWindow( intf_thread_t *p_intf, void *p_window ) ...@@ -260,31 +248,26 @@ static void ReleaseWindow( intf_thread_t *p_intf, void *p_window )
void VideoWindow::ReleaseWindow( void *p_window ) void VideoWindow::ReleaseWindow( void *p_window )
{ {
if( !b_auto_size ) return;
vlc_mutex_lock( &lock ); vlc_mutex_lock( &lock );
p_vout = NULL; p_vout = NULL;
int size_to_video = config_GetInt( p_intf, "wxwin-size-to-video" );
if (size_to_video)
{
#if defined(__WXGTK__) || defined(WIN32) #if defined(__WXGTK__) || defined(WIN32)
wxSizeEvent event( wxSize(0, 0), UpdateHide_Event ); wxSizeEvent event( wxSize(0, 0), UpdateHide_Event );
AddPendingEvent( event ); AddPendingEvent( event );
#endif #endif
}
vlc_mutex_unlock( &lock ); vlc_mutex_unlock( &lock );
} }
void VideoWindow::UpdateSize( wxEvent &_event ) void VideoWindow::UpdateSize( wxEvent &_event )
{ {
int size_to_video = config_GetInt( p_intf, "wxwin-size-to-video" ); m_hide_timer.Stop();
m_hide_timer.Stop(); if( !b_auto_size ) return;
if (size_to_video)
{
wxSizeEvent * event = (wxSizeEvent*)(&_event); wxSizeEvent * event = (wxSizeEvent*)(&_event);
if( !b_shown ) if( !b_shown )
{ {
...@@ -298,43 +281,15 @@ void VideoWindow::UpdateSize( wxEvent &_event ) ...@@ -298,43 +281,15 @@ void VideoWindow::UpdateSize( wxEvent &_event )
wxCommandEvent intf_event( wxEVT_INTF, 0 ); wxCommandEvent intf_event( wxEVT_INTF, 0 );
p_parent->AddPendingEvent( intf_event ); p_parent->AddPendingEvent( intf_event );
} }
else
{
//this is a very hackish way to show in case the user switched
//size-to-video off while no video was playing, which would leave
//the window hidden and of 0 size
if( !b_shown )
{
p_intf->p_sys->p_video_sizer->Show( this, TRUE );
SetFocus();
b_shown = VLC_TRUE;
wxSize child_size = wxSize( wxSystemSettings::GetMetric( wxSYS_SCREEN_X ) / 2,
wxSystemSettings::GetMetric( wxSYS_SCREEN_Y ) / 2);
SetSize(child_size);
p_child_window->SetSize(child_size);
Interface * intf = (Interface *)p_parent;
intf->frame_sizer->Layout();
intf->frame_sizer->Fit(intf);
}
}
}
void VideoWindow::UpdateHide( wxEvent &_event ) void VideoWindow::UpdateHide( wxEvent &_event )
{ {
int size_to_video = config_GetInt( p_intf, "wxwin-size-to-video" ); if( b_auto_size) m_hide_timer.Start( 200, wxTIMER_ONE_SHOT );
if (size_to_video)
{
m_hide_timer.Start(1000, wxTIMER_ONE_SHOT);
}
} }
void VideoWindow::OnHideTimer( wxTimerEvent& WXUNUSED(event)) void VideoWindow::OnHideTimer( wxTimerEvent& WXUNUSED(event))
{ {
//wxSizeEvent * event = (wxSizeEvent*)(&_event); //wxSizeEvent * event = (wxSizeEvent*)(&_event);
if( b_shown ) if( b_shown )
{ {
p_intf->p_sys->p_video_sizer->Show( this, FALSE ); p_intf->p_sys->p_video_sizer->Show( this, FALSE );
...@@ -342,10 +297,10 @@ void VideoWindow::OnHideTimer( wxTimerEvent& WXUNUSED(event)) ...@@ -342,10 +297,10 @@ void VideoWindow::OnHideTimer( wxTimerEvent& WXUNUSED(event))
b_shown = VLC_FALSE; b_shown = VLC_FALSE;
SetSize(0,0); SetSize(0,0);
Hide(); Hide();
} }
//ok I cheat here, but is it ever not 0,0? //ok I cheat here, but is it ever not 0,0?
p_intf->p_sys->p_video_sizer->SetMinSize( wxSize(0,0) ); p_intf->p_sys->p_video_sizer->SetMinSize( wxSize(0,0) );
wxCommandEvent intf_event( wxEVT_INTF, 0 ); wxCommandEvent intf_event( wxEVT_INTF, 0 );
p_parent->AddPendingEvent( intf_event ); p_parent->AddPendingEvent( intf_event );
...@@ -380,10 +335,8 @@ int VideoWindow::ControlWindow( void *p_window, int i_query, va_list args ) ...@@ -380,10 +335,8 @@ int VideoWindow::ControlWindow( void *p_window, int i_query, va_list args )
{ {
case VOUT_SET_ZOOM: case VOUT_SET_ZOOM:
{ {
int size_to_video = config_GetInt( p_intf, "wxwin-size-to-video" ); if( !b_auto_size ) break;
if (size_to_video)
{
double f_arg = va_arg( args, double ); double f_arg = va_arg( args, double );
/* Update dimensions */ /* Update dimensions */
...@@ -393,7 +346,6 @@ int VideoWindow::ControlWindow( void *p_window, int i_query, va_list args ) ...@@ -393,7 +346,6 @@ int VideoWindow::ControlWindow( void *p_window, int i_query, va_list args )
AddPendingEvent( event ); AddPendingEvent( event );
}
i_ret = VLC_SUCCESS; i_ret = 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