]> git.sesse.net Git - vlc/blobdiff - projects/mozilla/vlcshell.cpp
input: Export input_GetState().
[vlc] / projects / mozilla / vlcshell.cpp
index 3268b09bc5f656dc2456c973d13c9434129a1b82..be2ea7bbcb03bf59a594e9fbc0e5730be1c1050a 100644 (file)
@@ -1,10 +1,11 @@
 /*****************************************************************************
  * vlcshell.cpp: a VLC plugin for Mozilla
  *****************************************************************************
- * Copyright (C) 2002-2005 the VideoLAN team
+ * Copyright (C) 2002-2008 the VideoLAN team
  * $Id$
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
+ *          Jean-Paul Saman <jpsaman@videolan.org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
 #   include <mozilla-config.h>
 #endif
 
-#ifdef XP_UNIX
-#ifndef __APPLE__
-#include <X11/xpm.h>
-#endif
-#endif
-
 /* This is from mozilla java, do we really need it? */
 #if 0
 #include <jri.h>
@@ -52,7 +47,6 @@
 #undef X11_RESIZE_DEBUG
 
 #define WINDOW_TEXT "Video is loading..."
-#define CONTROL_HEIGHT 45
 
 /*****************************************************************************
  * Unix-only declarations
@@ -101,7 +95,8 @@ NPError NPP_GetValue( NPP instance, NPPVariable variable, void *value )
             return NPERR_NO_ERROR;
 
         case NPPVpluginDescriptionString:
-            snprintf( psz_desc, sizeof(psz_desc), PLUGIN_DESCRIPTION, VLC_Version() );
+            snprintf( psz_desc, sizeof(psz_desc), PLUGIN_DESCRIPTION,
+                      libvlc_get_version() );
             *((char **)value) = psz_desc;
             return NPERR_NO_ERROR;
 
@@ -192,12 +187,12 @@ int16 NPP_HandleEvent( NPP instance, void * event )
                 {
                     if( libvlc_playlist_isplaying(p_vlc, NULL) )
                     {
-                        libvlc_media_instance_t *p_md =
-                            libvlc_playlist_get_media_instance(p_vlc, NULL);
+                        libvlc_media_player_t *p_md =
+                            libvlc_playlist_get_media_player(p_vlc, NULL);
                         if( p_md )
                         {
                             libvlc_toggle_fullscreen(p_md, NULL);
-                            libvlc_media_instance_release(p_md);
+                            libvlc_media_player_release(p_md);
                         }
                     }
                 }
@@ -223,11 +218,12 @@ int16 NPP_HandleEvent( NPP instance, void * event )
                 {
                     if( libvlc_playlist_isplaying(p_vlc, NULL) )
                     {
-                        libvlc_media_instance_t *p_md =
-                            libvlc_playlist_get_media_instance(p_vlc, NULL);
+                        libvlc_media_player_t *p_md =
+                            libvlc_playlist_get_media_player(p_vlc, NULL);
                         if( p_md )
                         {
-                            hasVout = libvlc_media_instance_has_vout(p_md, NULL);
+                            hasVout = libvlc_media_player_has_vout(p_md,
+                                                                     NULL);
                             if( hasVout )
                             {
                                 libvlc_rectangle_t area;
@@ -235,9 +231,10 @@ int16 NPP_HandleEvent( NPP instance, void * event )
                                 area.top = 0;
                                 area.right = npwindow.width;
                                 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_player_release(p_md);
                         }
                     }
                 }
@@ -249,7 +246,8 @@ int16 NPP_HandleEvent( NPP instance, void * event )
                     ForeColor(blackColor);
                     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);
 
@@ -367,6 +365,11 @@ NPError NPP_Destroy( NPP instance, NPSavedData** save )
 
 NPError NPP_SetWindow( NPP instance, NPWindow* window )
 {
+#ifdef XP_UNIX && !defined(__APPLE__)
+    Window control;
+    unsigned int i_control_height = 0, i_control_width = 0;
+#endif
+
     if( ! instance )
     {
         return NPERR_INVALID_INSTANCE_ERROR;
@@ -374,12 +377,14 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
 
     /* NPP_SetWindow may be called before NPP_New (Opera) */
     VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(instance->pdata);
-    if( ! p_plugin )
+    if( NULL == p_plugin )
     {
         /* we should probably show a splash screen here */
         return NPERR_NO_ERROR;
     }
