]> git.sesse.net Git - vlc/commitdiff
- directx: commit patch by Sergey Volk
authorDamien Fouilleul <damienf@videolan.org>
Tue, 8 May 2007 15:39:36 +0000 (15:39 +0000)
committerDamien Fouilleul <damienf@videolan.org>
Tue, 8 May 2007 15:39:36 +0000 (15:39 +0000)
modules/video_output/directx/direct3d.c
modules/video_output/directx/directx.c
modules/video_output/directx/events.c
modules/video_output/directx/glwin32.c
modules/video_output/directx/vout.h

index dfb56bec6bf8db7e7b3a0ceedc31f736ef58bc7c..ae3f3502a35cbfc6a1e50b11b2ceb1900a805e0a 100644 (file)
@@ -381,8 +381,6 @@ static void End( vout_thread_t *p_vout )
  *****************************************************************************/
 static int Manage( vout_thread_t *p_vout )
 {
-    WINDOWPLACEMENT window_placement;
-
     /* If we do not control our window, we check for geometry changes
      * ourselves because the parent might not send us its events. */
     vlc_mutex_lock( &p_vout->p_sys->lock );
@@ -467,84 +465,7 @@ static int Manage( vout_thread_t *p_vout )
     if( p_vout->i_changes & VOUT_FULLSCREEN_CHANGE
         || p_vout->p_sys->i_changes & VOUT_FULLSCREEN_CHANGE )
     {
-        vlc_value_t val;
-        HWND hwnd = (p_vout->p_sys->hparent && p_vout->p_sys->hfswnd) ?
-            p_vout->p_sys->hfswnd : p_vout->p_sys->hwnd;
-
-        p_vout->b_fullscreen = ! p_vout->b_fullscreen;
-
-        /* We need to switch between Maximized and Normal sized window */
-        window_placement.length = sizeof(WINDOWPLACEMENT);
-        GetWindowPlacement( hwnd, &window_placement );
-        if( p_vout->b_fullscreen )
-        {
-            /* Change window style, no borders and no title bar */
-            int i_style = WS_CLIPCHILDREN | WS_VISIBLE;
-            SetWindowLong( hwnd, GWL_STYLE, i_style );
-
-            if( p_vout->p_sys->hparent )
-            {
-                /* Retrieve current window position so fullscreen will happen
-                 * on the right screen */
-                POINT point = {0,0};
-                RECT rect;
-                ClientToScreen( p_vout->p_sys->hwnd, &point );
-                GetClientRect( p_vout->p_sys->hwnd, &rect );
-                SetWindowPos( hwnd, 0, point.x, point.y,
-                              rect.right, rect.bottom,
-                              SWP_NOZORDER|SWP_FRAMECHANGED );
-                GetWindowPlacement( hwnd, &window_placement );
-            }
-
-            /* Maximize window */
-            window_placement.showCmd = SW_SHOWMAXIMIZED;
-            SetWindowPlacement( hwnd, &window_placement );
-            SetWindowPos( hwnd, 0, 0, 0, 0, 0,
-                          SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_FRAMECHANGED);
-
-            if( p_vout->p_sys->hparent )
-            {
-                RECT rect;
-                GetClientRect( hwnd, &rect );
-                SetParent( p_vout->p_sys->hwnd, hwnd );
-                SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0,
-                              rect.right, rect.bottom,
-                              SWP_NOZORDER|SWP_FRAMECHANGED );
-            }
-
-            SetForegroundWindow( hwnd );
-        }
-        else
-        {
-            /* Change window style, no borders and no title bar */
-            SetWindowLong( hwnd, GWL_STYLE, p_vout->p_sys->i_window_style );
-
-            /* Normal window */
-            window_placement.showCmd = SW_SHOWNORMAL;
-            SetWindowPlacement( hwnd, &window_placement );
-            SetWindowPos( hwnd, 0, 0, 0, 0, 0,
-                          SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_FRAMECHANGED);
-
-            if( p_vout->p_sys->hparent )
-            {
-                RECT rect;
-                GetClientRect( p_vout->p_sys->hparent, &rect );
-                SetParent( p_vout->p_sys->hwnd, p_vout->p_sys->hparent );
-                SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0,
-                              rect.right, rect.bottom,
-                              SWP_NOZORDER|SWP_FRAMECHANGED );
-
-                ShowWindow( hwnd, SW_HIDE );
-                SetForegroundWindow( p_vout->p_sys->hparent );
-            }
-
-            /* Make sure the mouse cursor is displayed */
-            PostMessage( p_vout->p_sys->hwnd, WM_VLC_SHOW_MOUSE, 0, 0 );
-        }
-
-        /* Update the object variable and trigger callback */
-        val.b_bool = p_vout->b_fullscreen;
-        var_Set( p_vout, "fullscreen", val );
+        Win32ToggleFullscreen( p_vout );
 
         p_vout->i_changes &= ~VOUT_FULLSCREEN_CHANGE;
         p_vout->p_sys->i_changes &= ~VOUT_FULLSCREEN_CHANGE;
