Commit 2d3624ca authored by Damien Fouilleul's avatar Damien Fouilleul

- mozilla: support for libvlc_video_redraw_rectangle() message for PAINT events and misc cleanups

parent 9ba00f59
...@@ -66,10 +66,10 @@ public: ...@@ -66,10 +66,10 @@ public:
NPP getBrowser() NPP getBrowser()
{ return p_browser; }; { return p_browser; };
char* getAbsoluteURL(const char *url); char* getAbsoluteURL(const char *url);
const NPWindow* getWindow() NPWindow& getWindow()
{ return &npwindow; }; { return npwindow; };
void setWindow(const NPWindow *window) void setWindow(const NPWindow &window)
{ npwindow = *window; }; { npwindow = window; };
NPClass* getScriptClass() NPClass* getScriptClass()
{ return p_scriptClass; }; { return p_scriptClass; };
......
...@@ -172,7 +172,7 @@ int16 NPP_HandleEvent( NPP instance, void * event ) ...@@ -172,7 +172,7 @@ int16 NPP_HandleEvent( NPP instance, void * event )
switch( myEvent->what ) switch( myEvent->what )
{ {
case nullEvent: case nullEvent:
break; return true;
case mouseDown: case mouseDown:
{ {
if( (myEvent->when - lastMouseUp) < GetDblTime() ) if( (myEvent->when - lastMouseUp) < GetDblTime() )
...@@ -204,44 +204,55 @@ int16 NPP_HandleEvent( NPP instance, void * event ) ...@@ -204,44 +204,55 @@ int16 NPP_HandleEvent( NPP instance, void * event )
return true; return true;
case updateEvt: case updateEvt:
{ {
int needsDisplay = TRUE; const NPWindow& npwindow = p_plugin->getWindow();
libvlc_instance_t *p_vlc = p_plugin->getVLC(); if( npwindow.window )
if( p_vlc )
{ {
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( libvlc_playlist_isplaying(p_vlc, NULL) )
if( p_input )
{ {
needsDisplay = ! libvlc_input_has_vout(p_input, NULL); libvlc_input_t *p_input = libvlc_playlist_get_input(p_vlc, NULL);
libvlc_input_free(p_input); if( p_input )
{
hasVout = libvlc_input_has_vout(p_input, 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_input, &area, NULL);
}
libvlc_input_free(p_input);
}
} }
} }
}
const NPWindow *npwindow = p_plugin->getWindow();
if( needsDisplay && npwindow->window ) if( ! hasVout )
{ {
/* draw the beautiful "No Picture" */ /* draw the beautiful "No Picture" */
ForeColor(blackColor); ForeColor(blackColor);
PenMode( patCopy ); PenMode( patCopy );
/* seems that firefox forgets to set the following on occasion (reload) */ /* seems that firefox forgets to set the following on occasion (reload) */
SetOrigin(((NP_Port *)npwindow->window)->portx, ((NP_Port *)npwindow->window)->porty); SetOrigin(((NP_Port *)npwindow.window)->portx, ((NP_Port *)npwindow.window)->porty);
Rect rect; Rect rect;
rect.left = 0; rect.left = 0;
rect.top = 0; rect.top = 0;
rect.right = npwindow->width; rect.right = npwindow.width;
rect.bottom = npwindow->height; rect.bottom = npwindow.height;
PaintRect( &rect ); PaintRect( &rect );
ForeColor(whiteColor); ForeColor(whiteColor);
MoveTo( (npwindow->width-80)/ 2 , npwindow->height / 2 ); MoveTo( (npwindow.width-80)/ 2 , npwindow.height / 2 );
DrawText( WINDOW_TEXT , 0 , strlen(WINDOW_TEXT) ); DrawText( WINDOW_TEXT , 0 , strlen(WINDOW_TEXT) );
}
} }
return true; return true;
} }
...@@ -257,6 +268,7 @@ int16 NPP_HandleEvent( NPP instance, void * event ) ...@@ -257,6 +268,7 @@ int16 NPP_HandleEvent( NPP instance, void * event )
case NPEventType_ClippingChangedEvent: case NPEventType_ClippingChangedEvent:
return false; return false;
case NPEventType_ScrollingBeginsEvent: case NPEventType_ScrollingBeginsEvent:
return true;
case NPEventType_ScrollingEndsEvent: case NPEventType_ScrollingEndsEvent:
return true; return true;
default: default:
...@@ -304,8 +316,10 @@ NPError NPP_New( NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, ...@@ -304,8 +316,10 @@ NPError NPP_New( NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc,
if( NPERR_NO_ERROR == status ) if( NPERR_NO_ERROR == status )
{ {
instance->pdata = reinterpret_cast<void*>(p_plugin); instance->pdata = reinterpret_cast<void*>(p_plugin);
//NPN_SetValue(instance, NPPVpluginWindowBool, (void *)false); #if 0
NPN_SetValue(instance, NPPVpluginWindowBool, (void *)false);
NPN_SetValue(instance, NPPVpluginTransparentBool, (void *)false); NPN_SetValue(instance, NPPVpluginTransparentBool, (void *)false);
#endif
} }
else else
{ {
...@@ -326,7 +340,7 @@ NPError NPP_Destroy( NPP instance, NPSavedData** save ) ...@@ -326,7 +340,7 @@ NPError NPP_Destroy( NPP instance, NPSavedData** save )
instance->pdata = NULL; instance->pdata = NULL;
#if XP_WIN #if XP_WIN
HWND win = (HWND)p_plugin->getWindow()->window; HWND win = (HWND)p_plugin->getWindow().window;
WNDPROC winproc = p_plugin->getWindowProc(); WNDPROC winproc = p_plugin->getWindowProc();
if( winproc ) if( winproc )
{ {
...@@ -365,14 +379,15 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window ) ...@@ -365,14 +379,15 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
* size changes, etc. * size changes, etc.
*/ */
const NPWindow *curwin = p_plugin->getWindow(); /* retrieve current window */
NPWindow& curwin = p_plugin->getWindow();
#ifdef XP_MACOSX #ifdef XP_MACOSX
if( window && window->window ) if( window && window->window )
{ {
/* check if plugin has a new parent window */ /* check if plugin has a new parent window */
CGrafPtr drawable = (((NP_Port*) (window->window))->port); 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 */ /* set/change parent window */
libvlc_video_set_parent(p_vlc, (libvlc_drawable_t)drawable, NULL); libvlc_video_set_parent(p_vlc, (libvlc_drawable_t)drawable, NULL);
...@@ -397,8 +412,13 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window ) ...@@ -397,8 +412,13 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
libvlc_video_set_viewport(p_vlc, &view, &clip, NULL); libvlc_video_set_viewport(p_vlc, &view, &clip, NULL);
/* remember window details */ /* remember new window */
p_plugin->setWindow(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 */ #endif /* XP_MACOSX */
...@@ -407,10 +427,10 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window ) ...@@ -407,10 +427,10 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
{ {
/* check if plugin has a new parent window */ /* check if plugin has a new parent window */
HWND drawable = (HWND) (window->window); HWND drawable = (HWND) (window->window);
if( !curwin->window || drawable != curwin->window ) if( !curwin.window || drawable != curwin.window )
{ {
/* reset previous window settings */ /* reset previous window settings */
HWND oldwin = (HWND)p_plugin->getWindow()->window; HWND oldwin = (HWND)p_plugin->getWindow().window;
WNDPROC oldproc = p_plugin->getWindowProc(); WNDPROC oldproc = p_plugin->getWindowProc();
if( oldproc ) if( oldproc )
{ {
...@@ -431,23 +451,24 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window ) ...@@ -431,23 +451,24 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
/* change/set parent */ /* change/set parent */
libvlc_video_set_parent(p_vlc, (libvlc_drawable_t)drawable, NULL); libvlc_video_set_parent(p_vlc, (libvlc_drawable_t)drawable, NULL);
}
/* remember window details */ /* remember new window */
p_plugin->setWindow(window); p_plugin->setWindow(*window);
/* Redraw window */ /* Redraw window */
InvalidateRect( (HWND)drawable, NULL, TRUE ); InvalidateRect( (HWND)drawable, NULL, TRUE );
UpdateWindow( (HWND)drawable ); UpdateWindow( (HWND)drawable );
}
} }
else else if ( curwin->window )
{ {
/* reset WNDPROC */ /* reset WNDPROC */
HWND oldwin = (HWND)curwin->window; HWND oldwin = (HWND)curwin.window;
SetWindowLong( oldwin, GWL_WNDPROC, (LONG)(p_plugin->getWindowProc()) ); SetWindowLong( oldwin, GWL_WNDPROC, (LONG)(p_plugin->getWindowProc()) );
p_plugin->setWindowProc(NULL); p_plugin->setWindowProc(NULL);
/* change/set parent */ /* change/set parent */
libvlc_video_set_parent(p_vlc, 0, NULL); libvlc_video_set_parent(p_vlc, 0, NULL);
curwin->window = NULL;
} }
#endif /* XP_WIN */ #endif /* XP_WIN */
...@@ -469,11 +490,17 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window ) ...@@ -469,11 +490,17 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
libvlc_video_set_parent(p_vlc, (libvlc_drawable_t)drawable, NULL); libvlc_video_set_parent(p_vlc, (libvlc_drawable_t)drawable, NULL);
/* remember window */ /* remember window */
p_plugin->setWindow(window); p_plugin->setWindow(*window);
Redraw( w, (XtPointer)p_plugin, NULL ); 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 */ #endif /* XP_UNIX */
if( !p_plugin->b_stream ) if( !p_plugin->b_stream )
...@@ -694,11 +721,11 @@ static LRESULT CALLBACK Manage( HWND p_hwnd, UINT i_msg, WPARAM wpar, LPARAM lpa ...@@ -694,11 +721,11 @@ static LRESULT CALLBACK Manage( HWND p_hwnd, UINT i_msg, WPARAM wpar, LPARAM lpa
static void Redraw( Widget w, XtPointer closure, XEvent *event ) static void Redraw( Widget w, XtPointer closure, XEvent *event )
{ {
VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(closure); VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(closure);
const NPWindow *window = p_plugin->getWindow(); const NPWindow& window = p_plugin->getWindow();
GC gc; GC gc;
XGCValues gcv; XGCValues gcv;
Window drawable = (Window) window->window; Window drawable = (Window) window.window;
Display *p_display = ((NPSetWindowCallbackStruct *)window->ws_info)->display; Display *p_display = ((NPSetWindowCallbackStruct *)window->ws_info)->display;
gcv.foreground = BlackPixel( p_display, 0 ); gcv.foreground = BlackPixel( p_display, 0 );
...@@ -720,8 +747,8 @@ static void Redraw( Widget w, XtPointer closure, XEvent *event ) ...@@ -720,8 +747,8 @@ static void Redraw( Widget w, XtPointer closure, XEvent *event )
static void Resize ( Widget w, XtPointer closure, XEvent *event ) static void Resize ( Widget w, XtPointer closure, XEvent *event )
{ {
VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(closure); VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(closure);
const NPWindow *window = p_plugin->getWindow(); const NPWindow& window = p_plugin->getWindow();
Window drawable = (Window) window->window; Window drawable = (Window) window.window;
Display *p_display = ((NPSetWindowCallbackStruct *)window->ws_info)->display; Display *p_display = ((NPSetWindowCallbackStruct *)window->ws_info)->display;
int i_ret; int i_ret;
......
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