]> git.sesse.net Git - vlc/commitdiff
* modules/video_output/directx: last attempt at fixing the spurious taskbar item...
authorGildas Bazin <gbazin@videolan.org>
Tue, 9 Nov 2004 11:20:05 +0000 (11:20 +0000)
committerGildas Bazin <gbazin@videolan.org>
Tue, 9 Nov 2004 11:20:05 +0000 (11:20 +0000)
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 93a94b3e5711d84f615d6c6a4fe0966e67813eb2..2ad441c22ff58098e1105b6c40a75ae4ae9d24a5 100644 (file)
@@ -199,7 +199,7 @@ static int OpenVideo( vlc_object_t *p_this )
     p_vout->p_sys->p_current_surface = NULL;
     p_vout->p_sys->p_clipper = NULL;
     p_vout->p_sys->hwnd = p_vout->p_sys->hvideownd = NULL;
-    p_vout->p_sys->hparent = NULL;
+    p_vout->p_sys->hparent = p_vout->p_sys->hfswnd = NULL;
     p_vout->p_sys->i_changes = 0;
     p_vout->p_sys->b_wallpaper = 0;
     vlc_mutex_init( p_vout, &p_vout->p_sys->lock );
@@ -541,74 +541,69 @@ 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 )
     {
-        int i_style = 0;
         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 );
+
+            /* 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 )
             {
-                POINT point;
-
-                /* Retrieve the window position */
-                point.x = point.y = 0;
-                ClientToScreen( p_vout->p_sys->hwnd, &point );
-                SetParent( p_vout->p_sys->hwnd, GetDesktopWindow() );
-                SetWindowPos( p_vout->p_sys->hwnd, 0, point.x, point.y, 0, 0,
-                              SWP_NOSIZE|SWP_NOZORDER|SWP_FRAMECHANGED );
-                SetForegroundWindow( p_vout->p_sys->hwnd );
+                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 );
             }
 
-            /* Maximized window */
-            GetWindowPlacement( p_vout->p_sys->hwnd, &window_placement );
-            window_placement.showCmd = SW_SHOWMAXIMIZED;
-            /* Change window style, no borders and no title bar */
-            i_style = WS_CLIPCHILDREN | WS_VISIBLE | WS_POPUP;
+            SetForegroundWindow( hwnd );
         }
         else
         {
+            /* Change window style, no borders and no title bar */
+            int i_style = WS_CLIPCHILDREN | WS_OVERLAPPEDWINDOW |
+                WS_SIZEBOX | WS_VISIBLE;
+            SetWindowLong( hwnd, GWL_STYLE, i_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, 0, 0,
-                              SWP_NOSIZE|SWP_NOZORDER|SWP_FRAMECHANGED );
-                i_style = WS_CLIPCHILDREN | WS_VISIBLE | WS_CHILD;
+                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 );
             }
-            else
-            {
-                i_style = WS_CLIPCHILDREN | WS_OVERLAPPEDWINDOW |
-                          WS_SIZEBOX | WS_VISIBLE;
-            }
-
-            /* Normal window */
-            GetWindowPlacement( p_vout->p_sys->hwnd, &window_placement );
-            window_placement.showCmd = SW_SHOWNORMAL;
 
             /* Make sure the mouse cursor is displayed */
             PostMessage( p_vout->p_sys->hwnd, WM_VLC_SHOW_MOUSE, 0, 0 );
         }
 
-        if( p_vout->p_sys->hparent )
-        {
-            ShowWindow( p_vout->p_sys->hwnd, SW_HIDE );
-            SetWindowLong( p_vout->p_sys->hwnd, GWL_EXSTYLE,
-                           !p_vout->b_fullscreen ?
-                           WS_EX_NOPARENTNOTIFY | WS_EX_TOOLWINDOW :
-                           WS_EX_NOPARENTNOTIFY );
-            ShowWindow( p_vout->p_sys->hwnd, SW_SHOW );
-        }
-
-        /* Change window style, borders and title bar */
-        SetWindowLong( p_vout->p_sys->hwnd, GWL_STYLE, i_style );
-        SetWindowPlacement( p_vout->p_sys->hwnd, &window_placement );
-        SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0, 0, 0,
-                      SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_FRAMECHANGED );
-
         /* Update the object variable and trigger callback */
         val.b_bool = p_vout->b_fullscreen;
         var_Set( p_vout, "fullscreen", val );
index e15052964a3c3bc41a32f7f49d5a72ea6d54aaf2..a700632162491b5373c8a7652eac316ee11d34b3 100644 (file)
@@ -121,8 +121,7 @@ void DirectXEventThread( event_thread_t *p_event )
 
     /* Main loop */
     /* GetMessage will sleep if there's no message in the queue */
-    while( !p_event->b_die &&
-           GetMessage( &msg, p_event->p_vout->p_sys->hwnd, 0, 0 ) )
+    while( !p_event->b_die && GetMessage( &msg, 0, 0, 0 ) )
     {
         /* Check if we are asked to exit */
         if( p_event->b_die )
@@ -137,7 +136,7 @@ void DirectXEventThread( event_thread_t *p_event )
                                p_event->p_vout->p_sys->i_window_height,
                                &i_x, &i_y, &i_width, &i_height );
 
-            if( msg.hwnd != p_event->p_vout->p_sys->hwnd )
+            if( msg.hwnd == p_event->p_vout->p_sys->hvideownd )
             {
                 /* Child window */
                 i_x = i_y = 0;
@@ -361,7 +360,7 @@ static int DirectXCreateWindow( vout_thread_t *p_vout )
     WNDCLASSEX wc;                            /* window class components */
     HICON      vlc_icon = NULL;
     char       vlc_path[MAX_PATH+1];
-    int        i_style, i_stylex;
+    int        i_style;
 
     msg_Dbg( p_vout, "DirectXCreateWindow" );
 
@@ -441,17 +440,15 @@ static int DirectXCreateWindow( vout_thread_t *p_vout )
     AdjustWindowRect( &rect_window, WS_OVERLAPPEDWINDOW|WS_SIZEBOX, 0 );
 
     i_style = WS_OVERLAPPEDWINDOW|WS_SIZEBOX|WS_VISIBLE|WS_CLIPCHILDREN;
-    i_stylex = 0;
 
     if( p_vout->p_sys->hparent )
     {
         i_style = WS_VISIBLE|WS_CLIPCHILDREN|WS_CHILD;
-        i_stylex = WS_EX_TOOLWINDOW;
     }
 
     /* Create the window */
     p_vout->p_sys->hwnd =
-        CreateWindowEx( WS_EX_NOPARENTNOTIFY | i_stylex,
+        CreateWindowEx( WS_EX_NOPARENTNOTIFY,
                     "VLC DirectX",                   /* name of window class */
                     VOUT_TITLE " (DirectX Output)", /* window title bar text */
                     i_style,                                 /* window style */
@@ -483,6 +480,15 @@ static int DirectXCreateWindow( vout_thread_t *p_vout )
             /* Hmmm, apparently this is a blocking call... */
             SetWindowLong( p_vout->p_sys->hparent, GWL_STYLE,
                            i_style | WS_CLIPCHILDREN );
+
+        /* Create our fullscreen window */
+        p_vout->p_sys->hfswnd =
+            CreateWindowEx( WS_EX_APPWINDOW, "VLC DirectX",
+                            VOUT_TITLE " (DirectX Output)",
+                            WS_OVERLAPPEDWINDOW|WS_CLIPCHILDREN|WS_SIZEBOX,
+                            CW_USEDEFAULT, CW_USEDEFAULT,
+                            CW_USEDEFAULT, CW_USEDEFAULT,
+                            NULL, NULL, hInstance, NULL );
     }
 
     /* Now display the window */
@@ -512,6 +518,7 @@ static void DirectXCloseWindow( vout_thread_t *p_vout )
     msg_Dbg( p_vout, "DirectXCloseWindow" );
 
     DestroyWindow( p_vout->p_sys->hwnd );
+    if( p_vout->p_sys->hfswnd ) DestroyWindow( p_vout->p_sys->hfswnd );
 
     if( p_vout->p_sys->hparent )
         vout_ReleaseWindow( p_vout, (void *)p_vout->p_sys->hparent );
index 44d783c23a102ade346f017739455ace5fbdab10..aff358e3d5c3c09f099dd960fe1de16edb606802 100644 (file)
@@ -103,7 +103,7 @@ static int OpenVideo( vlc_object_t *p_this )
     p_vout->p_sys->p_current_surface = NULL;\r
     p_vout->p_sys->p_clipper = NULL;\r
     p_vout->p_sys->hwnd = p_vout->p_sys->hvideownd = NULL;\r
-    p_vout->p_sys->hparent = NULL;\r
+    p_vout->p_sys->hparent = p_vout->p_sys->hfswnd = NULL;\r
     p_vout->p_sys->i_changes = 0;\r
     p_vout->p_sys->b_wallpaper = 0;\r
     vlc_mutex_init( p_vout, &p_vout->p_sys->lock );\r
@@ -307,64 +307,69 @@ static int Manage( vout_thread_t *p_vout )
     if( p_vout->i_changes & VOUT_FULLSCREEN_CHANGE\r
         || p_vout->p_sys->i_changes & VOUT_FULLSCREEN_CHANGE )\r
     {\r
-        int i_style = 0;\r
         vlc_value_t val;\r
+        HWND hwnd = (p_vout->p_sys->hparent && p_vout->p_sys->hfswnd) ?\r
+            p_vout->p_sys->hfswnd : p_vout->p_sys->hwnd;\r
 \r
         p_vout->b_fullscreen = ! p_vout->b_fullscreen;\r
 \r
         /* We need to switch between Maximized and Normal sized window */\r
         window_placement.length = sizeof(WINDOWPLACEMENT);\r
+        GetWindowPlacement( hwnd, &window_placement );\r
         if( p_vout->b_fullscreen )\r
         {\r
+            /* Change window style, no borders and no title bar */\r
+            int i_style = WS_CLIPCHILDREN | WS_VISIBLE;\r
+            SetWindowLong( hwnd, GWL_STYLE, i_style );\r
+\r
+            /* Maximize window */\r
+            window_placement.showCmd = SW_SHOWMAXIMIZED;\r
+            SetWindowPlacement( hwnd, &window_placement );\r
+            SetWindowPos( hwnd, 0, 0, 0, 0, 0,\r
+                          SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_FRAMECHANGED);\r
+\r
             if( p_vout->p_sys->hparent )\r
             {\r
-                POINT point;\r
-\r
-                /* Retrieve the window position */\r
-                point.x = point.y = 0;\r
-                ClientToScreen( p_vout->p_sys->hwnd, &point );\r
-                SetParent( p_vout->p_sys->hwnd, GetDesktopWindow() );\r
-                SetWindowPos( p_vout->p_sys->hwnd, 0, point.x, point.y, 0, 0,\r
-                              SWP_NOSIZE|SWP_NOZORDER|SWP_FRAMECHANGED );\r
-                SetForegroundWindow( p_vout->p_sys->hwnd );\r
+                RECT rect;\r
+                GetClientRect( hwnd, &rect );\r
+                SetParent( p_vout->p_sys->hwnd, hwnd );\r
+                SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0,\r
+                              rect.right, rect.bottom,\r
+                              SWP_NOZORDER|SWP_FRAMECHANGED );\r
             }\r
 \r
-            /* Maximized window */\r
-            GetWindowPlacement( p_vout->p_sys->hwnd, &window_placement );\r
-            window_placement.showCmd = SW_SHOWMAXIMIZED;\r
-            /* Change window style, no borders and no title bar */\r
-            i_style = WS_CLIPCHILDREN | WS_VISIBLE | WS_POPUP;\r
+            SetForegroundWindow( hwnd );\r
         }\r
         else\r
         {\r
+            /* Change window style, no borders and no title bar */\r
+            int i_style = WS_CLIPCHILDREN | WS_OVERLAPPEDWINDOW |\r
+                WS_SIZEBOX | WS_VISIBLE;\r
+            SetWindowLong( hwnd, GWL_STYLE, i_style );\r
+\r
+            /* Normal window */\r
+            window_placement.showCmd = SW_SHOWNORMAL;\r
+            SetWindowPlacement( hwnd, &window_placement );\r
+            SetWindowPos( hwnd, 0, 0, 0, 0, 0,\r
+                          SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_FRAMECHANGED);\r
+\r
             if( p_vout->p_sys->hparent )\r
             {\r
+                RECT rect;\r
+                GetClientRect( p_vout->p_sys->hparent, &rect );\r
                 SetParent( p_vout->p_sys->hwnd, p_vout->p_sys->hparent );\r
-                SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0, 0, 0,\r
-                              SWP_NOSIZE|SWP_NOZORDER|SWP_FRAMECHANGED );\r
-                i_style = WS_CLIPCHILDREN | WS_VISIBLE | WS_CHILD;\r
+                SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0,\r
+                              rect.right, rect.bottom,\r
+                              SWP_NOZORDER|SWP_FRAMECHANGED );\r
+\r
+                ShowWindow( hwnd, SW_HIDE );\r
                 SetForegroundWindow( p_vout->p_sys->hparent );\r
             }\r
-            else\r
-            {\r
-                i_style = WS_CLIPCHILDREN | WS_OVERLAPPEDWINDOW |\r
-                          WS_SIZEBOX | WS_VISIBLE;\r
-            }\r
-\r
-            /* Normal window */\r
-            GetWindowPlacement( p_vout->p_sys->hwnd, &window_placement );\r
-            window_placement.showCmd = SW_SHOWNORMAL;\r
 \r
             /* Make sure the mouse cursor is displayed */\r
             PostMessage( p_vout->p_sys->hwnd, WM_VLC_SHOW_MOUSE, 0, 0 );\r
         }\r
 \r
-        /* Change window style, borders and title bar */\r
-        SetWindowLong( p_vout->p_sys->hwnd, GWL_STYLE, i_style );\r
-        SetWindowPlacement( p_vout->p_sys->hwnd, &window_placement );\r
-        SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0, 0, 0,\r
-                      SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_FRAMECHANGED );\r
-\r
         /* Update the object variable and trigger callback */\r
         val.b_bool = p_vout->b_fullscreen;\r
         var_Set( p_vout, "fullscreen", val );\r
index da5c5791e89876776679f3281450fc566801761d..80c9a89acac01906fc91d019ce72e7703f233ced 100644 (file)
@@ -49,6 +49,7 @@ struct vout_sys_t
     HWND                 hwnd;                  /* Handle of the main window */
     HWND                 hvideownd;        /* Handle of the video sub-window */
     HWND                 hparent;             /* Handle of the parent window */
+    HWND                 hfswnd;          /* Handle of the fullscreen window */
     WNDPROC              pf_wndproc;             /* Window handling callback */
 
     /* Multi-monitor support */