+ /* 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 );
+}
+
+static void ControlHandler( Widget w, XtPointer closure, XEvent *event )
+{
+ VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(closure);
+ const NPWindow& window = p_plugin->getWindow();
+
+ int i_height = window.height;
+ int i_width = window.width;
+ 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) )
+ {
+ 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) );
+
+ libvlc_exception_init( &ex );
+ libvlc_media_instance_set_time( p_md, f_length, &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 );
+ 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 );
+ }
+
+ /* 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 );
+ }
+
+ /* 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 );
+ }
+
+ /* 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 );
+
+ Redraw( w, closure, event );
+}
+
+static void Resize ( Widget w, XtPointer closure, XEvent *event )
+{
+ VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(closure);
+ const NPWindow& window = p_plugin->getWindow();
+ Window drawable = p_plugin->getVideoWindow();
+ Display *p_display = ((NPSetWindowCallbackStruct *)window.ws_info)->display;
+
+ int i_ret;
+ Window root_return, parent_return, * children_return;
+ Window base_window;
+ unsigned int i_nchildren;
+
+#ifdef X11_RESIZE_DEBUG
+ XWindowAttributes attr;
+
+ if( event && event->type == ConfigureNotify )
+ {
+ fprintf( stderr, "vlcshell::Resize() ConfigureNotify %d x %d, "
+ "send_event ? %s\n", event->xconfigure.width,
+ event->xconfigure.height,
+ event->xconfigure.send_event ? "TRUE" : "FALSE" );
+ }
+#endif /* X11_RESIZE_DEBUG */
+
+ if( ! p_plugin->setSize(window.width, (window.height - CONTROL_HEIGHT)) )
+ {
+ /* size already set */
+ return;
+ }
+
+
+ i_ret = XResizeWindow( p_display, drawable, window.width, (window.height - CONTROL_HEIGHT) );
+
+#ifdef X11_RESIZE_DEBUG
+ fprintf( stderr,
+ "vlcshell::Resize() XResizeWindow(owner) returned %d\n", i_ret );
+
+ XGetWindowAttributes ( p_display, drawable, &attr );
+
+ /* X is asynchronous, so the current size reported here is not
+ necessarily the requested size as the Resize request may not
+ yet have been handled by the plugin host */
+ fprintf( stderr, "vlcshell::Resize() current (owner) size %d x %d\n",
+ attr.width, attr.height );
+#endif /* X11_RESIZE_DEBUG */
+
+ XQueryTree( p_display, drawable,
+ &root_return, &parent_return, &children_return,
+ &i_nchildren );
+
+ if( i_nchildren > 0 )
+ {
+ /* XXX: Make assumptions related to the window parenting structure in
+ vlc/modules/video_output/x11/xcommon.c */
+ base_window = children_return[i_nchildren - 1];
+
+#ifdef X11_RESIZE_DEBUG
+ fprintf( stderr, "vlcshell::Resize() got %d children\n", i_nchildren );
+ fprintf( stderr, "vlcshell::Resize() got base_window %p\n",
+ base_window );
+#endif /* X11_RESIZE_DEBUG */
+
+ i_ret = XResizeWindow( p_display, base_window,
+ window.width, ( window.height - CONTROL_HEIGHT ) );
+
+#ifdef X11_RESIZE_DEBUG
+ fprintf( stderr,
+ "vlcshell::Resize() XResizeWindow(base) returned %d\n",
+ i_ret );
+
+ XGetWindowAttributes( p_display, base_window, &attr );
+
+ fprintf( stderr, "vlcshell::Resize() new size %d x %d\n",
+ attr.width, attr.height );
+#endif /* X11_RESIZE_DEBUG */
+ }
+}
+
+#endif /* XP_UNIX */
+