Commit 250b7e43 authored by Jean-Paul Saman's avatar Jean-Paul Saman

mozilla: deliver async events under windows

In the windows gecko-sdk the call NPN_PluginThreadAsyncCall() is not supported, so the code most resort to an older method of sending async events from the plugin to the browser.
Source: http://stackoverflow.com/questions/1931883/generating-async-javascript-events-from-browser-plugin-npapiSigned-off-by: Jean-Paul Saman's avatarJean-Paul Saman <jean-paul.saman@m2x.nl>
parent 21ad24ea
......@@ -39,6 +39,7 @@
#elif defined(XP_WIN)
/* windows headers */
# include <winbase.h>
extern void ScheduleAsyncCall(HWND p_hwnd, void (*func)(void *), void *userData);
#else
#warning "locking not implemented for this platform"
#endif
......@@ -396,9 +397,12 @@ void VlcPlugin::event_callback(const libvlc_event_t* event,
NPVariant *npparams, uint32_t npcount, void *userdata)
{
VlcPlugin *plugin = (VlcPlugin*)userdata;
#if defined(XP_UNIX)
plugin->events.callback(event, npparams, npcount);
#if defined(XP_UNIX)
NPN_PluginThreadAsyncCall(plugin->getBrowser(), eventAsync, plugin);
#elif defined(XP_WIN)
HWND hwnd = (HWND)plugin->getWindow().window;
ScheduleAsyncCall(hwnd, eventAsync, plugin);
#else
#warning NPN_PluginThreadAsyncCall not implemented yet.
printf("No NPN_PluginThreadAsyncCall(), doing nothing.\n");
......
/*****************************************************************************
* vlcplugin.h: a VLC plugin for Mozilla
*****************************************************************************
* Copyright (C) 2002-2009 the VideoLAN team
* Copyright (C) 2002-2010 the VideoLAN team
* $Id$
*
* Authors: Samuel Hocevar <sam@zoy.org>
......
......@@ -718,10 +718,33 @@ void NPP_Print( NPP instance, NPPrint* printInfo )
* Windows-only methods
*****************************************************************************/
#if defined(XP_WIN)
#define WM_ASYNCTHREADINVOKE WM_USER + 1
struct WINDOWS_ASYNC_EVENT
{
WINDOWS_ASYNC_EVENT(void (*f)(void *), void *ud)
: func(f), userData(ud) { }
void (*func)(void *);
void *userData;
};
void ScheduleAsyncCall(HWND p_hwnd, void (*func)(void *), void *userData)
{
if (p_hwnd != NULL)
::PostMessage(p_hwnd, WM_ASYNCTHREADINVOKE, NULL,
(LPARAM)new ::WINDOWS_ASYNC_EVENT(func, userData));
}
static LRESULT CALLBACK Manage( HWND p_hwnd, UINT i_msg, WPARAM wpar, LPARAM lpar )
{
VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(GetWindowLongPtr(p_hwnd, GWLP_USERDATA));
if (i_msg == WM_ASYNCTHREADINVOKE) {
WINDOWS_ASYNC_EVENT *evt = static_cast<WINDOWS_ASYNC_EVENT*>((void*)lpar);
evt->func(evt->userData);
return S_OK;
}
switch( i_msg )
{
case WM_ERASEBKGND:
......
......@@ -79,4 +79,8 @@ int16_t NPP_HandleEvent( NPP instance, void * event );
#endif
#endif
#ifdef XP_WIN
void ScheduleAsyncCall(HWND p_hwnd, void (*func)(void *), void *userData);
#endif /* XP_WIN */
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment