static int ButtonEvent( vlc_object_t *p_this, char const *psz_var, vlc_value_t oldval, vlc_value_t val, void *p_data ) { intf_thread_t *p_intf = (intf_thread_t *)p_data; // sunqueen modify intf_sys_t *p_sys = p_intf->p_sys; (void) psz_var; (void) oldval; vlc_mutex_lock( &p_sys->lock ); if( val.i_int & p_sys->i_button_mask ) { if( !p_sys->b_button_pressed ) { p_sys->b_button_pressed = true; var_GetCoords( p_this, "mouse-moved", &p_sys->i_last_x, &p_sys->i_last_y ); } } else { if( p_sys->b_button_pressed ) { p_sys->b_button_pressed = false; ProcessGesture( p_intf ); } } vlc_mutex_unlock( &p_sys->lock ); 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(p_this); VLC_UNUSED(oldval); int pattern = 0; signed int i_horizontal, i_vertical; intf_thread_t *p_intf = (intf_thread_t *)p_data; intf_sys_t *p_sys = p_intf->p_sys; vlc_mutex_lock( &p_sys->lock ); /* don't process new gestures before the last events are processed */ if( p_sys->b_got_gesture ) { vlc_mutex_unlock( &p_sys->lock ); return VLC_SUCCESS; } if( !strcmp( psz_var, "mouse-moved" ) && p_sys->b_button_pressed ) { p_sys->i_mouse_x = newval.coords.x; p_sys->i_mouse_y = newval.coords.y; i_horizontal = p_sys->i_mouse_x - p_sys->i_last_x; i_horizontal = i_horizontal / p_sys->i_threshold; i_vertical = p_sys->i_mouse_y - p_sys->i_last_y; i_vertical = i_vertical / p_sys->i_threshold; if( i_horizontal < 0 ) { msg_Dbg( p_intf, "left gesture (%d)", i_horizontal ); pattern = LEFT; } else if( i_horizontal > 0 ) { msg_Dbg( p_intf, "right gesture (%d)", i_horizontal ); pattern = RIGHT; } if( i_vertical < 0 ) { msg_Dbg( p_intf, "up gesture (%d)", i_vertical ); pattern = UP; } else if( i_vertical > 0 ) { msg_Dbg( p_intf, "down gesture (%d)", i_vertical ); pattern = DOWN; } if( pattern ) { p_sys->i_last_y = p_sys->i_mouse_y; p_sys->i_last_x = p_sys->i_mouse_x; if( gesture( p_sys->i_pattern, p_sys->i_num_gestures - 1 ) != pattern ) { p_sys->i_pattern |= pattern << ( p_sys->i_num_gestures * 4 ); p_sys->i_num_gestures++; } } } else if( !strcmp( psz_var, "mouse-button-down" ) ) { if( (newval.i_int & p_sys->i_button_mask) && !p_sys->b_button_pressed ) { p_sys->b_button_pressed = true; var_GetCoords( p_sys->p_vout, "mouse-moved", &p_sys->i_last_x, &p_sys->i_last_y ); } else if( !( newval.i_int & p_sys->i_button_mask ) && p_sys->b_button_pressed ) { p_sys->b_button_pressed = false; p_sys->b_got_gesture = true; } } vlc_mutex_unlock( &p_sys->lock ); return VLC_SUCCESS; }