Commit 3e254383 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

gestures: avoid undefined negative shift

(cherry picked from commit 2051d837ea9066c4ddf388b7940652bb0c8d549c)
parent fa601028
...@@ -47,7 +47,7 @@ struct intf_sys_t ...@@ -47,7 +47,7 @@ struct intf_sys_t
bool b_button_pressed; bool b_button_pressed;
int i_last_x, i_last_y; int i_last_x, i_last_y;
unsigned int i_pattern; unsigned int i_pattern;
int i_num_gestures; unsigned int i_num_gestures;
int i_threshold; int i_threshold;
int i_button_mask; int i_button_mask;
}; };
...@@ -146,7 +146,7 @@ static int Open ( vlc_object_t *p_this ) ...@@ -146,7 +146,7 @@ static int Open ( vlc_object_t *p_this )
/***************************************************************************** /*****************************************************************************
* gesture: return a subpattern within a pattern * gesture: return a subpattern within a pattern
*****************************************************************************/ *****************************************************************************/
static int gesture( int i_pattern, int i_num ) static inline unsigned gesture( unsigned i_pattern, unsigned i_num )
{ {
return ( i_pattern >> ( i_num * 4 ) ) & 0xF; return ( i_pattern >> ( i_num * 4 ) ) & 0xF;
} }
...@@ -382,7 +382,7 @@ static int MovedEvent( vlc_object_t *p_this, char const *psz_var, ...@@ -382,7 +382,7 @@ static int MovedEvent( vlc_object_t *p_this, char const *psz_var,
{ {
int i_horizontal = newval.coords.x - p_sys->i_last_x; int i_horizontal = newval.coords.x - p_sys->i_last_x;
int i_vertical = newval.coords.y - p_sys->i_last_y; int i_vertical = newval.coords.y - p_sys->i_last_y;
int pattern = 0; unsigned int pattern = 0;
i_horizontal = i_horizontal / p_sys->i_threshold; i_horizontal = i_horizontal / p_sys->i_threshold;
i_vertical = i_vertical / p_sys->i_threshold; i_vertical = i_vertical / p_sys->i_threshold;
...@@ -412,7 +412,8 @@ static int MovedEvent( vlc_object_t *p_this, char const *psz_var, ...@@ -412,7 +412,8 @@ static int MovedEvent( vlc_object_t *p_this, char const *psz_var,
{ {
p_sys->i_last_x = newval.coords.x; p_sys->i_last_x = newval.coords.x;
p_sys->i_last_y = newval.coords.y; p_sys->i_last_y = newval.coords.y;
if( gesture( p_sys->i_pattern, p_sys->i_num_gestures - 1 ) if( p_sys->i_num_gestures > 0
&& gesture( p_sys->i_pattern, p_sys->i_num_gestures - 1 )
!= pattern ) != pattern )
{ {
p_sys->i_pattern |= pattern << ( p_sys->i_num_gestures * 4 ); p_sys->i_pattern |= pattern << ( p_sys->i_num_gestures * 4 );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment