]> git.sesse.net Git - vlc/blobdiff - mozilla/vlcshell.cpp
* modules/audio_output/directx.c: don't use hardware buffers for <= 2 channels.
[vlc] / mozilla / vlcshell.cpp
index 998c40bcbcbf9b471463de0271c4654a68c7f201..24401e6caf40a7d7189cf03066c65ad052bafde2 100644 (file)
@@ -2,7 +2,7 @@
  * vlcshell.cpp: a VLC plugin for Mozilla
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: vlcshell.cpp,v 1.25 2003/10/15 07:34:25 gbazin Exp $
+ * $Id: vlcshell.cpp,v 1.29 2004/01/25 17:52:17 gbazin Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *
@@ -27,6 +27,8 @@
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
+#include "config.h"
+
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
 #endif
 
 /* Mozilla stuff */
+#ifdef HAVE_MOZILLA_CONFIG_H
+#   include <mozilla-config.h>
+#endif
 #include <nsISupports.h>
 #include <nsMemory.h>
 #include <npapi.h>
+#include <jri.h>
+
+#if !defined(XP_MACOSX) && !defined(XP_UNIX) && !defined(XP_WIN)
+#define XP_UNIX 1
+#elif defined(XP_MACOSX)
+#undef XP_UNIX
+#endif
 
 #ifdef XP_WIN
     /* Windows stuff */
 #   include <Quickdraw.h>
 #endif
 
+#ifdef XP_UNIX
+    /* X11 stuff */
+#   include <X11/Xlib.h>
+#   include <X11/Intrinsic.h>
+#   include <X11/StringDefs.h>
+#endif
+
 #include "vlcpeer.h"
 #include "vlcplugin.h"
 
 #   define WINDOW_TEXT "(no libvlc)"
 #endif
 
-/* No, I really don't want to use XP_UNIX stuff on MacOSX */
-#ifdef XP_MACOSX
-#undef XP_UNIX
-#endif
-
-#ifdef XP_UNIX
-    /* X11 stuff */
-#   include <X11/Xlib.h>
-#   include <X11/Intrinsic.h>
-#   include <X11/StringDefs.h>
-#endif
-
 /*****************************************************************************
  * Unix-only declarations
 ******************************************************************************/
@@ -97,27 +104,10 @@ static void Redraw( Widget w, XtPointer closure, XEvent *event );
 #   define VOUT_PLUGINS "directx,wingdi,dummy"
 #   define AOUT_PLUGINS "directx,waveout,dummy"
 
-HINSTANCE g_hDllInstance = NULL;
-
-BOOL WINAPI DllMain( HINSTANCE hinstDLL, /* handle of DLL module */
-                     DWORD fdwReason,    /* reason for calling the function */
-                     LPVOID lpvReserved )
-{
-    switch( fdwReason )
-    {
-    case DLL_PROCESS_ATTACH:
-        g_hDllInstance = hinstDLL;
-        break;
-    case DLL_THREAD_ATTACH:
-    case DLL_PROCESS_DETACH:
-    case DLL_THREAD_DETACH:
-        break;
-    }
-    return TRUE;
-}
-
+#if defined(XP_WIN) && !USE_LIBVLC
 LRESULT CALLBACK Manage( HWND, UINT, WPARAM, LPARAM );
 #endif
+#endif
 
 /******************************************************************************
  * UNIX-only API calls
@@ -548,8 +538,10 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
         /* Window was destroyed. Invalidate everything. */
         if( p_plugin->p_npwin )
         {
+#if !USE_LIBVLC
             SetWindowLong( p_plugin->p_hwnd, GWL_WNDPROC,
                            (LONG)p_plugin->pf_wndproc );
+#endif
             p_plugin->pf_wndproc = NULL;
             p_plugin->p_hwnd = NULL;
         }
@@ -564,24 +556,31 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
         {
             /* Same window, but something may have changed. First we
              * update the plugin structure, then we redraw the window */
-            InvalidateRect( p_plugin->p_hwnd, NULL, TRUE );
             p_plugin->i_width = window->width;
             p_plugin->i_height = window->height;
             p_plugin->p_npwin = window;
+#if !USE_LIBVLC
+            InvalidateRect( p_plugin->p_hwnd, NULL, TRUE );
             UpdateWindow( p_plugin->p_hwnd );
+#endif
             return NPERR_NO_ERROR;
         }
 
         /* Window has changed. Destroy the one we have, and go
          * on as if it was a real initialization. */
+#if !USE_LIBVLC
         SetWindowLong( p_plugin->p_hwnd, GWL_WNDPROC,
                        (LONG)p_plugin->pf_wndproc );
+#endif
         p_plugin->pf_wndproc = NULL;
         p_plugin->p_hwnd = NULL;
     }
 
+#if !USE_LIBVLC
     p_plugin->pf_wndproc = (WNDPROC)SetWindowLong( (HWND)window->window,
                                                    GWL_WNDPROC, (LONG)Manage );
+#endif
+
     p_plugin->p_hwnd = (HWND)window->window;
     SetProp( p_plugin->p_hwnd, "w00t", (HANDLE)p_plugin );
     InvalidateRect( p_plugin->p_hwnd, NULL, TRUE );
@@ -803,14 +802,13 @@ void NPP_Print( NPP instance, NPPrint* printInfo )
 /******************************************************************************
  * Windows-only methods
  *****************************************************************************/
-#ifdef XP_WIN
+#if defined(XP_WIN) && !USE_LIBVLC
 LRESULT CALLBACK Manage( HWND p_hwnd, UINT i_msg, WPARAM wpar, LPARAM lpar )
 {
     VlcPlugin* p_plugin = (VlcPlugin*) GetProp( p_hwnd, "w00t" );
 
     switch( i_msg )
     {
-#if !USE_LIBVLC
         case WM_PAINT:
         {
             PAINTSTRUCT paintstruct;
@@ -827,7 +825,6 @@ LRESULT CALLBACK Manage( HWND p_hwnd, UINT i_msg, WPARAM wpar, LPARAM lpar )
             EndPaint( p_hwnd, &paintstruct );
             break;
         }
-#endif
         default:
             p_plugin->pf_wndproc( p_hwnd, i_msg, wpar, lpar );
             break;