Commit eb84c196 authored by ivoire's avatar ivoire
Browse files

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

parent a155e540
......@@ -44,11 +44,11 @@
*****************************************************************************/
struct intf_sys_t
{
vlc_mutex_t lock;
vlc_object_t * p_vout;
bool b_button_pressed;
bool b_triggered;
int i_threshold;
vlc_mutex_t lock;
vlc_object_t *p_vout;
bool b_button_pressed;
bool b_triggered;
int i_threshold;
};
/*****************************************************************************
......@@ -57,7 +57,6 @@ struct intf_sys_t
int Open ( vlc_object_t * );
void Close( vlc_object_t * );
static void RunIntf( intf_thread_t *p_intf );
static int InitThread( intf_thread_t *p_intf );
static int MouseEvent( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
......@@ -84,16 +83,19 @@ int Open( vlc_object_t *p_this )
intf_thread_t *p_intf = (intf_thread_t *)p_this;
/* Allocate instance and initialize some members */
p_intf->p_sys = malloc( sizeof( intf_sys_t ) );
if( p_intf->p_sys == NULL )
{
return( 1 );
};
intf_sys_t *p_sys = p_intf->p_sys = malloc( sizeof( intf_sys_t ) );
if( p_sys == NULL )
return VLC_ENOMEM;
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;
return( 0 );
return VLC_SUCCESS;
}
/*****************************************************************************
......@@ -115,13 +117,6 @@ void Close( vlc_object_t *p_this )
static void RunIntf( intf_thread_t *p_intf )
{
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 */
while( vlc_object_alive( p_intf ) )
......@@ -177,30 +172,6 @@ static void RunIntf( intf_thread_t *p_intf )
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
*****************************************************************************/
......@@ -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_UNUSED(p_this); VLC_UNUSED(oldval); VLC_UNUSED(newval);
vlc_value_t val;
int i_mouse_x, i_mouse_y;
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,
return VLC_SUCCESS;
/* Nothing to do when not in fullscreen mode */
var_Get( p_intf->p_sys->p_vout, "fullscreen", &val );
if( !val.i_int )
if( !var_GetBool( p_intf->p_sys->p_vout, "fullscreen" ) )
return VLC_SUCCESS;
vlc_mutex_lock( &p_intf->p_sys->lock );
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 = val.i_int;
var_Get( p_intf->p_sys->p_vout, "mouse-y", &val );
i_mouse_y = val.i_int;
i_mouse_x = var_GetInteger( p_intf->p_sys->p_vout, "mouse-x" );
i_mouse_y = var_GetInteger( p_intf->p_sys->p_vout, "mouse-y" );
/* Very basic test, we even ignore the x value :) */
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