+
+static int OSDMenuCallback( vlc_object_t *p_this, char const *psz_var,
+ vlc_value_t oldval, vlc_value_t newval,
+ void *p_data )
+{
+ VLC_UNUSED(p_this); VLC_UNUSED(oldval);
+ filter_sys_t *p_sys = (filter_sys_t *) p_data;
+
+ if( !p_sys )
+ return VLC_SUCCESS;
+
+ if( !strncmp( psz_var, OSD_CFG"position", 16) )
+ {
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+ unsigned int i;
+ for( i=0; i < ARRAY_SIZE(pi_pos_values); i++ )
+ {
+ if( newval.i_int == pi_pos_values[i] )
+ {
+ p_sys->i_position = newval.i_int % 11;
+ break;
+ }
+ }
+#undef ARRAY_SIZE
+ }
+ else if( !strncmp( psz_var, OSD_CFG"x", 9) ||
+ !strncmp( psz_var, OSD_CFG"y", 9))
+ {
+ p_sys->b_absolute = true;
+ if( (p_sys->i_x < 0) || (p_sys->i_y < 0) )
+ {
+ p_sys->b_absolute = false;
+ p_sys->p_menu->i_x = 0;
+ p_sys->p_menu->i_y = 0;
+ }
+ else if( (p_sys->i_x >= 0) || (p_sys->i_y >= 0) )
+ {
+ p_sys->p_menu->i_x = p_sys->i_x;
+ p_sys->p_menu->i_y = p_sys->i_y;
+ }
+ }
+ else if( !strncmp( psz_var, OSD_CFG"update", 14) )
+ p_sys->i_update = (mtime_t)(newval.i_int * 1000);
+ else if( !strncmp( psz_var, OSD_CFG"timeout", 15) )
+ p_sys->i_update = newval.i_int % 1000;
+ else if( !strncmp( psz_var, OSD_CFG"alpha", 13) )
+ p_sys->i_alpha = newval.i_int % 256;
+
+ p_sys->b_update = p_sys->b_visible ? true : false;
+ return VLC_SUCCESS;
+}
+
+/*****************************************************************************
+ * MouseEvent: callback for mouse events
+ *****************************************************************************/
+static int MouseEvent( vlc_object_t *p_this, char const *psz_var,
+ vlc_value_t oldval, vlc_value_t newval, void *p_data )
+{
+ VLC_UNUSED(oldval); VLC_UNUSED(newval);
+ filter_sys_t *p_sys = (filter_sys_t *)p_data;
+ vout_thread_t *p_vout = (vout_thread_t*)p_sys->p_vout;
+ int i_x, i_y;
+ int i_v;
+
+#define MOUSE_DOWN 1
+#define MOUSE_CLICKED 2
+#define MOUSE_MOVE_X 4
+#define MOUSE_MOVE_Y 8
+#define MOUSE_MOVE 12
+ uint8_t mouse= 0;
+
+ int v_h = p_vout->output.i_height;
+ int v_w = p_vout->output.i_width;
+
+ if( psz_var[6] == 'x' ) mouse |= MOUSE_MOVE_X;
+ if( psz_var[6] == 'y' ) mouse |= MOUSE_MOVE_Y;
+ if( psz_var[6] == 'c' ) mouse |= MOUSE_CLICKED;
+
+ i_v = var_GetInteger( p_sys->p_vout, "mouse-button-down" );
+ if( i_v & 0x1 ) mouse |= MOUSE_DOWN;
+ i_y = var_GetInteger( p_sys->p_vout, "mouse-y" );
+ i_x = var_GetInteger( p_sys->p_vout, "mouse-x" );
+
+ if( i_y < 0 || i_x < 0 || i_y >= v_h || i_x >= v_w )
+ return VLC_SUCCESS;
+
+ if( mouse & MOUSE_CLICKED )
+ {
+ int i_scale_width, i_scale_height;
+ osd_button_t *p_button = NULL;
+
+ i_scale_width = p_vout->fmt_out.i_visible_width * 1000 /
+ p_vout->fmt_in.i_visible_width;
+ i_scale_height = p_vout->fmt_out.i_visible_height * 1000 /
+ p_vout->fmt_in.i_visible_height;
+
+ p_button = osd_ButtonFind( p_this, i_x, i_y, v_h, v_w,
+ i_scale_width, i_scale_height );
+ if( p_button )
+ {
+ osd_ButtonSelect( p_this, p_button );
+ p_sys->b_update = p_sys->b_visible ? true : false;
+ p_sys->b_clicked = true;
+ msg_Dbg( p_this, "mouse clicked %s (%d,%d)\n", p_button->psz_name, i_x, i_y );
+ }
+ }
+ return VLC_SUCCESS;
+}