]> git.sesse.net Git - vlc/commitdiff
* modules/gui/wxwindows/video.cpp: some fixes for the recent breakage.
authorGildas Bazin <gbazin@videolan.org>
Fri, 15 Apr 2005 09:13:24 +0000 (09:13 +0000)
committerGildas Bazin <gbazin@videolan.org>
Fri, 15 Apr 2005 09:13:24 +0000 (09:13 +0000)
modules/gui/wxwindows/video.cpp

index eb70ea1d7bcb4bd179c1587890abc0eb1f83b86a..1eafb75ed9d3846578c03b1f706bde795eb28e81 100644 (file)
@@ -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,49 +111,36 @@ 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;
     p_intf->pf_control_window = ::ControlWindow;
 
     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();
 
-  m_hide_timer.Stop();
+    if( !b_auto_size ) return;
 
-  if (size_to_video)
-  {
     wxSizeEvent * event = (wxSizeEvent*)(&_event);
     if( !b_shown )
     {
@@ -298,43 +281,15 @@ 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))
 {
-  //wxSizeEvent * event = (wxSizeEvent*)(&_event);
+    //wxSizeEvent * event = (wxSizeEvent*)(&_event);
     if( b_shown )
     {
         p_intf->p_sys->p_video_sizer->Show( this, FALSE );
@@ -342,10 +297,10 @@ void VideoWindow::OnHideTimer( wxTimerEvent& WXUNUSED(event))
         b_shown = VLC_FALSE;
 
         SetSize(0,0);
-      Hide();
+        Hide();
     }
-  //ok I cheat here, but is it ever not 0,0?
-  p_intf->p_sys->p_video_sizer->SetMinSize( wxSize(0,0) );
+    //ok I cheat here, but is it ever not 0,0?
+    p_intf->p_sys->p_video_sizer->SetMinSize( wxSize(0,0) );
 
     wxCommandEvent intf_event( wxEVT_INTF, 0 );
     p_parent->AddPendingEvent( intf_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;
         }