+
+vlc_toolbar_clicked_t VlcPlugin::getToolbarButtonClicked( int i_xpos, int i_ypos )
+{
+ unsigned int i_dest = BTN_SPACE;
+ int is_playing = 0;
+ bool b_mute = false;
+ libvlc_exception_t ex;
+
+#ifndef NDEBUG
+ fprintf( stderr, "ToolbarButtonClicked:: "
+ "trying to match (%d,%d) (%d,%d)\n",
+ i_xpos, i_ypos, i_tb_height, i_tb_width );
+#endif
+ if( i_ypos >= i_tb_width )
+ return clicked_Unknown;
+
+ /* Note: the order of testing is dependend on the original
+ * drawing positions of the icon buttons. Buttons are tested
+ * left to right.
+ */
+
+ /* get isplaying */
+ libvlc_exception_init( &ex );
+ is_playing = playlist_isplaying( &ex );
+ libvlc_exception_clear( &ex );
+
+ /* get mute info */
+ b_mute = libvlc_audio_get_mute( getVLC(), &ex );
+ libvlc_exception_clear( &ex );
+
+ /* is Pause of Play button clicked */
+ if( (is_playing != 1) &&
+ (i_xpos >= (BTN_SPACE>>1)) &&
+ (i_xpos <= i_dest + p_btnPlay->width + (BTN_SPACE>>1)) )
+ return clicked_Play;
+ else if( (i_xpos >= (BTN_SPACE>>1)) &&
+ (i_xpos <= i_dest + p_btnPause->width) )
+ return clicked_Pause;
+
+ /* is Stop button clicked */
+ if( is_playing != 1 )
+ i_dest += (p_btnPlay->width + (BTN_SPACE>>1));
+ else
+ i_dest += (p_btnPause->width + (BTN_SPACE>>1));
+
+ if( (i_xpos >= i_dest) &&
+ (i_xpos <= i_dest + p_btnStop->width + (BTN_SPACE>>1)) )
+ return clicked_Stop;
+
+ /* is Fullscreen button clicked */
+ i_dest += (p_btnStop->width + (BTN_SPACE>>1));
+ if( (i_xpos >= i_dest) &&
+ (i_xpos <= i_dest + p_btnFullscreen->width + (BTN_SPACE>>1)) )
+ return clicked_Fullscreen;
+
+ /* is Mute or Unmute button clicked */
+ i_dest += (p_btnFullscreen->width + (BTN_SPACE>>1));
+ if( !b_mute && (i_xpos >= i_dest) &&
+ (i_xpos <= i_dest + p_btnMute->width + (BTN_SPACE>>1)) )
+ return clicked_Mute;
+ else if( (i_xpos >= i_dest) &&
+ (i_xpos <= i_dest + p_btnUnmute->width + (BTN_SPACE>>1)) )
+ return clicked_Unmute;
+
+ /* is timeline clicked */
+ if( !b_mute )
+ i_dest += (p_btnMute->width + (BTN_SPACE>>1));
+ else
+ i_dest += (p_btnUnmute->width + (BTN_SPACE>>1));
+ if( (i_xpos >= i_dest) &&
+ (i_xpos <= i_dest + p_timeline->width + (BTN_SPACE>>1)) )
+ return clicked_timeline;
+
+ /* is time button clicked */
+ i_dest += (p_timeline->width + (BTN_SPACE>>1));
+ if( (i_xpos >= i_dest) &&
+ (i_xpos <= i_dest + p_btnTime->width + (BTN_SPACE>>1)) )
+ return clicked_Time;
+
+ return clicked_Unknown;
+}
+#undef BTN_SPACE