index 635c0425406e105a8313c15f1a66dd528721a7b3..9c86356532c461c7c1f830652f9e40a0126a48a0 100644 (file)
@@ -540,8 +540,6 @@ static void CloseVideo( vlc_object_t *p_this )
  *****************************************************************************/
 static int Manage( vout_thread_t *p_vout )
 {
-    WINDOWPLACEMENT window_placement;
-
     /* If we do not control our window, we check for geometry changes
      * ourselves because the parent might not send us its events. */
     vlc_mutex_lock( &p_vout->p_sys->lock );
@@ -631,84 +629,7 @@ static int Manage( vout_thread_t *p_vout )
     if( p_vout->i_changes & VOUT_FULLSCREEN_CHANGE
         || p_vout->p_sys->i_changes & VOUT_FULLSCREEN_CHANGE )
     {
-        vlc_value_t val;
-        HWND hwnd = (p_vout->p_sys->hparent && p_vout->p_sys->hfswnd) ?
-            p_vout->p_sys->hfswnd : p_vout->p_sys->hwnd;
-
-        p_vout->b_fullscreen = ! p_vout->b_fullscreen;
-
-        /* We need to switch between Maximized and Normal sized window */
-        window_placement.length = sizeof(WINDOWPLACEMENT);
-        GetWindowPlacement( hwnd, &window_placement );
-        if( p_vout->b_fullscreen )
-        {
-            /* Change window style, no borders and no title bar */
-            int i_style = WS_CLIPCHILDREN | WS_VISIBLE;
-            SetWindowLong( hwnd, GWL_STYLE, i_style );
-
-            if( p_vout->p_sys->hparent )
-            {
-                /* Retrieve current window position so fullscreen will happen
-                 * on the right screen */
-                POINT point = {0,0};
-                RECT rect;
-                ClientToScreen( p_vout->p_sys->hwnd, &point );
-                GetClientRect( p_vout->p_sys->hwnd, &rect );
-                SetWindowPos( hwnd, 0, point.x, point.y,
-                              rect.right, rect.bottom,
-                              SWP_NOZORDER|SWP_FRAMECHANGED );
-                GetWindowPlacement( hwnd, &window_placement );
-            }
-
-            /* Maximize window */
-            window_placement.showCmd = SW_SHOWMAXIMIZED;
-            SetWindowPlacement( hwnd, &window_placement );
-            SetWindowPos( hwnd, 0, 0, 0, 0, 0,
-                          SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_FRAMECHANGED);
-
-            if( p_vout->p_sys->hparent )
-            {
-                RECT rect;
-                GetClientRect( hwnd, &rect );
-                SetParent( p_vout->p_sys->hwnd, hwnd );
-                SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0,
-                              rect.right, rect.bottom,
-                              SWP_NOZORDER|SWP_FRAMECHANGED );
-            }
-
-            SetForegroundWindow( hwnd );
-        }
-        else
-        {
-            /* Change window style, no borders and no title bar */
-            SetWindowLong( hwnd, GWL_STYLE, p_vout->p_sys->i_window_style );
-
-            /* Normal window */
-            window_placement.showCmd = SW_SHOWNORMAL;
-            SetWindowPlacement( hwnd, &window_placement );
-            SetWindowPos( hwnd, 0, 0, 0, 0, 0,
-                          SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_FRAMECHANGED);
-
-            if( p_vout->p_sys->hparent )
-            {
-                RECT rect;
-                GetClientRect( p_vout->p_sys->hparent, &rect );
-                SetParent( p_vout->p_sys->hwnd, p_vout->p_sys->hparent );
-                SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0,
-                              rect.right, rect.bottom,
-                              SWP_NOZORDER|SWP_FRAMECHANGED );
-
-                ShowWindow( hwnd, SW_HIDE );
-                SetForegroundWindow( p_vout->p_sys->hparent );
-            }
-
-            /* Make sure the mouse cursor is displayed */
-            PostMessage( p_vout->p_sys->hwnd, WM_VLC_SHOW_MOUSE, 0, 0 );
-        }
-
-        /* Update the object variable and trigger callback */
-        val.b_bool = p_vout->b_fullscreen;
-        var_Set( p_vout, "fullscreen", val );
+        Win32ToggleFullscreen( p_vout );
 
         p_vout->i_changes &= ~VOUT_FULLSCREEN_CHANGE;
         p_vout->p_sys->i_changes &= ~VOUT_FULLSCREEN_CHANGE;
