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:
wxWindow *p_parent;
vlc_mutex_t lock;
vlc_bool_t b_shown;
vlc_bool_t b_auto_size;
wxWindow *p_child_window;
......@@ -110,11 +111,11 @@ VideoWindow::VideoWindow( intf_thread_t *_p_intf, wxWindow *_p_parent ):
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;
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_release_window = ::ReleaseWindow;
......@@ -123,36 +124,23 @@ VideoWindow::VideoWindow( intf_thread_t *_p_intf, wxWindow *_p_parent ):
p_intf->p_sys->p_video_window = this;
wxSize child_size = wxSize(0,0);
if (!size_to_video)
if( !b_auto_size )
{
//maybe this size should be an option
child_size = wxSize( wxSystemSettings::GetMetric( wxSYS_SCREEN_X ) / 2,
wxSystemSettings::GetMetric( wxSYS_SCREEN_Y ) / 2);
// Maybe this size should be an option
child_size = wxSize( wxSystemSettings::GetMetric(wxSYS_SCREEN_X) / 2,
wxSystemSettings::GetMetric(wxSYS_SCREEN_Y) / 2 );
SetSize(child_size);
SetSize( 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();
Show();
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);
SetBackgroundColour(*wxBLACK);
p_child_window->SetBackgroundColour( *wxBLACK );
SetBackgroundColour( *wxBLACK );
p_intf->p_sys->p_video_sizer = new wxBoxSizer( wxHORIZONTAL );
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 )
void VideoWindow::ReleaseWindow( void *p_window )
{
if( !b_auto_size ) return;
vlc_mutex_lock( &lock );
p_vout = NULL;
int size_to_video = config_GetInt( p_intf, "wxwin-size-to-video" );
if (size_to_video)
{
#if defined(__WXGTK__) || defined(WIN32)
wxSizeEvent event( wxSize(0, 0), UpdateHide_Event );
AddPendingEvent( event );
#endif
}
vlc_mutex_unlock( &lock );
}
void VideoWindow::UpdateSize( wxEvent &_event )
{
int size_to_video = config_GetInt( p_intf, "wxwin-size-to-video" );
m_hide_timer.Stop();
if (size_to_video)
{
if( !b_auto_size ) return;
wxSizeEvent * event = (wxSizeEvent*)(&_event);
if( !b_shown )
{
......@@ -298,38 +281,10 @@ void VideoWindow::UpdateSize( wxEvent &_event )
wxCommandEvent intf_event( wxEVT_INTF, 0 );
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 )
{
int size_to_video = config_GetInt( p_intf, "wxwin-size-to-video" );
if (size_to_video)
{
m_hide_timer.Start(1000, wxTIMER_ONE_SHOT);
}
if( b_auto_size) m_hide_timer.Start( 200, wxTIMER_ONE_SHOT );
}
void VideoWindow::OnHideTimer( wxTimerEvent& WXUNUSED(event))
......@@ -380,10 +335,8 @@ int VideoWindow::ControlWindow( void *p_window, int i_query, va_list args )
{
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 );
/* Update dimensions */
......@@ -393,7 +346,6 @@ int VideoWindow::ControlWindow( void *p_window, int i_query, va_list args )
AddPendingEvent( event );
}
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