>From 67a4e1e46c11b786641765e6b0771715888fa784 Mon Sep 17 00:00:00 2001
From: Erwan Tulou <erwan10@videolan.org>
Date: Sun, 13 Jun 2010 15:45:09 +0200
Subject: [PATCH] qt4: use the new vout_window_SendEventSetup/Cleanup

---
 modules/gui/qt4/main_interface.cpp |   44 ++++++++++++++++++++++-------------
 modules/gui/qt4/main_interface.hpp |   17 ++++++-------
 modules/gui/qt4/qt4.cpp            |   15 +++++-------
 3 files changed, 42 insertions(+), 34 deletions(-)

diff --git a/modules/gui/qt4/main_interface.cpp b/modules/gui/qt4/main_interface.cpp
index 87e2c3f..568bbff 100644
--- a/modules/gui/qt4/main_interface.cpp
+++ b/modules/gui/qt4/main_interface.cpp
@@ -198,11 +198,11 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
     /* END CONNECTS ON IM */
 
     /* VideoWidget connects for asynchronous calls */
-    connect( this, SIGNAL(askGetVideo(WId*,int*,int*,unsigned*,unsigned *)),
-             this, SLOT(getVideoSlot(WId*,int*,int*,unsigned*,unsigned*)),
+    connect( this, SIGNAL(askGetVideo(vout_window_t*, WId*)),
+             this, SLOT(getVideoSlot(vout_window_t*, WId*)),
              Qt::BlockingQueuedConnection );
-    connect( this, SIGNAL(askReleaseVideo( void )),
-             this, SLOT(releaseVideoSlot( void )),
+    connect( this, SIGNAL(askReleaseVideo(vout_window_t*)),
+             this, SLOT(releaseVideoSlot(vout_window_t*)),
              Qt::BlockingQueuedConnection );
 
     if( videoWidget )
@@ -553,8 +553,7 @@ private:
  * All window provider queries must be handled through signals or events.
  * That's why we have all those emit statements...
  */
-WId MainInterface::getVideo( int *pi_x, int *pi_y,
-                             unsigned int *pi_width, unsigned int *pi_height )
+WId MainInterface::getVideo( vout_window_t* p_wnd )
 {
     if( !videoWidget )
         return 0;
@@ -562,17 +561,26 @@ WId MainInterface::getVideo( int *pi_x, int *pi_y,
     /* This is a blocking call signal. Results are returned through pointers.
      * Beware of deadlocks! */
     WId id;
-    emit askGetVideo( &id, pi_x, pi_y, pi_width, pi_height );
+    emit askGetVideo( p_wnd, &id );
     return id;
 }
 
-void MainInterface::getVideoSlot( WId *p_id, int *pi_x, int *pi_y,
-                                  unsigned *pi_width, unsigned *pi_height )
+void MainInterface::getVideoSlot( vout_window_t* p_wnd, WId* p_id )
 {
+    int i_x = p_wnd->cfg->x;
+    int i_y = p_wnd->cfg->y;
+    unsigned i_width = p_wnd->cfg->width;
+    unsigned i_height = p_wnd->cfg->height;
+
     /* Request the videoWidget */
-    WId ret = videoWidget->request( pi_x, pi_y,
-                                    pi_width, pi_height, !b_autoresize );
-    *p_id = ret;
+    WId ret = videoWidget->request( &i_x, &i_y,
+                                    &i_width, &i_height, !b_autoresize );
+
+    p_wnd->handle.hwnd = *p_id = ret;
+
+    /* finish off setup work on behalf of the vout_display module */
+    vout_window_SendEventSetup( p_wnd );
+
     if( ret ) /* The videoWidget is available */
     {
         /* Consider the video active now */
@@ -580,20 +588,24 @@ void MainInterface::getVideoSlot( WId *p_id, int *pi_x, int *pi_y,
 
         /* Ask videoWidget to resize correctly, if we are in normal mode */
         if( !isFullScreen() && !isMaximized() && b_autoresize )
-            videoWidget->SetSizing( *pi_width, *pi_height );
+            videoWidget->SetSizing( i_width, i_height );
     }
+
 }
 
+
 /* Asynchronous call from the WindowClose function */
-void MainInterface::releaseVideo( void )
+void MainInterface::releaseVideo( vout_window_t* p_wnd )
 {
-    emit askReleaseVideo();
+    emit askReleaseVideo( p_wnd );
     QApplication::postEvent( this, new SetVideoOnTopQtEvent( false ) );
 }
 
 /* Function that is CONNECTED to the previous emit */
-void MainInterface::releaseVideoSlot( void )
+void MainInterface::releaseVideoSlot( vout_window_t* p_wnd )
 {
+    vout_window_SendEventCleanup( p_wnd );
+
     videoWidget->release();
 
     if( stackCentralW->currentWidget() == videoWidget )
diff --git a/modules/gui/qt4/main_interface.hpp b/modules/gui/qt4/main_interface.hpp
index 3390190..0f83a1c 100644
--- a/modules/gui/qt4/main_interface.hpp
+++ b/modules/gui/qt4/main_interface.hpp
@@ -33,6 +33,8 @@
  #include <vlc_windows_interfaces.h>
 #endif
 
+#include <vlc_vout_window.h>
+
 #include <QSystemTrayIcon>
 #include <QStackedWidget>
 
@@ -74,9 +76,8 @@ public:
     virtual ~MainInterface();
 
     /* Video requests from core */
-    WId  getVideo( int *pi_x, int *pi_y,
-                  unsigned int *pi_width, unsigned int *pi_height );
-    void releaseVideo( void );
+    WId  getVideo( vout_window_t* p_wnd );
+    void releaseVideo( vout_window_t* p_wnd );
     int  controlVideo( int i_query, va_list args );
 
     /* Getters */
@@ -183,9 +184,8 @@ public slots:
     void changeThumbbarButtons( int );
 
     /* Manage the Video Functions from the vout threads */
-    void getVideoSlot( WId *p_id, int *pi_x, int *pi_y,
-                       unsigned *pi_width, unsigned *pi_height );
-    void releaseVideoSlot( void );
+    void getVideoSlot( vout_window_t* p_wnd, WId* p_id );
+    void releaseVideoSlot( vout_window_t* p_wnd );
 
 private slots:
     void debug();
@@ -217,9 +217,8 @@ private slots:
 
 
 signals:
-    void askGetVideo( WId *p_id, int *pi_x, int *pi_y,
-                      unsigned *pi_width, unsigned *pi_height );
-    void askReleaseVideo( );
+    void askGetVideo( vout_window_t* p_wnd, WId* p_id );
+    void askReleaseVideo( vout_window_t* p_wnd );
     void askVideoToResize( unsigned int, unsigned int );
     void askVideoSetFullScreen( bool );
     void minimalViewToggled( bool );
diff --git a/modules/gui/qt4/qt4.cpp b/modules/gui/qt4/qt4.cpp
index 6d13f5b..dd197b9 100644
--- a/modules/gui/qt4/qt4.cpp
+++ b/modules/gui/qt4/qt4.cpp
@@ -554,21 +554,18 @@ static int WindowOpen( vlc_object_t *p_obj )
     MainInterface *p_mi = p_intf->p_sys->p_mi;
     msg_Dbg( p_obj, "requesting video..." );
 
-    int i_x = p_wnd->cfg->x;
-    int i_y = p_wnd->cfg->y;
-    unsigned i_width = p_wnd->cfg->width;
-    unsigned i_height = p_wnd->cfg->height;
-
 #if defined (Q_WS_X11)
-    p_wnd->handle.xid = p_mi->getVideo( &i_x, &i_y, &i_width, &i_height );
+    WId ret = p_mi->getVideo( p_wnd );
     if( !p_wnd->handle.xid )
         return VLC_EGENERIC;
+    p_wnd->handle.xid = ret;
     p_wnd->display.x11 = x11_display;
 
 #elif defined (Q_WS_WIN)
-    p_wnd->handle.hwnd = p_mi->getVideo( &i_x, &i_y, &i_width, &i_height );
-    if( !p_wnd->handle.hwnd )
+    WId ret = p_mi->getVideo( p_wnd );
+    if( !ret )
         return VLC_EGENERIC;
+    p_wnd->handle.hwnd = ret;
 #else
 # error FIXME
 #endif
@@ -590,6 +587,6 @@ static void WindowClose( vlc_object_t *p_obj )
     MainInterface *p_mi = (MainInterface *)p_wnd->sys;
 
     msg_Dbg( p_obj, "releasing video..." );
-    p_mi->releaseVideo();
+    p_mi->releaseVideo( p_wnd );
 }
 
-- 
1.5.6.5