index 7879cbf0ea002a87521e4474e8814fcead66759b..646563ed837ed9a35422bc08e0ac298f6c3e0640 100644 (file)
@@ -1056,7 +1056,7 @@ static int Control( vout_thread_t *p_vout, int i_query, va_list args )
         return vout_vaControlDefault( p_vout, i_query, args );
 
     case VOUT_SET_STAY_ON_TOP:
-        if( p_vout->p_sys->hparent )
+        if( p_vout->p_sys->hparent && !var_GetBool( p_vout, "fullscreen" ) )
             return vout_ControlWindow( p_vout,
                     (void *)p_vout->p_sys->hparent, i_query, args );
 
@@ -1067,3 +1067,113 @@ static int Control( vout_thread_t *p_vout, int i_query, va_list args )
         return vout_vaControlDefault( p_vout, i_query, args );
     }
 }
+
+
+/* Internal wrapper over GetWindowPlacement / SetWindowPlacement */ 
+static void SetWindowState(HWND hwnd, int nShowCmd)
+{
+    WINDOWPLACEMENT window_placement;
+    window_placement.length = sizeof(WINDOWPLACEMENT);
+    GetWindowPlacement( hwnd, &window_placement );
+    window_placement.showCmd = nShowCmd;
+    SetWindowPlacement( hwnd, &window_placement );
+    SetWindowPos( hwnd, 0, 0, 0, 0, 0,
+        SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_FRAMECHANGED);
+}
+
+/* Internal wrapper to call vout_ControlWindow for hparent */
+static void ControlParentWindow( vout_thread_t *p_vout, int i_query, ... )
+{
+    va_list args;
+    va_start( args, i_query );
+    vout_ControlWindow( p_vout,
+        (void *)p_vout->p_sys->hparent, i_query, args );
+    va_end( args );
+}
+
+void Win32ToggleFullscreen( vout_thread_t *p_vout )
+{
+    HWND hwnd = (p_vout->p_sys->hparent && p_vout->p_sys->hfswnd) ?
+        p_vout->p_sys->hfswnd : p_vout->p_sys->hwnd;
+
+    p_vout->b_fullscreen = ! p_vout->b_fullscreen;
+
+    if( p_vout->b_fullscreen )
+    {
+        msg_Dbg( p_vout, "entering fullscreen mode" );
+        /* Change window style, no borders and no title bar */
+        int i_style = WS_CLIPCHILDREN | WS_VISIBLE;
+        SetWindowLong( hwnd, GWL_STYLE, i_style );
+
+        if( p_vout->p_sys->hparent )
+        {
+            /* Retrieve current window position so fullscreen will happen
+            * on the right screen */
+            POINT point = {0,0};
+            RECT rect;
+            ClientToScreen( p_vout->p_sys->hwnd, &point );
+            GetClientRect( p_vout->p_sys->hwnd, &rect );
+            SetWindowPos( hwnd, 0, point.x, point.y,
+                          rect.right, rect.bottom,
+                          SWP_NOZORDER|SWP_FRAMECHANGED );
+        }
+
+        /* Maximize window */
+        SetWindowState( hwnd, SW_SHOWMAXIMIZED );
+
+        if( p_vout->p_sys->hparent )
+        {
+            RECT rect;
+            GetClientRect( hwnd, &rect );
+            SetParent( p_vout->p_sys->hwnd, hwnd );
+            SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0,
+                          rect.right, rect.bottom,
+                          SWP_NOZORDER|SWP_FRAMECHANGED );
+
+            HWND topLevelParent = GetAncestor( p_vout->p_sys->hparent, GA_ROOT );
+            ShowWindow( topLevelParent, SW_HIDE );
+        }
+
+        SetForegroundWindow( hwnd );
+    }
+    else
+    {
+        msg_Dbg( p_vout, "leaving fullscreen mode" );
+        /* Change window style, no borders and no title bar */
+        SetWindowLong( hwnd, GWL_STYLE, p_vout->p_sys->i_window_style );
+
+        /* Normal window */
+        SetWindowState( hwnd, SW_SHOWNORMAL );
+
+        if( p_vout->p_sys->hparent )
+        {
+            RECT rect;
+            GetClientRect( p_vout->p_sys->hparent, &rect );
+            SetParent( p_vout->p_sys->hwnd, p_vout->p_sys->hparent );
+            SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0,
+                          rect.right, rect.bottom,
+                          SWP_NOZORDER|SWP_FRAMECHANGED );
+
+            HWND topLevelParent = GetAncestor( p_vout->p_sys->hparent, GA_ROOT );
+            ShowWindow( topLevelParent, SW_SHOW );
+            SetForegroundWindow( p_vout->p_sys->hparent );
+            ShowWindow( hwnd, SW_HIDE );
+
+            /* Update "video-on-top" status for main interface window, it
+            needs to be updated as we were hiding VOUT_SET_STAY_ON_TOP
+            queries from it while we were in fullscreen mode */
+            int b_ontop = var_GetBool( p_vout, "video-on-top" );
+            ControlParentWindow( p_vout, VOUT_SET_STAY_ON_TOP, b_ontop );
+        }
+
+        /* Make sure the mouse cursor is displayed */
+        PostMessage( p_vout->p_sys->hwnd, WM_VLC_SHOW_MOUSE, 0, 0 );
+    }
+
+    {
+        vlc_value_t val;
+        /* Update the object variable and trigger callback */
+        val.b_bool = p_vout->b_fullscreen;
+        var_Set( p_vout, "fullscreen", val );
+    }
+}
index 19dcace3568d58e1e608c4d95f5833f4055c8c4f..14fe9b2aeac4e4251c5ca723fb4c4b89bc0d7840 100644 (file)
@@ -256,8 +256,6 @@ static void CloseVideo( vlc_object_t *p_this )
  *****************************************************************************/
 static int Manage( vout_thread_t *p_vout )
 {
-    WINDOWPLACEMENT window_placement;
-
     int i_width = p_vout->p_sys->rect_dest.right -
         p_vout->p_sys->rect_dest.left;
     int i_height = p_vout->p_sys->rect_dest.bottom -
@@ -328,84 +326,7 @@ static int Manage( vout_thread_t *p_vout )
     if( p_vout->i_changes & VOUT_FULLSCREEN_CHANGE
         || p_vout->p_sys->i_changes & VOUT_FULLSCREEN_CHANGE )
     {
-        vlc_value_t val;
-        HWND hwnd = (p_vout->p_sys->hparent && p_vout->p_sys->hfswnd) ?
-            p_vout->p_sys->hfswnd : p_vout->p_sys->hwnd;
-
-        p_vout->b_fullscreen = ! p_vout->b_fullscreen;
-
-        /* We need to switch between Maximized and Normal sized window */
-        window_placement.length = sizeof(WINDOWPLACEMENT);
-        GetWindowPlacement( hwnd, &window_placement );
-        if( p_vout->b_fullscreen )
-        {
-            /* Change window style, no borders and no title bar */
-            int i_style = WS_CLIPCHILDREN | WS_VISIBLE;
-            SetWindowLong( hwnd, GWL_STYLE, i_style );
-
-            if( p_vout->p_sys->hparent )
-            {
-                /* Retrieve current window position so fullscreen will happen
-                 * on the right screen */
-                POINT point = {0,0};
-                RECT rect;
-                ClientToScreen( p_vout->p_sys->hwnd, &point );
-                GetClientRect( p_vout->p_sys->hwnd, &rect );
-                SetWindowPos( hwnd, 0, point.x, point.y,
-                              rect.right, rect.bottom,
-                              SWP_NOZORDER|SWP_FRAMECHANGED );
-                GetWindowPlacement( hwnd, &window_placement );
-            }
-
-            /* Maximize window */
-            window_placement.showCmd = SW_SHOWMAXIMIZED;
-            SetWindowPlacement( hwnd, &window_placement );
-            SetWindowPos( hwnd, 0, 0, 0, 0, 0,
-                          SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_FRAMECHANGED);
-
-            if( p_vout->p_sys->hparent )
-            {
-                RECT rect;
-                GetClientRect( hwnd, &rect );
-                SetParent( p_vout->p_sys->hwnd, hwnd );
-                SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0,
-                              rect.right, rect.bottom,
-                              SWP_NOZORDER|SWP_FRAMECHANGED );
-            }
-
-            SetForegroundWindow( hwnd );
-        }
-        else
-        {
-            /* Change window style, no borders and no title bar */
-            SetWindowLong( hwnd, GWL_STYLE, p_vout->p_sys->i_window_style );
-
-            /* Normal window */
-            window_placement.showCmd = SW_SHOWNORMAL;
-            SetWindowPlacement( hwnd, &window_placement );
-            SetWindowPos( hwnd, 0, 0, 0, 0, 0,
-                          SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_FRAMECHANGED);
-
-            if( p_vout->p_sys->hparent )
-            {
-                RECT rect;
-                GetClientRect( p_vout->p_sys->hparent, &rect );
-                SetParent( p_vout->p_sys->hwnd, p_vout->p_sys->hparent );
-                SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0,
-                              rect.right, rect.bottom,
-                              SWP_NOZORDER|SWP_FRAMECHANGED );
-
-                ShowWindow( hwnd, SW_HIDE );
-                SetForegroundWindow( p_vout->p_sys->hparent );
-            }
-
-            /* Make sure the mouse cursor is displayed */
-            PostMessage( p_vout->p_sys->hwnd, WM_VLC_SHOW_MOUSE, 0, 0 );
-        }
-
-        /* Update the object variable and trigger callback */
-        val.b_bool = p_vout->b_fullscreen;
-        var_Set( p_vout, "fullscreen", val );
+        Win32ToggleFullscreen( p_vout );
 
         p_vout->i_changes &= ~VOUT_FULLSCREEN_CHANGE;
         p_vout->p_sys->i_changes &= ~VOUT_FULLSCREEN_CHANGE;
index b8fb9dfde1d53726e36e794a953db2c8d589dfac..5fe7d9880b3927866ce2f5bc5470caadea42e8af 100644 (file)
@@ -147,6 +147,7 @@ int E_(DirectXUpdateOverlay)( vout_thread_t *p_vout );
  *****************************************************************************/
 void E_(DirectXEventThread) ( event_thread_t *p_event );
 void E_(DirectXUpdateRects) ( vout_thread_t *p_vout, vlc_bool_t b_force );
+void Win32ToggleFullscreen ( vout_thread_t *p_vout );
 
 /*****************************************************************************
  * Constants