Commit eb84c196 authored by Rémi Duraffort's avatar Rémi Duraffort

showintf: fix a variable type (bool instead of int) and do some cleanup.

parent a155e540
...@@ -44,11 +44,11 @@ ...@@ -44,11 +44,11 @@
*****************************************************************************/ *****************************************************************************/
struct intf_sys_t struct intf_sys_t
{ {
vlc_mutex_t lock; vlc_mutex_t lock;
vlc_object_t * p_vout; vlc_object_t *p_vout;
bool b_button_pressed; bool b_button_pressed;
bool b_triggered; bool b_triggered;
int i_threshold; int i_threshold;
}; };
/***************************************************************************** /*****************************************************************************
...@@ -57,7 +57,6 @@ struct intf_sys_t ...@@ -57,7 +57,6 @@ struct intf_sys_t
int Open ( vlc_object_t * ); int Open ( vlc_object_t * );
void Close( vlc_object_t * ); void Close( vlc_object_t * );
static void RunIntf( intf_thread_t *p_intf ); static void RunIntf( intf_thread_t *p_intf );
static int InitThread( intf_thread_t *p_intf );
static int MouseEvent( vlc_object_t *, char const *, static int MouseEvent( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * ); vlc_value_t, vlc_value_t, void * );
...@@ -84,16 +83,19 @@ int Open( vlc_object_t *p_this ) ...@@ -84,16 +83,19 @@ int Open( vlc_object_t *p_this )
intf_thread_t *p_intf = (intf_thread_t *)p_this; intf_thread_t *p_intf = (intf_thread_t *)p_this;
/* Allocate instance and initialize some members */ /* Allocate instance and initialize some members */
p_intf->p_sys = malloc( sizeof( intf_sys_t ) ); intf_sys_t *p_sys = p_intf->p_sys = malloc( sizeof( intf_sys_t ) );
if( p_intf->p_sys == NULL ) if( p_sys == NULL )
{ return VLC_ENOMEM;
return( 1 );
}; vlc_mutex_init( &p_sys->lock );
p_sys->p_vout = NULL;
p_sys->b_button_pressed = false;
p_sys->b_triggered = false;
p_sys->i_threshold = config_GetInt( p_intf, "showintf-threshold" );
vlc_mutex_init( &p_intf->p_sys->lock );
p_intf->pf_run = RunIntf; p_intf->pf_run = RunIntf;
return( 0 ); return VLC_SUCCESS;
} }
/***************************************************************************** /*****************************************************************************
...@@ -115,13 +117,6 @@ void Close( vlc_object_t *p_this ) ...@@ -115,13 +117,6 @@ void Close( vlc_object_t *p_this )
static void RunIntf( intf_thread_t *p_intf ) static void RunIntf( intf_thread_t *p_intf )
{ {
int canc = vlc_savecancel( ); int canc = vlc_savecancel( );
p_intf->p_sys->p_vout = NULL;
if( InitThread( p_intf ) < 0 )
{
msg_Err( p_intf, "cannot initialize interface" );
return;
}
/* Main loop */ /* Main loop */
while( vlc_object_alive( p_intf ) ) while( vlc_object_alive( p_intf ) )
...@@ -177,30 +172,6 @@ static void RunIntf( intf_thread_t *p_intf ) ...@@ -177,30 +172,6 @@ static void RunIntf( intf_thread_t *p_intf )
vlc_restorecancel( canc ); vlc_restorecancel( canc );
} }
/*****************************************************************************
* InitThread:
*****************************************************************************/
static int InitThread( intf_thread_t * p_intf )
{
if( vlc_object_alive( p_intf ) )
{
vlc_mutex_lock( &p_intf->p_sys->lock );
p_intf->p_sys->b_triggered = false;
p_intf->p_sys->b_button_pressed = false;
p_intf->p_sys->i_threshold =
config_GetInt( p_intf, "showintf-threshold" );
vlc_mutex_unlock( &p_intf->p_sys->lock );
return 0;
}
else
{
return -1;
}
}
/***************************************************************************** /*****************************************************************************
* MouseEvent: callback for mouse events * MouseEvent: callback for mouse events
*****************************************************************************/ *****************************************************************************/
...@@ -208,7 +179,6 @@ static int MouseEvent( vlc_object_t *p_this, char const *psz_var, ...@@ -208,7 +179,6 @@ static int MouseEvent( vlc_object_t *p_this, char const *psz_var,
vlc_value_t oldval, vlc_value_t newval, void *p_data ) vlc_value_t oldval, vlc_value_t newval, void *p_data )
{ {
VLC_UNUSED(p_this); VLC_UNUSED(oldval); VLC_UNUSED(newval); VLC_UNUSED(p_this); VLC_UNUSED(oldval); VLC_UNUSED(newval);
vlc_value_t val;
int i_mouse_x, i_mouse_y; int i_mouse_x, i_mouse_y;
intf_thread_t *p_intf = (intf_thread_t *)p_data; intf_thread_t *p_intf = (intf_thread_t *)p_data;
...@@ -218,17 +188,14 @@ static int MouseEvent( vlc_object_t *p_this, char const *psz_var, ...@@ -218,17 +188,14 @@ static int MouseEvent( vlc_object_t *p_this, char const *psz_var,
return VLC_SUCCESS; return VLC_SUCCESS;
/* Nothing to do when not in fullscreen mode */ /* Nothing to do when not in fullscreen mode */
var_Get( p_intf->p_sys->p_vout, "fullscreen", &val ); if( !var_GetBool( p_intf->p_sys->p_vout, "fullscreen" ) )
if( !val.i_int )
return VLC_SUCCESS; return VLC_SUCCESS;
vlc_mutex_lock( &p_intf->p_sys->lock ); vlc_mutex_lock( &p_intf->p_sys->lock );
if( !strcmp( psz_var, "mouse-moved" ) && !p_intf->p_sys->b_button_pressed ) if( !strcmp( psz_var, "mouse-moved" ) && !p_intf->p_sys->b_button_pressed )
{ {
var_Get( p_intf->p_sys->p_vout, "mouse-x", &val ); i_mouse_x = var_GetInteger( p_intf->p_sys->p_vout, "mouse-x" );
i_mouse_x = val.i_int; i_mouse_y = var_GetInteger( p_intf->p_sys->p_vout, "mouse-y" );
var_Get( p_intf->p_sys->p_vout, "mouse-y", &val );
i_mouse_y = val.i_int;
/* Very basic test, we even ignore the x value :) */ /* Very basic test, we even ignore the x value :) */
if ( i_mouse_y < p_intf->p_sys->i_threshold ) if ( i_mouse_y < p_intf->p_sys->i_threshold )
......
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