]> git.sesse.net Git - vlc/commitdiff
* ./modules/video_output/directx/events.c: we now call CreateWindow so that
authorSam Hocevar <sam@videolan.org>
Fri, 22 Nov 2002 15:24:10 +0000 (15:24 +0000)
committerSam Hocevar <sam@videolan.org>
Fri, 22 Nov 2002 15:24:10 +0000 (15:24 +0000)
    we are sure that the WndProc always has a valid p_vout value.

modules/video_output/directx/events.c

index 7f5dc56835fcc2679f62e1eda99fcca76fdcd8c1..9aa486f44977302e4872a88a614ee419471ed833 100644 (file)
@@ -2,7 +2,7 @@
  * events.c: Windows DirectX video output events handler
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: events.c,v 1.6 2002/10/25 18:17:59 sam Exp $
+ * $Id: events.c,v 1.7 2002/11/22 15:24:10 sam Exp $
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
  *
@@ -324,6 +324,10 @@ static int DirectXCreateWindow( vout_thread_t *p_vout )
                       GCL_HBRBACKGROUND, (LONG)p_vout->p_sys->hbrush );
         SetClassLong( p_vout->p_sys->hwnd,
                       GCL_HCURSOR, (LONG)LoadCursor(NULL, IDC_ARROW) );
+        /* Store a p_vout pointer into the window local storage (for later
+         * use in DirectXEventProc). */
+        SetWindowLong( p_vout->p_sys->hwnd, GWL_USERDATA, (LONG)p_vout );
+
         p_vout->p_sys->pf_wndproc =
                (WNDPROC)SetWindowLong( p_vout->p_sys->hwnd,
                                        GWL_WNDPROC, (LONG)DirectXEventProc );
@@ -407,7 +411,7 @@ static int DirectXCreateWindow( vout_thread_t *p_vout )
                     NULL,                                /* no parent window */
                     NULL,                          /* no menu in this window */
                     hInstance,            /* handle of this program instance */
-                    NULL);                        /* no additional arguments */
+                    (LPVOID)p_vout );            /* send p_vout to WM_CREATE */
 
         if( !p_vout->p_sys->hwnd )
         {
@@ -416,11 +420,6 @@ static int DirectXCreateWindow( vout_thread_t *p_vout )
         }
     }
 
-    /* Store a p_vout pointer into the window local storage (for later use
-     * in DirectXEventProc).
-     * We need to use SetWindowLongPtr when it is available in mingw */
-    SetWindowLong( p_vout->p_sys->hwnd, GWL_USERDATA, (LONG)p_vout );
-
     /* Append a "Always On Top" entry in the system menu */
     hMenu = GetSystemMenu( p_vout->p_sys->hwnd, FALSE );
     AppendMenu( hMenu, MF_SEPARATOR, 0, "" );
@@ -587,13 +586,17 @@ void DirectXUpdateRects( vout_thread_t *p_vout, vlc_bool_t b_force )
 static long FAR PASCAL DirectXEventProc( HWND hwnd, UINT message,
                                          WPARAM wParam, LPARAM lParam )
 {
-    vout_thread_t *p_vout =
-            (vout_thread_t *)GetWindowLong( hwnd, GWL_USERDATA );
+    vout_thread_t *p_vout;
 
-    /* Just in case the window wasn't properly initialized yet */
-    if( !p_vout )
+    if( message == WM_CREATE )
+    {
+        /* Store p_vout for future use */
+        p_vout = (vout_thread_t *)((CREATESTRUCT *)lParam)->lpCreateParams;
+        SetWindowLong( hWnd, GWL_USERDATA, (LONG)p_vout );
+    }
+    else
     {
-        return DefWindowProc( hwnd, message, wParam, lParam );
+        p_vout = (vout_thread_t *)GetWindowLong( hWnd, GWL_USERDATA );
     }
 
     switch( message )