default:
/* move on to instance variables ... */
- break;
+ ;
}
if( instance == NULL )
switch( variable )
{
case NPPVpluginScriptableNPObject:
- /* create an instance and return it */
- *(NPObject**)value = NPN_CreateObject(instance, p_plugin->getScriptClass());
- if( NULL == *(NPObject**)value )
+ {
+ /* retrieve plugin root class */
+ NPClass *scriptClass = p_plugin->getScriptClass();
+ if( scriptClass )
{
- return NPERR_OUT_OF_MEMORY_ERROR;
+ /* create an instance and return it */
+ *(NPObject**)value = NPN_CreateObject(instance, scriptClass);
+ return NPERR_NO_ERROR;
}
break;
+ }
default:
- return NPERR_GENERIC_ERROR;
+ ;
}
- return NPERR_NO_ERROR;
+ return NPERR_GENERIC_ERROR;
+}
+
+/*
+ * there is some confusion in gecko headers regarding definition of this API
+ * NPPVariable is wrongly defined as NPNVariable, which sounds incorrect.
+ */
+
+NPError NPP_SetValue( NPP instance, NPNVariable variable, void *value )
+{
+ return NPERR_GENERIC_ERROR;
}
/******************************************************************************
#ifdef XP_MACOSX
int16 NPP_HandleEvent( NPP instance, void * event )
{
+ static UInt32 lastMouseUp = 0;
+
if( instance == NULL )
{
return false;
}
VlcPlugin *p_plugin = (VlcPlugin*)instance->pdata;
+
+ if( p_plugin == NULL )
+ {
+ return false;
+ }
+
EventRecord *myEvent = (EventRecord*)event;
switch( myEvent->what )
{
case nullEvent:
- break;
+ return true;
case mouseDown:
+ {
+ if( (myEvent->when - lastMouseUp) < GetDblTime() )
+ {
+ /* double click */
+ libvlc_instance_t *p_vlc = p_plugin->getVLC();
+
+ if( p_vlc )
+ {
+ if( libvlc_playlist_isplaying(p_vlc, NULL) )
+ {
+ libvlc_media_instance_t *p_md = libvlc_playlist_get_media_instance(p_vlc, NULL);
+ if( p_md )
+ {
+ libvlc_toggle_fullscreen(p_md, NULL);
+ libvlc_media_instance_release(p_md);
+ }
+ }
+ }
+ }
+ return true;
+ }
case mouseUp:
+ lastMouseUp = myEvent->when;
return true;
case keyUp:
case keyDown:
return true;
case updateEvt:
{
- int needsDisplay = TRUE;
- libvlc_instance_t *p_vlc = p_plugin->getVLC();
-
- if( p_vlc )
+ const NPWindow& npwindow = p_plugin->getWindow();
+ if( npwindow.window )
{
- if( libvlc_playlist_isplaying(p_vlc, NULL) )
+ int hasVout = FALSE;
+ libvlc_instance_t *p_vlc = p_plugin->getVLC();
+
+ if( p_vlc )
{
- libvlc_input_t *p_input = libvlc_playlist_get_input(p_vlc, NULL);
- if( p_input )
+ if( libvlc_playlist_isplaying(p_vlc, NULL) )
{
- needsDisplay = ! libvlc_input_has_vout(p_input, NULL);
- libvlc_input_free(p_input);
+ libvlc_media_instance_t *p_md = libvlc_playlist_get_media_instance(p_vlc, NULL);
+ if( p_md )
+ {
+ hasVout = libvlc_media_instance_has_vout(p_md, NULL);
+ if( hasVout )
+ {
+ libvlc_rectangle_t area;
+ area.left = 0;
+ area.top = 0;
+ area.right = npwindow.width;
+ area.bottom = npwindow.height;
+ libvlc_video_redraw_rectangle(p_md, &area, NULL);
+ }
+ libvlc_media_instance_release(p_md);
+ }
}
}
- }
- const NPWindow *npwindow = p_plugin->getWindow();
-
- if( needsDisplay && npwindow->window )
- {
- /* draw the beautiful "No Picture" */
+ if( ! hasVout )
+ {
+ /* draw the beautiful "No Picture" */
- ForeColor(blackColor);
- PenMode( patCopy );
+ ForeColor(blackColor);
+ PenMode( patCopy );
- /* seems that firefox forgets to set the following on occasion (reload) */
- SetOrigin(((NP_Port *)npwindow->window)->portx, ((NP_Port *)npwindow->window)->porty);
+ /* seems that firefox forgets to set the following on occasion (reload) */
+ SetOrigin(((NP_Port *)npwindow.window)->portx, ((NP_Port *)npwindow.window)->porty);
- Rect rect;
- rect.left = 0;
- rect.top = 0;
- rect.right = npwindow->width;
- rect.bottom = npwindow->height;
- PaintRect( &rect );
+ Rect rect;
+ rect.left = 0;
+ rect.top = 0;
+ rect.right = npwindow.width;
+ rect.bottom = npwindow.height;
+ PaintRect( &rect );
- ForeColor(whiteColor);
- MoveTo( (npwindow->width-80)/ 2 , npwindow->height / 2 );
- DrawText( WINDOW_TEXT , 0 , strlen(WINDOW_TEXT) );
+ ForeColor(whiteColor);
+ MoveTo( (npwindow.width-80)/ 2 , npwindow.height / 2 );
+ DrawText( WINDOW_TEXT , 0 , strlen(WINDOW_TEXT) );
+ }
}
return true;
}
case NPEventType_ClippingChangedEvent:
return false;
case NPEventType_ScrollingBeginsEvent:
+ return true;
case NPEventType_ScrollingEndsEvent:
return true;
default:
}
status = p_plugin->init(argc, argn, argv);
- if( NPERR_NO_ERROR == status ) {
+ if( NPERR_NO_ERROR == status )
+ {
instance->pdata = reinterpret_cast<void*>(p_plugin);
+#if 0
+ NPN_SetValue(instance, NPPVpluginWindowBool, (void *)false);
+ NPN_SetValue(instance, NPPVpluginTransparentBool, (void *)false);
+#endif
}
- else {
+ else
+ {
delete p_plugin;
}
return status;
NPError NPP_Destroy( NPP instance, NPSavedData** save )
{
- if( instance == NULL )
- {
+ if( NULL == instance )
return NPERR_INVALID_INSTANCE_ERROR;
- }
VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(instance->pdata);
+ if( NULL == p_plugin )
+ return NPERR_NO_ERROR;
+
+ instance->pdata = NULL;
#if XP_WIN
- HWND win = (HWND)p_plugin->getWindow()->window;
+ HWND win = (HWND)p_plugin->getWindow().window;
WNDPROC winproc = p_plugin->getWindowProc();
if( winproc )
{
}
#endif
- if( p_plugin )
- delete p_plugin;
-
- instance->pdata = NULL;
+ delete p_plugin;
return NPERR_NO_ERROR;
}
* size changes, etc.
*/
- const NPWindow *curwin = p_plugin->getWindow();
+ /* retrieve current window */
+ NPWindow& curwin = p_plugin->getWindow();
#ifdef XP_MACOSX
if( window && window->window )
{
/* check if plugin has a new parent window */
CGrafPtr drawable = (((NP_Port*) (window->window))->port);
- if( !curwin->window || drawable != (((NP_Port*) (curwin->window))->port) )
+ if( !curwin.window || drawable != (((NP_Port*) (curwin.window))->port) )
{
/* set/change parent window */
libvlc_video_set_parent(p_vlc, (libvlc_drawable_t)drawable, NULL);
libvlc_video_set_viewport(p_vlc, &view, &clip, NULL);
- /* remember window details */
- p_plugin->setWindow(window);
+ /* remember new window */
+ p_plugin->setWindow(*window);
+ }
+ else if( curwin.window ) {
+ /* change/set parent */
+ libvlc_video_set_parent(p_vlc, 0, NULL);
+ curwin.window = NULL;
}
#endif /* XP_MACOSX */
{
/* check if plugin has a new parent window */
HWND drawable = (HWND) (window->window);
- if( !curwin->window || drawable != curwin->window )
+ if( !curwin.window || drawable != curwin.window )
{
/* reset previous window settings */
- HWND oldwin = (HWND)p_plugin->getWindow()->window;
+ HWND oldwin = (HWND)p_plugin->getWindow().window;
WNDPROC oldproc = p_plugin->getWindowProc();
if( oldproc )
{
/* change/set parent */
libvlc_video_set_parent(p_vlc, (libvlc_drawable_t)drawable, NULL);
- }
- /* remember window details */
- p_plugin->setWindow(window);
+ /* remember new window */
+ p_plugin->setWindow(*window);
- /* Redraw window */
- InvalidateRect( (HWND)drawable, NULL, TRUE );
- UpdateWindow( (HWND)drawable );
+ /* Redraw window */
+ InvalidateRect( (HWND)drawable, NULL, TRUE );
+ UpdateWindow( (HWND)drawable );
+ }
}
- else
+ else if ( curwin.window )
{
/* reset WNDPROC */
- HWND oldwin = (HWND)curwin->window;
+ HWND oldwin = (HWND)curwin.window;
SetWindowLong( oldwin, GWL_WNDPROC, (LONG)(p_plugin->getWindowProc()) );
p_plugin->setWindowProc(NULL);
/* change/set parent */
libvlc_video_set_parent(p_vlc, 0, NULL);
+ curwin.window = NULL;
}
#endif /* XP_WIN */
if( window && window->window )
{
Window drawable = (Window) window->window;
- if( !curwin->window || drawable != (Window)curwin->window )
+ if( !curwin.window || drawable != (Window)curwin.window )
{
Display *p_display = ((NPSetWindowCallbackStruct *)window->ws_info)->display;
libvlc_video_set_parent(p_vlc, (libvlc_drawable_t)drawable, NULL);
/* remember window */
- p_plugin->setWindow(window);
+ p_plugin->setWindow(*window);
Redraw( w, (XtPointer)p_plugin, NULL );
}
}
+ else if ( curwin.window )
+ {
+ /* change/set parent */
+ libvlc_video_set_parent(p_vlc, 0, NULL);
+ curwin.window = NULL;
+ }
#endif /* XP_UNIX */
if( !p_plugin->b_stream )
{
if( p_plugin->psz_target )
{
- if( VLC_SUCCESS == libvlc_playlist_add( p_vlc, p_plugin->psz_target, NULL, NULL ) )
+ if( libvlc_playlist_add( p_vlc, p_plugin->psz_target, NULL, NULL ) != -1 )
{
if( p_plugin->b_autoplay )
{
libvlc_playlist_play(p_vlc, 0, 0, NULL, NULL);
}
- p_plugin->b_stream = VLC_TRUE;
}
+ p_plugin->b_stream = VLC_TRUE;
}
}
return NPERR_NO_ERROR;
}
VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(instance->pdata);
+ if( NULL == p_plugin )
+ {
+ return NPERR_INVALID_INSTANCE_ERROR;
+ }
/*
** Firefox/Mozilla may decide to open a stream from the URL specified
}
VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(instance->pdata);
+ if( NULL == p_plugin )
+ {
+ return;
+ }
- if( VLC_SUCCESS == libvlc_playlist_add( p_plugin->getVLC(), fname, stream->url, NULL ) )
+ if( libvlc_playlist_add( p_plugin->getVLC(), fname, stream->url, NULL ) != -1 )
{
if( p_plugin->b_autoplay )
{
FillRect( hdc, &rect, (HBRUSH)GetStockObject(BLACK_BRUSH) );
SetTextColor(hdc, RGB(255, 255, 255));
SetBkColor(hdc, RGB(0, 0, 0));
- DrawText( hdc, WINDOW_TEXT, strlen(WINDOW_TEXT), &rect, DT_CENTER|DT_VCENTER|DT_SINGLELINE);
+ DrawText( hdc, WINDOW_TEXT, strlen(WINDOW_TEXT), &rect, DT_CENTER|DT_VCENTER|DT_SINGLELINE);
EndPaint( p_hwnd, &paintstruct );
return 0L;
}
default:
/* delegate to default handler */
- return p_plugin->getWindowProc()( p_hwnd, i_msg, wpar, lpar );
+ return CallWindowProc(p_plugin->getWindowProc(), p_hwnd, i_msg, wpar, lpar );
}
}
#endif /* XP_WIN */
static void Redraw( Widget w, XtPointer closure, XEvent *event )
{
VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(closure);
- const NPWindow *window = p_plugin->getWindow();
+ const NPWindow& window = p_plugin->getWindow();
GC gc;
XGCValues gcv;
- Window drawable = (Window) window->window;
- Display *p_display = ((NPSetWindowCallbackStruct *)window->ws_info)->display;
+ Window drawable = (Window) window.window;
+ Display *p_display = ((NPSetWindowCallbackStruct *)window.ws_info)->display;
gcv.foreground = BlackPixel( p_display, 0 );
gc = XCreateGC( p_display, drawable, GCForeground, &gcv );
XFillRectangle( p_display, drawable, gc,
- 0, 0, window->width, window->height );
+ 0, 0, window.width, window.height );
gcv.foreground = WhitePixel( p_display, 0 );
XChangeGC( p_display, gc, GCForeground, &gcv );
XDrawString( p_display, drawable, gc,
- window->width / 2 - 40, window->height / 2,
+ window.width / 2 - 40, window.height / 2,
WINDOW_TEXT, strlen(WINDOW_TEXT) );
XFreeGC( p_display, gc );
static void Resize ( Widget w, XtPointer closure, XEvent *event )
{
VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(closure);
- const NPWindow *window = p_plugin->getWindow();
- Window drawable = (Window) window->window;
- Display *p_display = ((NPSetWindowCallbackStruct *)window->ws_info)->display;
+ const NPWindow& window = p_plugin->getWindow();
+ Window drawable = (Window) window.window;
+ Display *p_display = ((NPSetWindowCallbackStruct *)window.ws_info)->display;
int i_ret;
Window root_return, parent_return, * children_return;
}
#endif /* X11_RESIZE_DEBUG */
- if( ! p_plugin->setSize(window->width, window->height) )
+ if( ! p_plugin->setSize(window.width, window.height) )
{
/* size already set */
return;
}
- i_ret = XResizeWindow( p_display, drawable, window->width, window->height );
+ i_ret = XResizeWindow( p_display, drawable, window.width, window.height );
#ifdef X11_RESIZE_DEBUG
fprintf( stderr,
#endif /* X11_RESIZE_DEBUG */
i_ret = XResizeWindow( p_display, base_window,
- window->width, window->height );
+ window.width, window.height );
#ifdef X11_RESIZE_DEBUG
fprintf( stderr,