-
+#ifdef XP_UNIX && !defined(__APPLE__)
+    control = p_plugin->getControlWindow();
+#endif
     libvlc_instance_t *p_vlc = p_plugin->getVLC();
 
     /*
@@ -408,8 +413,9 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
         libvlc_rectangle_t view, clip;
 
         /*
-        ** browser sets port origin to top-left location of plugin relative to GrafPort
-        ** window origin is set relative to document, which of little use for drawing
+        ** browser sets port origin to top-left location of plugin
+        ** relative to GrafPort window origin is set relative to document,
+        ** which of little use for drawing
         */
         view.top     = ((NP_Port*) (window->window))->porty;
         view.left    = ((NP_Port*) (window->window))->portx;
@@ -485,30 +491,41 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
 #endif /* XP_WIN */
 
 #ifdef XP_UNIX
+    /* default to hidden toolbar, shown at the end of this method if asked *
+     * developers note : getToolbarSize need to wait the end of this method
+     */
+    i_control_height = 0;
+    i_control_width = window->width;
+
     if( window && window->window )
     {
-        Window  parent   = (Window) window->window;
+        Window  parent  = (Window) window->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 );
 
             int i_blackColor = BlackPixel(p_display, DefaultScreen(p_display));
 
+            /* create windows */
             Window video = XCreateSimpleWindow( p_display, parent, 0, 0,
-                           window->width, window->height - CONTROL_HEIGHT, 0,
-                           i_blackColor, i_blackColor );
-            Window controls = XCreateSimpleWindow( p_display, parent, 0,
-                            window->height - CONTROL_HEIGHT-1, window->width,
-                            CONTROL_HEIGHT-1, 0, i_blackColor, i_blackColor );
+                           window->width, window->height - i_control_height,
+                           0, i_blackColor, i_blackColor );
+            Window controls = (Window) NULL;
+            controls = XCreateSimpleWindow( p_display, parent,
+                            0, window->height - i_control_height-1,
+                            window->width, i_control_height-1,
+                            0, i_blackColor, i_blackColor );
 
             XMapWindow( p_display, parent );
             XMapWindow( p_display, video );
-            XMapWindow( p_display, controls );
+            if( controls ) { XMapWindow( p_display, controls ); }
 
             XFlush(p_display);
 
+            /* bind events */
             Widget w = XtWindowToWidget( p_display, parent );
 
             XtAddEventHandler( w, ExposureMask, FALSE,
@@ -520,14 +537,14 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
 
             /* callback */
 /*
-            libvlc_media_instance_t *p_md;
+            libvlc_media_player_t *p_md;
 
             libvlc_exception_t ex;
             libvlc_exception_init(& ex );
-            p_md = libvlc_playlist_get_media_instance( p_plugin->getVLC(), &ex );
+            p_md = libvlc_playlist_get_media_player( p_plugin->getVLC(), &ex );
             libvlc_exception_init( &ex );
-            libvlc_event_attach( libvlc_media_instance_event_manager( p_md, &ex ),
-                                 libvlc_MediaInstancePositionChanged, Redraw, NULL, &ex );
+            libvlc_event_attach( libvlc_media_player_event_manager( p_md, &ex ),
+                                 libvlc_MediaPlayerPositionChanged, Redraw, NULL, &ex );
 */
 
             /* set/change parent window */
@@ -536,9 +553,15 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
             /* remember window */
             p_plugin->setWindow( *window );
             p_plugin->setVideoWindow( video );
-            p_plugin->setControlWindow( controls );
+            if( controls ) { p_plugin->setControlWindow( controls ); }
 
             Redraw( w, (XtPointer)p_plugin, NULL );
+
+            /* now display toolbar if asked through parameters */
+            if( p_plugin->b_toolbar )
+            {
+                p_plugin->showToolbar();
+            }
         }
     }
     else if ( curwin.window )
@@ -561,7 +584,7 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
                     libvlc_playlist_play(p_vlc, 0, 0, NULL, NULL);
                 }
             }
-            p_plugin->b_stream = VLC_TRUE;
+            p_plugin->b_stream = true;
         }
     }
     return NPERR_NO_ERROR;
@@ -635,7 +658,8 @@ void NPP_StreamAsFile( NPP instance, NPStream *stream, const char* fname )
         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 )
         {
@@ -757,7 +781,8 @@ static LRESULT CALLBACK Manage( HWND p_hwnd, UINT i_msg, WPARAM wpar, LPARAM lpa
         }
         default:
             /* 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 */
@@ -769,182 +794,35 @@ static LRESULT CALLBACK Manage( HWND p_hwnd, UINT i_msg, WPARAM wpar, LPARAM lpa
 static void Redraw( Widget w, XtPointer closure, XEvent *event )
 {
     VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(closure);
+    Window control = p_plugin->getControlWindow();
     const NPWindow& window = p_plugin->getWindow();
     GC gc;
     XGCValues gcv;
+    unsigned int i_control_height, i_control_width;
 
-    /* Toolbar */
-    XImage *p_playIcon = NULL;
-    XImage *p_pauseIcon = NULL;
-    XImage *p_stopIcon = NULL;
-    XImage *p_timeline = NULL;
-    XImage *p_timeKnob = NULL;
-    XImage *p_fscreen = NULL;
-    XImage *p_muteIcon = NULL;
-    XImage *p_unmuteIcon = NULL;
-
-    libvlc_media_instance_t *p_md = NULL;
-    float f_position = 0;
-    int i_playing = 0;
-    bool b_mute = false;
+    if( p_plugin->b_toolbar )
+        p_plugin->getToolbarSize( &i_control_width, &i_control_height );
+    else
+        i_control_height = i_control_width = 0;
 
     Window video = p_plugin->getVideoWindow();
-    Window control = p_plugin->getControlWindow();
     Display *p_display = ((NPSetWindowCallbackStruct *)window.ws_info)->display;
 
     gcv.foreground = BlackPixel( p_display, 0 );
     gc = XCreateGC( p_display, video, GCForeground, &gcv );
 
     XFillRectangle( p_display, video, gc,
-                    0, 0, window.width, window.height - CONTROL_HEIGHT );
+                    0, 0, window.width, window.height - i_control_height);
 
     gcv.foreground = WhitePixel( p_display, 0 );
     XChangeGC( p_display, gc, GCForeground, &gcv );
 
     XDrawString( p_display, video, gc,
-                 window.width / 2 - 40, (window.height - CONTROL_HEIGHT) / 2,
+                 window.width / 2 - 40, (window.height - i_control_height) / 2,
                  WINDOW_TEXT, strlen(WINDOW_TEXT) );
-
-    /* RedrawToolbar */
-    gcv.foreground = BlackPixel( p_display, 0 );
-    gc = XCreateGC( p_display, control, GCForeground, &gcv );
-
-    XFillRectangle( p_display, control, gc,
-                    0, 0, window.width, CONTROL_HEIGHT );
-
-
-    gcv.foreground = WhitePixel( p_display, 0 );
-    XChangeGC( p_display, gc, GCForeground, &gcv );
-
-    /* get media instance */
-    libvlc_exception_t ex;
-    libvlc_exception_init( &ex );
-    p_md = libvlc_playlist_get_media_instance( p_plugin->getVLC(), &ex );
-    libvlc_exception_clear( &ex );
-
-    /* get isplaying */
-    libvlc_exception_init( &ex );
-    i_playing = libvlc_playlist_isplaying( p_plugin->getVLC(), &ex );
-    libvlc_exception_clear( &ex );
-
-    /* get mute info */
-    libvlc_exception_init(&ex);
-    b_mute = libvlc_audio_get_mute( p_plugin->getVLC(), &ex );
-    libvlc_exception_clear( &ex );
-
-    /* get movie position in % */
-    if( i_playing == 1 )
-    {
-        libvlc_exception_init( &ex );
-        f_position = libvlc_media_instance_get_position(p_md, &ex)*100;
-        libvlc_exception_clear( &ex );
-    }
-    libvlc_media_instance_release(p_md);
-
-    /* load icons */
-    XpmReadFileToImage( p_display, DATA_PATH "/mozilla/play.xpm",
-                        &p_playIcon, NULL, NULL);
-    XpmReadFileToImage( p_display, DATA_PATH "/mozilla/pause.xpm",
-                        &p_pauseIcon, NULL, NULL);
-    XpmReadFileToImage( p_display, DATA_PATH "/mozilla/stop.xpm",
-                        &p_stopIcon, NULL, NULL );
-    XpmReadFileToImage( p_display, DATA_PATH "/mozilla/time_line.xpm",
-                        &p_timeline, NULL, NULL);
-    XpmReadFileToImage( p_display, DATA_PATH "/mozilla/time_icon.xpm",
-                        &p_timeKnob, NULL, NULL);
-    XpmReadFileToImage( p_display, DATA_PATH "/mozilla/fullscreen.xpm",
-                        &p_fscreen, NULL, NULL);
-    XpmReadFileToImage( p_display, DATA_PATH "/mozilla/volume_max.xpm",
-                        &p_muteIcon, NULL, NULL);
-    XpmReadFileToImage( p_display, DATA_PATH "/mozilla/volume_mute.xpm",
-                        &p_unmuteIcon, NULL, NULL);
-
-#if 1 /* DEBUG */
-    if( !p_playIcon )
-    {
-        fprintf(stderr, "Error: playImage not found\n");
-    }
-    if( !p_pauseIcon )
-    {
-        fprintf(stderr, "Error: pauseImage not found\n");
-    }
-    if( !p_stopIcon )
-    {
-        fprintf(stderr, "Error: stopImage not found\n");
-    }
-    if( !p_timeline )
-    {
-        fprintf(stderr, "Error: TimeLineImage not found\n");
-    }
-    if( !p_timeKnob )
-    {
-        fprintf(stderr, "Error: TimeIcon not found\n");
-    }
-    if( !p_fscreen )
-    {
-        fprintf(stderr, "Error: FullscreenImage not found\n");
-    }
-    if( !p_muteIcon )
-    {
-        fprintf(stderr, "Error: MuteImage not found\n");
-    }
-    if( !p_unmuteIcon )
-    {
-        fprintf(stderr, "Error: UnMuteImage not found\n");
-    }
-#endif
-
-    /* position icons */
-    if( p_pauseIcon && (i_playing == 1) )
-    {
-        XPutImage( p_display, control, gc, p_pauseIcon, 0, 0, 4, 14,
-                   p_pauseIcon->width, p_pauseIcon->height );
-    }
-    else if( p_playIcon )
-    {
-        XPutImage( p_display, control, gc, p_playIcon, 0, 0, 4, 14,
-                   p_playIcon->width, p_playIcon->height );
-    }
-
-    if( p_stopIcon )
-        XPutImage( p_display, control, gc, p_stopIcon, 0, 0, 39, 14,
-                   p_stopIcon->width, p_stopIcon->height );
-    if( p_fscreen )
-        XPutImage( p_display, control, gc, p_fscreen, 0, 0, 67, 21,
-                   p_fscreen->width, p_fscreen->height );
-
-    if( p_unmuteIcon && b_mute )
-    {
-        XPutImage( p_display, control, gc, p_unmuteIcon, 0, 0, 94, 30,
-                 p_unmuteIcon->width, p_unmuteIcon->height );
-    }
-    else if( p_muteIcon )
-    {
-        XPutImage( p_display, control, gc, p_muteIcon, 0, 0, 94, 30,
-                   p_muteIcon->width, p_muteIcon->height );
-    }
-
-    if( p_timeline )
-        XPutImage( p_display, control, gc, p_timeline, 0, 0, 4, 4,
-                   (window.width-8), p_timeline->height );
-    if( p_timeKnob && (f_position > 0) )
-    {
-        f_position = (((float)window.width-8)/100)*f_position;
-        XPutImage( p_display, control, gc, p_timeKnob, 0, 0, (4+f_position), 2,
-                   p_timeKnob->width, p_timeKnob->height );
-    }
-
-    /* Cleanup */
-    if( p_playIcon )   XDestroyImage( p_playIcon );
-    if( p_pauseIcon )  XDestroyImage( p_pauseIcon );
-    if( p_stopIcon )   XDestroyImage( p_stopIcon );
-    if( p_timeline )   XDestroyImage( p_timeline );
-    if( p_timeKnob )   XDestroyImage( p_timeKnob );
-    if( p_fscreen )    XDestroyImage( p_fscreen );
-    if( p_muteIcon )   XDestroyImage( p_muteIcon );
-    if( p_unmuteIcon ) XDestroyImage( p_unmuteIcon );
-
     XFreeGC( p_display, gc );
+
+    p_plugin->redrawToolbar();
 }
 
 static void ControlHandler( Widget w, XtPointer closure, XEvent *event )
@@ -957,75 +835,117 @@ static void ControlHandler( Widget w, XtPointer closure, XEvent *event )
     int i_xPos = event->xbutton.x;
     int i_yPos = event->xbutton.y;
 
-    libvlc_exception_t ex;
-    libvlc_exception_init( &ex );
-    libvlc_media_instance_t *p_md =
-            libvlc_playlist_get_media_instance(p_plugin->getVLC(), &ex);
-    libvlc_exception_clear( &ex );
-
-    /* jump in the movie */
-    if( i_yPos <= (i_height-30) )
+    if( p_plugin && p_plugin->b_toolbar )
     {
-        vlc_int64_t f_length;
-        libvlc_exception_init( &ex );
-        f_length = libvlc_media_instance_get_length( p_md, &ex ) / 100;
-        libvlc_exception_clear( &ex );
-
-        f_length = (float)f_length *
-                   ( ((float)i_xPos-4 ) / ( ((float)i_width-8)/100) );
+        int i_playing;
+        libvlc_exception_t ex;
 
         libvlc_exception_init( &ex );
-        libvlc_media_instance_set_time( p_md, f_length, &ex );
+        libvlc_media_player_t *p_md =
+                libvlc_playlist_get_media_player(p_plugin->getVLC(), &ex);
+        if( libvlc_exception_raised(&ex) )
+            fprintf( stderr, "%s\n", libvlc_exception_get_message(&ex));
         libvlc_exception_clear( &ex );
-    }
 
-    /* play/pause toggle */
-    if( (i_yPos > (i_height-30)) && (i_xPos > 4) && (i_xPos <= 39) )
-    {
-        int i_playing;
         libvlc_exception_init( &ex );
         i_playing = libvlc_playlist_isplaying( p_plugin->getVLC(), &ex );
+        if( libvlc_exception_raised(&ex) )
+            fprintf( stderr, "%s\n", libvlc_exception_get_message(&ex));
         libvlc_exception_clear( &ex );
 
-        libvlc_exception_init( &ex );
-        if( i_playing == 1 )
-            libvlc_playlist_pause( p_plugin->getVLC(), &ex );
-        else
-            libvlc_playlist_play( p_plugin->getVLC(), -1, 0, NULL, &ex );
-        libvlc_exception_clear( &ex );
-    }
+        vlc_toolbar_clicked_t clicked;
+        clicked = p_plugin->getToolbarButtonClicked( i_xPos, i_yPos );
+        switch( clicked )
+        {
+            case clicked_Play:
+            case clicked_Pause:
+            {
+                libvlc_exception_init( &ex );
+                if( i_playing == 1 )
+                    libvlc_playlist_pause( p_plugin->getVLC(), &ex );
+                else
+                    libvlc_playlist_play( p_plugin->getVLC(), -1, 0, NULL, &ex );
+
+                if( libvlc_exception_raised(&ex) )
+                    fprintf( stderr, "%s\n", libvlc_exception_get_message(&ex));
+                libvlc_exception_clear( &ex );
+            }
+            break;
 
-    /* stop */
-    if( (i_yPos > (i_height-30)) && (i_xPos > 39) && (i_xPos < 67) )
-    {
-        libvlc_exception_init( &ex );
-        libvlc_playlist_stop( p_plugin->getVLC(), &ex );
-        libvlc_exception_clear( &ex );
-    }
+            case clicked_Stop:
+            {
+                libvlc_exception_init( &ex );
+                libvlc_playlist_stop( p_plugin->getVLC(), &ex );
+                if( libvlc_exception_raised(&ex) )
+                    fprintf( stderr, "%s\n", libvlc_exception_get_message(&ex));
+                libvlc_exception_clear( &ex );
+            }
+            break;
 
-    /* fullscreen */
-    if( (i_yPos > (i_height-30)) && (i_xPos >= 67) && (i_xPos < 94) )
-    {
-        libvlc_exception_init( &ex );
-        libvlc_set_fullscreen( p_md, 1, &ex );
-        libvlc_exception_clear( &ex );
-    }
+            case clicked_Fullscreen:
+            {
+                if( (i_playing == 1) && p_md )
+                {
+                    libvlc_exception_init( &ex );
+                    libvlc_set_fullscreen( p_md, 1, &ex );
+                    if( libvlc_exception_raised(&ex) )
+                        fprintf( stderr, "%s\n", libvlc_exception_get_message(&ex));
+                    libvlc_exception_clear( &ex );
+                }
+            }
+            break;
 
-    /* mute toggle */
-    if( (i_yPos > (i_height-30)) && (i_xPos >= 94) && (i_xPos < 109))
-    {
-        libvlc_exception_init( &ex );
-        libvlc_audio_toggle_mute( p_plugin->getVLC(), &ex );
-        libvlc_exception_clear( &ex );
-    }
-    libvlc_media_instance_release( p_md );
+            case clicked_Mute:
+            case clicked_Unmute:
+            {
+                libvlc_exception_init( &ex );
+                libvlc_audio_toggle_mute( p_plugin->getVLC(), &ex );
+                if( libvlc_exception_raised(&ex) )
+                    fprintf( stderr, "%s\n", libvlc_exception_get_message(&ex));
+                libvlc_exception_clear( &ex );
+            }
+            break;
+
+            case clicked_timeline:
+            {
+                /* if a movie is loaded */
+                if( p_md )
+                {
+                    int64_t f_length;
+                    libvlc_exception_init( &ex );
+                    f_length = libvlc_media_player_get_length( p_md, &ex ) / 100;
+                    libvlc_exception_clear( &ex );
+
+                    f_length = (float)f_length *
+                            ( ((float)i_xPos-4.0 ) / ( ((float)i_width-8.0)/100) );
+
+                    libvlc_exception_init( &ex );
+                    libvlc_media_player_set_time( p_md, f_length, &ex );
+                    if( libvlc_exception_raised(&ex) )
+                        fprintf( stderr, "%s\n", libvlc_exception_get_message(&ex));
+                    libvlc_exception_clear( &ex );
+                }
+            }
+            break;
 
+            case clicked_Time:
+            {
+                /* Not implemented yet*/
+            }
+            break;
+
+            default: /* button_Unknown */
+            break;
+        }
+        if( p_md ) libvlc_media_player_release( p_md );
+    }
     Redraw( w, closure, event );
 }
 
 static void Resize ( Widget w, XtPointer closure, XEvent *event )
 {
     VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(closure);
+    Window control = p_plugin->getControlWindow();
     const NPWindow& window = p_plugin->getWindow();
     Window  drawable   = p_plugin->getVideoWindow();
     Display *p_display = ((NPSetWindowCallbackStruct *)window.ws_info)->display;
@@ -1034,6 +954,16 @@ static void Resize ( Widget w, XtPointer closure, XEvent *event )
     Window root_return, parent_return, * children_return;
     Window base_window;
     unsigned int i_nchildren;
+    unsigned int i_control_height, i_control_width;
+
+    if( p_plugin->b_toolbar )
+    {
+        p_plugin->getToolbarSize( &i_control_width, &i_control_height );
+    }
+    else
+    {
+        i_control_height = i_control_width = 0;
+    }
 
 #ifdef X11_RESIZE_DEBUG
     XWindowAttributes attr;
@@ -1047,14 +977,14 @@ static void Resize ( Widget w, XtPointer closure, XEvent *event )
     }
 #endif /* X11_RESIZE_DEBUG */
 
-    if( ! p_plugin->setSize(window.width, (window.height - CONTROL_HEIGHT)) )
+    if( ! p_plugin->setSize(window.width, (window.height - i_control_height)) )
     {
         /* size already set */
         return;
     }
 
-
-    i_ret = XResizeWindow( p_display, drawable, window.width, (window.height - CONTROL_HEIGHT) );
+    i_ret = XResizeWindow( p_display, drawable,
+                           window.width, (window.height - i_control_height) );
 
 #ifdef X11_RESIZE_DEBUG
     fprintf( stderr,
@@ -1086,7 +1016,7 @@ static void Resize ( Widget w, XtPointer closure, XEvent *event )
 #endif /* X11_RESIZE_DEBUG */
 
         i_ret = XResizeWindow( p_display, base_window,
-                window.width, ( window.height - CONTROL_HEIGHT ) );
+                window.width, ( window.height - i_control_height ) );
 
 #ifdef X11_RESIZE_DEBUG
         fprintf( stderr,
@@ -1102,4 +1032,3 @@ static void Resize ( Widget w, XtPointer closure, XEvent *event )
 }
 
 #endif /* XP_UNIX */
-