Commit 03a19fdb authored by Anthony Loiseau's avatar Anthony Loiseau Committed by Jean-Paul Saman

Mozilla-plugin linux toolbar can be hidden by adding show_toolbar="no" to the

'embed' HTML node that import VLC mozplug. Default to visible.
Signed-off-by: default avatarJean-Paul Saman <jpsaman@videolan.org>
parent ac9747bb
...@@ -44,6 +44,7 @@ VlcPlugin::VlcPlugin( NPP instance, uint16 mode ) : ...@@ -44,6 +44,7 @@ VlcPlugin::VlcPlugin( NPP instance, uint16 mode ) :
i_npmode(mode), i_npmode(mode),
b_stream(0), b_stream(0),
b_autoplay(1), b_autoplay(1),
b_show_toolbar(1),
#if XP_UNIX #if XP_UNIX
i_control_height(45), i_control_height(45),
#endif #endif
...@@ -166,8 +167,14 @@ NPError VlcPlugin::init(int argc, char* const argn[], char* const argv[]) ...@@ -166,8 +167,14 @@ NPError VlcPlugin::init(int argc, char* const argn[], char* const argv[])
{ {
progid = argv[i]; progid = argv[i];
} }
else if( !strcmp( argn[i], "show_toolbar" ) )
{
b_show_toolbar = boolValue(argv[i]);
}
} }
libvlc_instance = libvlc_new(ppsz_argc, ppsz_argv, NULL); libvlc_instance = libvlc_new(ppsz_argc, ppsz_argv, NULL);
if( ! libvlc_instance ) if( ! libvlc_instance )
{ {
......
...@@ -118,6 +118,7 @@ public: ...@@ -118,6 +118,7 @@ public:
/* plugin properties */ /* plugin properties */
int b_stream; int b_stream;
int b_autoplay; int b_autoplay;
int b_show_toolbar;
char * psz_target; char * psz_target;
#if XP_UNIX #if XP_UNIX
......
...@@ -94,7 +94,8 @@ NPError NPP_GetValue( NPP instance, NPPVariable variable, void *value ) ...@@ -94,7 +94,8 @@ NPError NPP_GetValue( NPP instance, NPPVariable variable, void *value )
return NPERR_NO_ERROR; return NPERR_NO_ERROR;
case NPPVpluginDescriptionString: case NPPVpluginDescriptionString:
snprintf( psz_desc, sizeof(psz_desc), PLUGIN_DESCRIPTION, VLC_Version() ); snprintf( psz_desc, sizeof(psz_desc), PLUGIN_DESCRIPTION,
VLC_Version() );
*((char **)value) = psz_desc; *((char **)value) = psz_desc;
return NPERR_NO_ERROR; return NPERR_NO_ERROR;
...@@ -220,7 +221,8 @@ int16 NPP_HandleEvent( NPP instance, void * event ) ...@@ -220,7 +221,8 @@ int16 NPP_HandleEvent( NPP instance, void * event )
libvlc_playlist_get_media_instance(p_vlc, NULL); libvlc_playlist_get_media_instance(p_vlc, NULL);
if( p_md ) if( p_md )
{ {
hasVout = libvlc_media_instance_has_vout(p_md, NULL); hasVout = libvlc_media_instance_has_vout(p_md,
NULL);
if( hasVout ) if( hasVout )
{ {
libvlc_rectangle_t area; libvlc_rectangle_t area;
...@@ -228,7 +230,8 @@ int16 NPP_HandleEvent( NPP instance, void * event ) ...@@ -228,7 +230,8 @@ int16 NPP_HandleEvent( NPP instance, void * event )
area.top = 0; area.top = 0;
area.right = npwindow.width; area.right = npwindow.width;
area.bottom = npwindow.height; area.bottom = npwindow.height;
libvlc_video_redraw_rectangle(p_md, &area, NULL); libvlc_video_redraw_rectangle(p_md, &area,
NULL);
} }
libvlc_media_instance_release(p_md); libvlc_media_instance_release(p_md);
} }
...@@ -242,7 +245,8 @@ int16 NPP_HandleEvent( NPP instance, void * event ) ...@@ -242,7 +245,8 @@ int16 NPP_HandleEvent( NPP instance, void * event )
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, SetOrigin(((NP_Port *)npwindow.window)->portx,
((NP_Port *)npwindow.window)->porty); ((NP_Port *)npwindow.window)->porty);
...@@ -360,6 +364,9 @@ NPError NPP_Destroy( NPP instance, NPSavedData** save ) ...@@ -360,6 +364,9 @@ NPError NPP_Destroy( NPP instance, NPSavedData** save )
NPError NPP_SetWindow( NPP instance, NPWindow* window ) NPError NPP_SetWindow( NPP instance, NPWindow* window )
{ {
/* height used by bottom toolbar (pixels). 0 if hidden */
unsigned int i_toolbar_height;
if( ! instance ) if( ! instance )
{ {
return NPERR_INVALID_INSTANCE_ERROR; return NPERR_INVALID_INSTANCE_ERROR;
...@@ -367,7 +374,7 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window ) ...@@ -367,7 +374,7 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
/* NPP_SetWindow may be called before NPP_New (Opera) */ /* NPP_SetWindow may be called before NPP_New (Opera) */
VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(instance->pdata); VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(instance->pdata);
if( ! p_plugin ) if( NULL == p_plugin )
{ {
/* we should probably show a splash screen here */ /* we should probably show a splash screen here */
return NPERR_NO_ERROR; return NPERR_NO_ERROR;
...@@ -375,6 +382,16 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window ) ...@@ -375,6 +382,16 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
libvlc_instance_t *p_vlc = p_plugin->getVLC(); libvlc_instance_t *p_vlc = p_plugin->getVLC();
if( p_plugin->b_show_toolbar )
{
i_toolbar_height = p_plugin->i_control_height;
}
else
{
i_toolbar_height = 0;
}
/* /*
* PLUGIN DEVELOPERS: * PLUGIN DEVELOPERS:
* Before setting window to point to the * Before setting window to point to the
...@@ -401,8 +418,9 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window ) ...@@ -401,8 +418,9 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
libvlc_rectangle_t view, clip; libvlc_rectangle_t view, clip;
/* /*
** browser sets port origin to top-left location of plugin relative to GrafPort ** browser sets port origin to top-left location of plugin
** window origin is set relative to document, which of little use for drawing ** relative to GrafPort window origin is set relative to document,
** which of little use for drawing
*/ */
view.top = ((NP_Port*) (window->window))->porty; view.top = ((NP_Port*) (window->window))->porty;
view.left = ((NP_Port*) (window->window))->portx; view.left = ((NP_Port*) (window->window))->portx;
...@@ -483,25 +501,33 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window ) ...@@ -483,25 +501,33 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
Window parent = (Window) window->window; Window parent = (Window) window->window;
if( !curwin.window || (parent != (Window)curwin.window) ) if( !curwin.window || (parent != (Window)curwin.window) )
{ {
Display *p_display = ((NPSetWindowCallbackStruct *)window->ws_info)->display; Display *p_display = ( (NPSetWindowCallbackStruct *)
window->ws_info )->display;
XResizeWindow( p_display, parent, window->width, window->height ); XResizeWindow( p_display, parent, window->width, window->height );
int i_blackColor = BlackPixel(p_display, DefaultScreen(p_display)); int i_blackColor = BlackPixel(p_display, DefaultScreen(p_display));
/* create windows */
Window video = XCreateSimpleWindow( p_display, parent, 0, 0, Window video = XCreateSimpleWindow( p_display, parent, 0, 0,
window->width, window->height - p_plugin->i_control_height, 0, window->width, window->height - i_toolbar_height,
i_blackColor, i_blackColor ); 0, i_blackColor, i_blackColor );
Window controls = XCreateSimpleWindow( p_display, parent, 0, Window controls = (Window) NULL;
window->height - p_plugin->i_control_height-1, window->width, if( p_plugin->b_show_toolbar )
p_plugin->i_control_height-1, 0, i_blackColor, i_blackColor ); {
controls = XCreateSimpleWindow( p_display, parent,
0, window->height - i_toolbar_height-1,
window->width, i_toolbar_height-1,
0, i_blackColor, i_blackColor );
}
XMapWindow( p_display, parent ); XMapWindow( p_display, parent );
XMapWindow( p_display, video ); XMapWindow( p_display, video );
XMapWindow( p_display, controls ); if( controls ) { XMapWindow( p_display, controls ); }
XFlush(p_display); XFlush(p_display);
/* bind events */
Widget w = XtWindowToWidget( p_display, parent ); Widget w = XtWindowToWidget( p_display, parent );
XtAddEventHandler( w, ExposureMask, FALSE, XtAddEventHandler( w, ExposureMask, FALSE,
...@@ -529,7 +555,7 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window ) ...@@ -529,7 +555,7 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
/* remember window */ /* remember window */
p_plugin->setWindow( *window ); p_plugin->setWindow( *window );
p_plugin->setVideoWindow( video ); p_plugin->setVideoWindow( video );
p_plugin->setControlWindow( controls ); if( controls ) { p_plugin->setControlWindow( controls ); }
Redraw( w, (XtPointer)p_plugin, NULL ); Redraw( w, (XtPointer)p_plugin, NULL );
} }
...@@ -628,7 +654,8 @@ void NPP_StreamAsFile( NPP instance, NPStream *stream, const char* fname ) ...@@ -628,7 +654,8 @@ void NPP_StreamAsFile( NPP instance, NPStream *stream, const char* fname )
return; return;
} }
if( libvlc_playlist_add( p_plugin->getVLC(), fname, stream->url, NULL ) != -1 ) if( libvlc_playlist_add( p_plugin->getVLC(), fname, stream->url, NULL )
!= -1 )
{ {
if( p_plugin->b_autoplay ) if( p_plugin->b_autoplay )
{ {
...@@ -750,7 +777,8 @@ static LRESULT CALLBACK Manage( HWND p_hwnd, UINT i_msg, WPARAM wpar, LPARAM lpa ...@@ -750,7 +777,8 @@ static LRESULT CALLBACK Manage( HWND p_hwnd, UINT i_msg, WPARAM wpar, LPARAM lpa
} }
default: default:
/* delegate to default handler */ /* delegate to default handler */
return CallWindowProc(p_plugin->getWindowProc(), p_hwnd, i_msg, wpar, lpar ); return CallWindowProc( p_plugin->getWindowProc(), p_hwnd,
i_msg, wpar, lpar );
} }
} }
#endif /* XP_WIN */ #endif /* XP_WIN */
...@@ -765,29 +793,41 @@ static void Redraw( Widget w, XtPointer closure, XEvent *event ) ...@@ -765,29 +793,41 @@ static void Redraw( Widget w, XtPointer closure, XEvent *event )
const NPWindow& window = p_plugin->getWindow(); const NPWindow& window = p_plugin->getWindow();
GC gc; GC gc;
XGCValues gcv; XGCValues gcv;
/* height used to show the bottom toolbar in non-fullscreen mode */
unsigned int i_toolbar_height;
if( p_plugin->b_show_toolbar )
{
p_plugin->showToolbar();
i_toolbar_height = p_plugin->i_control_height;
}
else
{
i_toolbar_height = 0;
}
Window video = p_plugin->getVideoWindow(); Window video = p_plugin->getVideoWindow();
Display *p_display = ((NPSetWindowCallbackStruct *)window.ws_info)->display; Display *p_display = ((NPSetWindowCallbackStruct *)window.ws_info)->display;
p_plugin->showToolbar();
gcv.foreground = BlackPixel( p_display, 0 ); gcv.foreground = BlackPixel( p_display, 0 );
gc = XCreateGC( p_display, video, GCForeground, &gcv ); gc = XCreateGC( p_display, video, GCForeground, &gcv );
XFillRectangle( p_display, video, gc, XFillRectangle( p_display, video, gc,
0, 0, window.width, window.height - p_plugin->i_control_height ); 0, 0, window.width, window.height - i_toolbar_height);
gcv.foreground = WhitePixel( p_display, 0 ); gcv.foreground = WhitePixel( p_display, 0 );
XChangeGC( p_display, gc, GCForeground, &gcv ); XChangeGC( p_display, gc, GCForeground, &gcv );
XDrawString( p_display, video, gc, XDrawString( p_display, video, gc,
window.width / 2 - 40, (window.height - p_plugin->i_control_height) / 2, window.width / 2 - 40, (window.height - i_toolbar_height) / 2,
WINDOW_TEXT, strlen(WINDOW_TEXT) ); WINDOW_TEXT, strlen(WINDOW_TEXT) );
XFreeGC( p_display, gc ); XFreeGC( p_display, gc );
p_plugin->redrawToolbar(); if( p_plugin->b_show_toolbar )
{
p_plugin->hideToolbar(); p_plugin->redrawToolbar();
p_plugin->hideToolbar();
}
} }
static void ControlHandler( Widget w, XtPointer closure, XEvent *event ) static void ControlHandler( Widget w, XtPointer closure, XEvent *event )
...@@ -800,7 +840,7 @@ static void ControlHandler( Widget w, XtPointer closure, XEvent *event ) ...@@ -800,7 +840,7 @@ static void ControlHandler( Widget w, XtPointer closure, XEvent *event )
int i_xPos = event->xbutton.x; int i_xPos = event->xbutton.x;
int i_yPos = event->xbutton.y; int i_yPos = event->xbutton.y;
if( p_plugin ) if( p_plugin && p_plugin->b_show_toolbar )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init( &ex ); libvlc_exception_init( &ex );
...@@ -875,7 +915,7 @@ static void ControlHandler( Widget w, XtPointer closure, XEvent *event ) ...@@ -875,7 +915,7 @@ static void ControlHandler( Widget w, XtPointer closure, XEvent *event )
libvlc_audio_toggle_mute( p_plugin->getVLC(), &ex ); libvlc_audio_toggle_mute( p_plugin->getVLC(), &ex );
libvlc_exception_clear( &ex ); libvlc_exception_clear( &ex );
} }
if( p_md ) libvlc_media_instance_release( p_md ); if( p_md ) libvlc_media_instance_release( p_md );
} }
Redraw( w, closure, event ); Redraw( w, closure, event );
...@@ -892,6 +932,17 @@ static void Resize ( Widget w, XtPointer closure, XEvent *event ) ...@@ -892,6 +932,17 @@ static void Resize ( Widget w, XtPointer closure, XEvent *event )
Window root_return, parent_return, * children_return; Window root_return, parent_return, * children_return;
Window base_window; Window base_window;
unsigned int i_nchildren; unsigned int i_nchildren;
/* height used for the bottom control bar, 0 if hidden */
unsigned int i_toolbar_height;
if( p_plugin->b_show_toolbar )
{
i_toolbar_height = p_plugin->i_control_height;
}
else
{
i_toolbar_height = 0;
}
#ifdef X11_RESIZE_DEBUG #ifdef X11_RESIZE_DEBUG
XWindowAttributes attr; XWindowAttributes attr;
...@@ -905,13 +956,14 @@ static void Resize ( Widget w, XtPointer closure, XEvent *event ) ...@@ -905,13 +956,14 @@ static void Resize ( Widget w, XtPointer closure, XEvent *event )
} }
#endif /* X11_RESIZE_DEBUG */ #endif /* X11_RESIZE_DEBUG */
if( ! p_plugin->setSize(window.width, (window.height - p_plugin->i_control_height)) ) if( ! p_plugin->setSize(window.width, (window.height - i_toolbar_height)) )
{ {
/* size already set */ /* size already set */
return; return;
} }
i_ret = XResizeWindow( p_display, drawable, window.width, (window.height - p_plugin->i_control_height) ); i_ret = XResizeWindow( p_display, drawable,
window.width, (window.height - i_toolbar_height) );
#ifdef X11_RESIZE_DEBUG #ifdef X11_RESIZE_DEBUG
fprintf( stderr, fprintf( stderr,
...@@ -943,7 +995,7 @@ static void Resize ( Widget w, XtPointer closure, XEvent *event ) ...@@ -943,7 +995,7 @@ static void Resize ( Widget w, XtPointer closure, XEvent *event )
#endif /* X11_RESIZE_DEBUG */ #endif /* X11_RESIZE_DEBUG */
i_ret = XResizeWindow( p_display, base_window, i_ret = XResizeWindow( p_display, base_window,
window.width, ( window.height - p_plugin->i_control_height ) ); window.width, ( window.height - i_toolbar_height ) );
#ifdef X11_RESIZE_DEBUG #ifdef X11_RESIZE_DEBUG
fprintf( stderr, fprintf( stderr,
......
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