]> git.sesse.net Git - vlc/commitdiff
correctly implement VOUT_REPARENT in windows
authorFilippo Carone <littlejohn@videolan.org>
Sun, 15 Apr 2007 17:21:34 +0000 (17:21 +0000)
committerFilippo Carone <littlejohn@videolan.org>
Sun, 15 Apr 2007 17:21:34 +0000 (17:21 +0000)
modules/video_output/directx/events.c

index 4e5f93edf8b11cb475a0bbd9c6c80a93339f2ec5..a2bfe657f9c26846320ccc3ec91c36a947909ac0 100644 (file)
@@ -968,35 +968,47 @@ static int Control( vout_thread_t *p_vout, int i_query, va_list args )
     case VOUT_CLOSE:
         ShowWindow( p_vout->p_sys->hwnd, SW_HIDE );
     case VOUT_REPARENT:
-        /* Change window style, borders and title bar */
-        vlc_mutex_lock( &p_vout->p_sys->lock );
-        p_vout->p_sys->hparent = 0;
-        vlc_mutex_unlock( &p_vout->p_sys->lock );
-
         /* Retrieve the window position */
         point.x = point.y = 0;
         ClientToScreen( p_vout->p_sys->hwnd, &point );
 
-        int d = 0;
+        HWND d = 0;
 
-        if( i_query == VOUT_REPARENT ) d = va_arg( args, int );
+        if( i_query == VOUT_REPARENT ) d = (HWND)va_arg( args, int );
         if( !d )
         {
+            vlc_mutex_lock( &p_vout->p_sys->lock );
+            p_vout->p_sys->hparent = 0;
+            vlc_mutex_unlock( &p_vout->p_sys->lock );
             SetParent( p_vout->p_sys->hwnd, 0 );
             p_vout->p_sys->i_window_style =
                 WS_CLIPCHILDREN | WS_OVERLAPPEDWINDOW | WS_SIZEBOX;
+            SetWindowLong( p_vout->p_sys->hwnd, GWL_STYLE,
+                           p_vout->p_sys->i_window_style |
+                           (i_query == VOUT_CLOSE ? 0 : WS_VISIBLE) );
+            SetWindowLong( p_vout->p_sys->hwnd, GWL_EXSTYLE, WS_EX_APPWINDOW );
+            SetWindowPos( p_vout->p_sys->hwnd, 0, point.x, point.y, 0, 0,
+                          SWP_NOSIZE|SWP_NOZORDER|SWP_FRAMECHANGED );
         }
         else
         {
+            vlc_mutex_lock( &p_vout->p_sys->lock );
+            p_vout->p_sys->hparent = d;
+            vlc_mutex_unlock( &p_vout->p_sys->lock );
+
             SetParent( p_vout->p_sys->hwnd, d );
             p_vout->p_sys->i_window_style = WS_CLIPCHILDREN;
+            SetWindowLong( p_vout->p_sys->hwnd, GWL_STYLE,
+                           p_vout->p_sys->i_window_style |
+                           (i_query == VOUT_CLOSE ? 0 : WS_VISIBLE) );
+            SetWindowLong( p_vout->p_sys->hwnd, GWL_EXSTYLE, WS_EX_APPWINDOW );
+
+            /* Retrieve the parent size */
+            RECT  rect;
+            GetClientRect( d, &rect );
+            SetWindowPos( p_vout->p_sys->hwnd, d, point.x, point.y, rect.right, rect.bottom,
+                          SWP_FRAMECHANGED );
         }
-        SetWindowLong( p_vout->p_sys->hwnd, GWL_STYLE,
-                       p_vout->p_sys->i_window_style |
-                       (i_query == VOUT_CLOSE ? 0 : WS_VISIBLE) );
-        SetWindowLong( p_vout->p_sys->hwnd, GWL_EXSTYLE, WS_EX_APPWINDOW );
-        SetWindowPos( p_vout->p_sys->hwnd, 0, point.x, point.y, 0, 0,
-                      SWP_NOSIZE|SWP_NOZORDER|SWP_FRAMECHANGED );
 
         return vout_vaControlDefault( p_vout, i_query, args );