[vlc-devel] [RFC] JS and libvlc mouse events

Laurent Aimar fenrir at via.ecp.fr
Tue Jan 26 20:07:56 CET 2010


Hi,

On Mon, Jan 25, 2010, Jean-Paul Saman wrote:
> diff --git a/src/video_output/event.h b/src/video_output/event.h
> index 37eb390..f06df96 100644
> --- a/src/video_output/event.h
> +++ b/src/video_output/event.h
> @@ -60,19 +60,24 @@ static inline void vout_SendEventKey(vout_thread_t *vout, int key)
>  static inline void vout_SendEventMouseMoved(vout_thread_t *vout, int x, int y)
>  {
>  	var_SetInteger(vout, "mouse-x", x);
> +	var_SetInteger(vout->p_libvlc, "mouse-x", x);
>  	var_SetInteger(vout, "mouse-y", y);
> +	var_SetInteger(vout->p_libvlc, "mouse-y", y);
>  	var_SetBool(vout, "mouse-moved", true);
> +	var_SetBool(vout->p_libvlc, "mouse-moved", true);
>  }
>  static inline void vout_SendEventMousePressed(vout_thread_t *vout, int button)
>  {
>  	int current = var_GetInteger(vout, "mouse-button-down");
>  	current |= 1 << button;
>  	var_SetInteger(vout, "mouse-button-down", current);
> +        var_SetInteger(vout->p_libvlc, "mouse-button-down", current);
>  
>  	switch (button)
>  	{
>  	case MOUSE_BUTTON_LEFT:
> -        var_SetBool(vout, "mouse-clicked", true);
> +                var_SetBool(vout, "mouse-clicked", true);
> +                var_SetBool(vout->p_libvlc, "mouse-clicked", true);
>  		var_SetBool(vout->p_libvlc, "intf-popupmenu", false);
>  		break;
>  	case MOUSE_BUTTON_CENTER:
> @@ -89,11 +94,13 @@ static inline void vout_SendEventMouseReleased(vout_thread_t *vout, int button)
>  	int current = var_GetInteger(vout, "mouse-button-down");
>  	current &= ~(1 << button);
>  	var_SetInteger(vout, "mouse-button-down", current);
> +        var_SetInteger(vout->p_libvlc, "mouse-button-down", current);
>  }
>  static inline void vout_SendEventMouseDoubleClick(vout_thread_t *vout)
>  {
>      //vout_ControlSetFullscreen(vout, !var_GetBool(vout, "fullscreen"));
>      var_ToggleBool(vout, "fullscreen");
> +    var_SetBool(vout->p_libvlc, "mouse-double-clicked", true);
>  }
 I don't think storing them in p_libvlc is a really good idea:
 - you can have multiple inputs and/or vouts per libvlc.
 - and it clutters a bit more the vout code.

 I think it can be done by simply monitoring INPUT_EVENT_VOUT and
attaching/detaching callbacks on vout creation/destructions.
Becarefull that you have to remember on which vout you have added your
callbacks and to not forget to remove them before releasing the input.

Regards,

-- 
fenrir




More information about the vlc-devel mailing list