Commit 4a95265a authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Make mouse-moved and mouse-clicked coordinates, remove mouse-x and -y

This simplifies callbacks a bit, and fixes a race condition.
parent c01dd91c
...@@ -1272,8 +1272,8 @@ static int EventMouse( vlc_object_t *p_vout, char const *psz_var, ...@@ -1272,8 +1272,8 @@ static int EventMouse( vlc_object_t *p_vout, char const *psz_var,
/* FIXME? PCI usage thread safe? */ /* FIXME? PCI usage thread safe? */
pci_t *pci = dvdnav_get_current_nav_pci( p_sys->dvdnav ); pci_t *pci = dvdnav_get_current_nav_pci( p_sys->dvdnav );
int x = var_GetInteger( p_vout, "mouse-x" ); int x = val.coords.x;
int y = var_GetInteger( p_vout, "mouse-y" ); int y = val.coords.y;
if( psz_var[6] == 'm' ) /* mouse-moved */ if( psz_var[6] == 'm' ) /* mouse-moved */
dvdnav_mouse_select( p_sys->dvdnav, pci, x, y ); dvdnav_mouse_select( p_sys->dvdnav, pci, x, y );
...@@ -1284,8 +1284,7 @@ static int EventMouse( vlc_object_t *p_vout, char const *psz_var, ...@@ -1284,8 +1284,7 @@ static int EventMouse( vlc_object_t *p_vout, char const *psz_var,
ButtonUpdate( p_demux, true ); ButtonUpdate( p_demux, true );
dvdnav_mouse_activate( p_sys->dvdnav, pci, x, y ); dvdnav_mouse_activate( p_sys->dvdnav, pci, x, y );
} }
(void)oldval;
(void)oldval; (void)val;
return VLC_SUCCESS; return VLC_SUCCESS;
} }
......
...@@ -465,8 +465,8 @@ static int MouseEvent( vlc_object_t *p_this, char const *psz_var, ...@@ -465,8 +465,8 @@ static int MouseEvent( vlc_object_t *p_this, char const *psz_var,
if( !strcmp( psz_var, "mouse-moved" ) && p_sys->b_button_pressed ) if( !strcmp( psz_var, "mouse-moved" ) && p_sys->b_button_pressed )
{ {
p_sys->i_mouse_x = var_GetInteger( p_sys->p_vout, "mouse-x" ); p_sys->i_mouse_x = newval.coords.x;
p_sys->i_mouse_y = var_GetInteger( p_sys->p_vout, "mouse-y" ); p_sys->i_mouse_y = newval.coords.y;
i_horizontal = p_sys->i_mouse_x - p_sys->i_last_x; i_horizontal = p_sys->i_mouse_x - p_sys->i_last_x;
i_horizontal = i_horizontal / p_sys->i_threshold; i_horizontal = i_horizontal / p_sys->i_threshold;
i_vertical = p_sys->i_mouse_y - p_sys->i_last_y; i_vertical = p_sys->i_mouse_y - p_sys->i_last_y;
...@@ -510,8 +510,8 @@ static int MouseEvent( vlc_object_t *p_this, char const *psz_var, ...@@ -510,8 +510,8 @@ static int MouseEvent( vlc_object_t *p_this, char const *psz_var,
if( (newval.i_int & p_sys->i_button_mask) && !p_sys->b_button_pressed ) if( (newval.i_int & p_sys->i_button_mask) && !p_sys->b_button_pressed )
{ {
p_sys->b_button_pressed = true; p_sys->b_button_pressed = true;
p_sys->i_last_x = var_GetInteger( p_sys->p_vout, "mouse-x" ); var_GetCoords( p_sys->p_vout, "mouse-moved",
p_sys->i_last_y = var_GetInteger( p_sys->p_vout, "mouse-y" ); &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 ) else if( !( newval.i_int & p_sys->i_button_mask ) && p_sys->b_button_pressed )
{ {
......
...@@ -415,12 +415,11 @@ void * demux_sys_t::EventThread( vlc_object_t *p_this ) ...@@ -415,12 +415,11 @@ void * demux_sys_t::EventThread( vlc_object_t *p_this )
/* MOUSE part */ /* MOUSE part */
if( p_vout && ( p_ev->b_moved || p_ev->b_clicked ) ) if( p_vout && ( p_ev->b_moved || p_ev->b_clicked ) )
{ {
vlc_value_t valx, valy; int x, y;
var_GetCoords( p_vout, "mouse-moved", &x, &y );
vlc_mutex_lock( &p_ev->lock ); vlc_mutex_lock( &p_ev->lock );
pci_t *pci = (pci_t *) &p_sys->pci_packet; pci_t *pci = (pci_t *) &p_sys->pci_packet;
var_Get( p_vout, "mouse-x", &valx );
var_Get( p_vout, "mouse-y", &valy );
if( p_ev->b_clicked ) if( p_ev->b_clicked )
{ {
...@@ -428,7 +427,7 @@ void * demux_sys_t::EventThread( vlc_object_t *p_this ) ...@@ -428,7 +427,7 @@ void * demux_sys_t::EventThread( vlc_object_t *p_this )
int32_t best,dist,d; int32_t best,dist,d;
int32_t mx,my,dx,dy; int32_t mx,my,dx,dy;
msg_Dbg( p_ev->p_demux, "Handle Mouse Event: Mouse clicked x(%d)*y(%d)", (unsigned)valx.i_int, (unsigned)valy.i_int); msg_Dbg( p_ev->p_demux, "Handle Mouse Event: Mouse clicked x(%d)*y(%d)", x, y);
b_activated = true; b_activated = true;
// get current button // get current button
...@@ -438,15 +437,15 @@ void * demux_sys_t::EventThread( vlc_object_t *p_this ) ...@@ -438,15 +437,15 @@ void * demux_sys_t::EventThread( vlc_object_t *p_this )
{ {
btni_t *button_ptr = &(pci->hli.btnit[button-1]); btni_t *button_ptr = &(pci->hli.btnit[button-1]);
if(((unsigned)valx.i_int >= button_ptr->x_start) if(((unsigned)x >= button_ptr->x_start)
&& ((unsigned)valx.i_int <= button_ptr->x_end) && ((unsigned)x <= button_ptr->x_end)
&& ((unsigned)valy.i_int >= button_ptr->y_start) && ((unsigned)y >= button_ptr->y_start)
&& ((unsigned)valy.i_int <= button_ptr->y_end)) && ((unsigned)y <= button_ptr->y_end))
{ {
mx = (button_ptr->x_start + button_ptr->x_end)/2; mx = (button_ptr->x_start + button_ptr->x_end)/2;
my = (button_ptr->y_start + button_ptr->y_end)/2; my = (button_ptr->y_start + button_ptr->y_end)/2;
dx = mx - valx.i_int; dx = mx - x;
dy = my - valy.i_int; dy = my - y;
d = (dx*dx) + (dy*dy); d = (dx*dx) + (dy*dy);
/* If the mouse is within the button and the mouse is closer /* If the mouse is within the button and the mouse is closer
* to the center of this button then it is the best choice. */ * to the center of this button then it is the best choice. */
...@@ -519,7 +518,7 @@ void * demux_sys_t::EventThread( vlc_object_t *p_this ) ...@@ -519,7 +518,7 @@ void * demux_sys_t::EventThread( vlc_object_t *p_this )
} }
else if( p_ev->b_moved ) else if( p_ev->b_moved )
{ {
// dvdnav_mouse_select( NULL, pci, valx.i_int, valy.i_int ); // dvdnav_mouse_select( NULL, pci, x, y );
} }
p_ev->b_moved = false; p_ev->b_moved = false;
......
...@@ -580,7 +580,10 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, ...@@ -580,7 +580,10 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
if( p_vout && [o_event type] == NSLeftMouseUp ) if( p_vout && [o_event type] == NSLeftMouseUp )
{ {
var_SetBool( p_vout, "mouse-clicked", true ); int x, y;
var_GetCoords( p_vout, "mouse-moved", &x, &y );
var_SetCoords( p_vout, "mouse-clicked", x, y );
var_Get( p_vout, "mouse-button-down", &val ); var_Get( p_vout, "mouse-button-down", &val );
val.i_int &= ~1; val.i_int &= ~1;
...@@ -646,29 +649,24 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, ...@@ -646,29 +649,24 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
if( b_inside ) if( b_inside )
{ {
vlc_value_t val; int x, y;
unsigned int i_width, i_height, i_x, i_y; unsigned int i_width, i_height, i_x, i_y;
vout_PlacePicture( p_vout, (unsigned int)s_rect.size.width, vout_PlacePicture( p_vout, (unsigned int)s_rect.size.width,
(unsigned int)s_rect.size.height, (unsigned int)s_rect.size.height,
&i_x, &i_y, &i_width, &i_height ); &i_x, &i_y, &i_width, &i_height );
val.i_int = ( ((int)ml.x) - i_x ) * x = (((int)ml.x) - i_x) * p_vout->render.i_width / i_width;
p_vout->render.i_width / i_width;
var_Set( p_vout, "mouse-x", val );
if( [[o_view className] isEqualToString: @"VLCGLView"] ) if( [[o_view className] isEqualToString: @"VLCGLView"] )
{ {
val.i_int = ( ((int)(s_rect.size.height - ml.y)) - i_y ) * y = (((int)(s_rect.size.height - ml.y)) - i_y) *
p_vout->render.i_height / i_height; p_vout->render.i_height / i_height;
} }
else else
{ {
val.i_int = ( ((int)ml.y) - i_y ) * y = (((int)ml.y) - i_y) * p_vout->render.i_height / i_height;
p_vout->render.i_height / i_height;
} }
var_Set( p_vout, "mouse-y", val ); var_SetCoords( p_vout, "mouse-moved", x, y );
var_TriggerCallback( p_vout, "mouse-moved" );
} }
if( [self isFullscreen] ) if( [self isFullscreen] )
[[[[VLCMain sharedInstance] controls] fspanel] fadeIn]; [[[[VLCMain sharedInstance] controls] fspanel] fadeIn];
......
...@@ -976,8 +976,10 @@ static pascal OSStatus WindowEventHandler(EventHandlerCallRef nextHandler, Event ...@@ -976,8 +976,10 @@ static pascal OSStatus WindowEventHandler(EventHandlerCallRef nextHandler, Event
else else
{ {
vlc_value_t val; vlc_value_t val;
int x, y;
var_SetBool( p_vout, "mouse-clicked", true ); var_GetCoords( p_vout, "mouse-moved", &x, &y );
var_SetCoords( p_vout, "mouse-clicked", x, y );
var_Get( p_vout, "mouse-button-down", &val ); var_Get( p_vout, "mouse-button-down", &val );
val.i_int &= ~1; val.i_int &= ~1;
...@@ -1017,20 +1019,15 @@ static pascal OSStatus WindowEventHandler(EventHandlerCallRef nextHandler, Event ...@@ -1017,20 +1019,15 @@ static pascal OSStatus WindowEventHandler(EventHandlerCallRef nextHandler, Event
unsigned int i_x, i_y; unsigned int i_x, i_y;
unsigned int i_height = p_vout->p_sys->i_height; unsigned int i_height = p_vout->p_sys->i_height;
unsigned int i_width = p_vout->p_sys->i_width; unsigned int i_width = p_vout->p_sys->i_width;
int x, y;
vout_PlacePicture(p_vout, i_width, i_height, &i_x, &i_y, &i_width, &i_height); vout_PlacePicture(p_vout, i_width, i_height, &i_x, &i_y, &i_width, &i_height);
GetEventParameter(event, kEventParamWindowMouseLocation, typeQDPoint, NULL, sizeof(Point), NULL, &ml); GetEventParameter(event, kEventParamWindowMouseLocation, typeQDPoint, NULL, sizeof(Point), NULL, &ml);
val.i_int = ( ((int)ml.h) - i_x ) * x = (((int)ml.h) - i_x) * p_vout->render.i_width / i_width;
p_vout->render.i_width / i_width; y = (((int)ml.v) - i_y) * p_vout->render.i_height / i_height;
var_Set( p_vout, "mouse-x", val ); var_SetCoords( p_vout, "mouse-moved", x, y );
val.i_int = ( ((int)ml.v) - i_y ) *
p_vout->render.i_height / i_height;
var_Set( p_vout, "mouse-y", val );
var_TriggerCallback( p_vout, "mouse-moved" );
break; break;
} }
......
...@@ -534,8 +534,10 @@ static pascal OSStatus WindowEventHandler(EventHandlerCallRef nextHandler, Event ...@@ -534,8 +534,10 @@ static pascal OSStatus WindowEventHandler(EventHandlerCallRef nextHandler, Event
else else
{ {
vlc_value_t val; vlc_value_t val;
int x, y;
var_SetBool( p_vout, "mouse-clicked", true ); var_GetCoords( p_vout, "mouse-moved", &x, &y );
var_SetCoords( p_vout, "mouse-clicked", x, y );
var_Get( p_vout, "mouse-button-down", &val ); var_Get( p_vout, "mouse-button-down", &val );
val.i_int &= ~1; val.i_int &= ~1;
...@@ -575,20 +577,15 @@ static pascal OSStatus WindowEventHandler(EventHandlerCallRef nextHandler, Event ...@@ -575,20 +577,15 @@ static pascal OSStatus WindowEventHandler(EventHandlerCallRef nextHandler, Event
unsigned int i_x, i_y; unsigned int i_x, i_y;
unsigned int i_height = p_vout->p_sys->i_height; unsigned int i_height = p_vout->p_sys->i_height;
unsigned int i_width = p_vout->p_sys->i_width; unsigned int i_width = p_vout->p_sys->i_width;
int x, y;
vout_PlacePicture(p_vout, i_width, i_height, &i_x, &i_y, &i_width, &i_height); vout_PlacePicture(p_vout, i_width, i_height, &i_x, &i_y, &i_width, &i_height);
GetEventParameter(event, kEventParamWindowMouseLocation, typeQDPoint, NULL, sizeof(Point), NULL, &ml); GetEventParameter(event, kEventParamWindowMouseLocation, typeQDPoint, NULL, sizeof(Point), NULL, &ml);
val.i_int = ( ((int)ml.h) - i_x ) * x = (((int)ml.h) - i_x) * p_vout->render.i_width / i_width;
p_vout->render.i_width / i_width; y = (((int)ml.v) - i_y) * p_vout->render.i_height / i_height;
var_Set( p_vout, "mouse-x", val ); var_SetCoords( p_vout, "mouse-moved", x, y );
val.i_int = ( ((int)ml.v) - i_y ) *
p_vout->render.i_height / i_height;
var_Set( p_vout, "mouse-y", val );
var_TriggerCallback( p_vout, "mouse-moved" );
break; break;
} }
......
...@@ -949,10 +949,7 @@ static int FullscreenControllerWidgetMouseMoved( vlc_object_t *vlc_object, const ...@@ -949,10 +949,7 @@ static int FullscreenControllerWidgetMouseMoved( vlc_object_t *vlc_object, const
FullscreenControllerWidget *p_fs = (FullscreenControllerWidget *)data; FullscreenControllerWidget *p_fs = (FullscreenControllerWidget *)data;
/* Get the value from the Vout - Trust the vout more than Qt */ /* Get the value from the Vout - Trust the vout more than Qt */
const int i_mousex = var_GetInteger( p_vout, "mouse-x" ); p_fs->mouseChanged( p_vout, new_val.coords.x, new_val.coords.y );
const int i_mousey = var_GetInteger( p_vout, "mouse-y" );
p_fs->mouseChanged( p_vout, i_mousex, i_mousey );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
......
...@@ -831,14 +831,14 @@ static int MouseEvent( vlc_object_t *p_this, char const *psz_var, ...@@ -831,14 +831,14 @@ static int MouseEvent( vlc_object_t *p_this, char const *psz_var,
vout_thread_t *p_vout = p_data; vout_thread_t *p_vout = p_data;
VLC_UNUSED(p_this); VLC_UNUSED(oldval); VLC_UNUSED(p_this); VLC_UNUSED(oldval);
if( !strcmp( psz_var, "mouse-button-down" ) )
return var_SetChecked( p_vout, psz_var, VLC_VAR_INTEGER, newval );
/* Translate the mouse coordinates /* Translate the mouse coordinates
* FIXME missing lock */ * FIXME missing lock */
if( !strcmp( psz_var, "mouse-x" ) ) newval.coords.x += p_vout->p_sys->i_x;
newval.i_int += p_vout->p_sys->i_x; newval.coords.y += p_vout->p_sys->i_y;
else if( !strcmp( psz_var, "mouse-y" ) ) return var_SetChecked( p_vout, psz_var, VLC_VAR_COORDS, newval );
newval.i_int += p_vout->p_sys->i_y;
return var_Set( p_vout, psz_var, newval );
} }
#ifdef BEST_AUTOCROP #ifdef BEST_AUTOCROP
......
...@@ -494,10 +494,12 @@ static int MouseEvent( vlc_object_t *p_this, char const *psz_var, ...@@ -494,10 +494,12 @@ static int MouseEvent( vlc_object_t *p_this, char const *psz_var,
vout_thread_t *p_vout = p_data; vout_thread_t *p_vout = p_data;
VLC_UNUSED(p_this); VLC_UNUSED(oldval); VLC_UNUSED(p_this); VLC_UNUSED(oldval);
if( !strcmp( psz_var, "mouse-y" ) && p_vout->p_sys->b_half_height ) if( !strcmp( psz_var, "mouse-button-down" ) )
newval.i_int *= 2; return var_SetChecked( p_vout, psz_var, VLC_VAR_INTEGER, newval );
return var_Set( p_vout, psz_var, newval ); if( p_vout->p_sys->b_half_height )
newval.coords.y *= 2;
return var_SetChecked( p_vout, psz_var, VLC_VAR_COORDS, newval );
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -102,8 +102,6 @@ static inline void vout_filter_SetupChild( vout_thread_t *p_parent, ...@@ -102,8 +102,6 @@ static inline void vout_filter_SetupChild( vout_thread_t *p_parent,
/* */ /* */
if( !pf_mouse_event ) if( !pf_mouse_event )
pf_mouse_event = ForwardEvent; pf_mouse_event = ForwardEvent;
pf_execute( VLC_OBJECT(p_child), "mouse-x", pf_mouse_event, p_parent );
pf_execute( VLC_OBJECT(p_child), "mouse-y", pf_mouse_event, p_parent );
pf_execute( VLC_OBJECT(p_child), "mouse-moved", pf_mouse_event, p_parent ); pf_execute( VLC_OBJECT(p_child), "mouse-moved", pf_mouse_event, p_parent );
pf_execute( VLC_OBJECT(p_child), "mouse-clicked", pf_mouse_event, p_parent ); pf_execute( VLC_OBJECT(p_child), "mouse-clicked", pf_mouse_event, p_parent );
pf_execute( VLC_OBJECT(p_child), "mouse-button-down", pf_mouse_event, p_parent ); pf_execute( VLC_OBJECT(p_child), "mouse-button-down", pf_mouse_event, p_parent );
......
...@@ -255,14 +255,8 @@ static int CreateFilter ( vlc_object_t *p_this ) ...@@ -255,14 +255,8 @@ static int CreateFilter ( vlc_object_t *p_this )
p_sys->p_vout = vlc_object_find( p_this, VLC_OBJECT_VOUT, FIND_PARENT ); p_sys->p_vout = vlc_object_find( p_this, VLC_OBJECT_VOUT, FIND_PARENT );
if( p_sys->p_vout ) if( p_sys->p_vout )
{
var_AddCallback( p_sys->p_vout, "mouse-x",
MouseEvent, p_sys );
var_AddCallback( p_sys->p_vout, "mouse-y",
MouseEvent, p_sys );
var_AddCallback( p_sys->p_vout, "mouse-clicked", var_AddCallback( p_sys->p_vout, "mouse-clicked",
MouseEvent, p_sys ); MouseEvent, p_sys );
}
es_format_Init( &p_filter->fmt_out, SPU_ES, VLC_CODEC_SPU ); es_format_Init( &p_filter->fmt_out, SPU_ES, VLC_CODEC_SPU );
p_filter->fmt_out.i_priority = 0; p_filter->fmt_out.i_priority = 0;
...@@ -291,25 +285,16 @@ static void DestroyFilter( vlc_object_t *p_this ) ...@@ -291,25 +285,16 @@ static void DestroyFilter( vlc_object_t *p_this )
var_DelCallback( p_filter, OSD_CFG "update", OSDMenuCallback, p_sys ); var_DelCallback( p_filter, OSD_CFG "update", OSDMenuCallback, p_sys );
var_DelCallback( p_filter, OSD_CFG "alpha", OSDMenuCallback, p_sys ); var_DelCallback( p_filter, OSD_CFG "alpha", OSDMenuCallback, p_sys );
if( p_sys ) /* FIXME: <-- WTF??? what about the 4 ones above? */ var_DelCallback( p_sys->p_menu, "osd-menu-update",
{ OSDMenuUpdateEvent, p_filter );
var_DelCallback( p_sys->p_menu, "osd-menu-update", var_DelCallback( p_sys->p_menu, "osd-menu-visible",
OSDMenuUpdateEvent, p_filter ); OSDMenuVisibleEvent, p_filter );
var_DelCallback( p_sys->p_menu, "osd-menu-visible",
OSDMenuVisibleEvent, p_filter );
}
if( p_sys && p_sys->p_vout ) if( p_sys->p_vout )
{ {
var_DelCallback( p_sys->p_vout, "mouse-x",
MouseEvent, p_sys );
var_DelCallback( p_sys->p_vout, "mouse-y",
MouseEvent, p_sys );
var_DelCallback( p_sys->p_vout, "mouse-clicked", var_DelCallback( p_sys->p_vout, "mouse-clicked",
MouseEvent, p_sys ); MouseEvent, p_sys );
vlc_object_release( p_sys->p_vout ); vlc_object_release( p_sys->p_vout );
p_sys->p_vout = NULL;
} }
var_Destroy( p_this, OSD_CFG "file-path" ); var_Destroy( p_this, OSD_CFG "file-path" );
...@@ -321,14 +306,10 @@ static void DestroyFilter( vlc_object_t *p_this ) ...@@ -321,14 +306,10 @@ static void DestroyFilter( vlc_object_t *p_this )
var_Destroy( p_this, OSD_CFG "update" ); var_Destroy( p_this, OSD_CFG "update" );
var_Destroy( p_this, OSD_CFG "alpha" ); var_Destroy( p_this, OSD_CFG "alpha" );
if( p_sys ) osd_MenuDelete( p_filter, p_sys->p_menu );
{ free( p_sys->psz_path );
osd_MenuDelete( p_filter, p_sys->p_menu ); free( p_sys->psz_file );
free( p_sys );
free( p_sys->psz_path );
free( p_sys->psz_file );
free( p_sys );
}
} }
/***************************************************************************** /*****************************************************************************
...@@ -662,35 +643,18 @@ static int OSDMenuCallback( vlc_object_t *p_this, char const *psz_var, ...@@ -662,35 +643,18 @@ static int OSDMenuCallback( vlc_object_t *p_this, char const *psz_var,
static int MouseEvent( vlc_object_t *p_this, char const *psz_var, 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(oldval); VLC_UNUSED(newval); VLC_UNUSED(oldval);
filter_sys_t *p_sys = (filter_sys_t *)p_data; filter_sys_t *p_sys = (filter_sys_t *)p_data;
vout_thread_t *p_vout = (vout_thread_t*)p_sys->p_vout; vout_thread_t *p_vout = (vout_thread_t*)p_sys->p_vout;
int i_x, i_y; int i_x = newval.coords.x;
int i_v; int i_y = newval.coords.y;
#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_h = p_vout->output.i_height;
int v_w = p_vout->output.i_width; 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 ) if( i_y < 0 || i_x < 0 || i_y >= v_h || i_x >= v_w )
return VLC_SUCCESS; return VLC_SUCCESS;
if( mouse & MOUSE_CLICKED ) do
{ {
int i_scale_width, i_scale_height; int i_scale_width, i_scale_height;
osd_button_t *p_button = NULL; osd_button_t *p_button = NULL;
...@@ -710,5 +674,6 @@ static int MouseEvent( vlc_object_t *p_this, char const *psz_var, ...@@ -710,5 +674,6 @@ static int MouseEvent( vlc_object_t *p_this, char const *psz_var,
msg_Dbg( p_this, "mouse clicked %s (%d,%d)", p_button->psz_name, i_x, i_y ); msg_Dbg( p_this, "mouse clicked %s (%d,%d)", p_button->psz_name, i_x, i_y );
} }
} }
while(0);
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -1335,10 +1335,8 @@ static int MouseEvent( vlc_object_t *p_this, char const *psz_var, ...@@ -1335,10 +1335,8 @@ static int MouseEvent( vlc_object_t *p_this, char const *psz_var,
int i_x, i_y; int i_x, i_y;
int i_v; int i_v;
i_v = var_GetInteger( p_sys->p_vout, "mouse-button-down" ); i_v = var_GetInteger( p_sys->p_vout, "mouse-button-down" );
i_y = var_GetInteger( p_sys->p_vout, "mouse-y" ); var_GetCoords( p_sys->p_vout, "mouse-moved", &i_x, &i_y );
i_x = var_GetInteger( p_sys->p_vout, "mouse-x" );
vlc_mutex_lock( &p_sys->lock ); vlc_mutex_lock( &p_sys->lock );
......
...@@ -325,59 +325,47 @@ static void Render( vout_thread_t *p_vout, picture_t *p_pic ) ...@@ -325,59 +325,47 @@ static void Render( vout_thread_t *p_vout, picture_t *p_pic )
* Forward mouse event with proper conversion. * Forward mouse event with proper conversion.
*/ */
static int MouseEvent( vlc_object_t *p_this, char const *psz_var, 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 val, void *p_data )
{ {
vout_thread_t *p_vout = p_data; vout_thread_t *p_vout = p_data;
VLC_UNUSED(p_this); VLC_UNUSED(oldval); VLC_UNUSED(p_this); VLC_UNUSED(oldval);
/* Translate the mouse coordinates /* Translate the mouse coordinates
* FIXME missing lock */ * FIXME missing lock */
if( !strcmp( psz_var, "mouse-x" ) ) if( !strcmp( psz_var, "mouse-button-down" ) )
return var_SetChecked( p_vout, psz_var, VLC_VAR_INTEGER, val );
int x = val.coords.x, y = val.coords.y;
switch( p_vout->p_sys->i_mode )
{ {
switch( p_vout->p_sys->i_mode )
{
case TRANSFORM_MODE_270:
newval.i_int = p_vout->p_sys->p_vout->output.i_width
- newval.i_int;
case TRANSFORM_MODE_90: case TRANSFORM_MODE_90:
psz_var = "mouse-y"; x = p_vout->p_sys->p_vout->output.i_height - val.coords.y;
y = val.coords.x;
break; break;
case TRANSFORM_MODE_180: case TRANSFORM_MODE_180:
case TRANSFORM_MODE_HFLIP: x = p_vout->p_sys->p_vout->output.i_width - val.coords.x;
newval.i_int = p_vout->p_sys->p_vout->output.i_width y = p_vout->p_sys->p_vout->output.i_height - val.coords.y;
- newval.i_int;
break; break;
case TRANSFORM_MODE_VFLIP:
default:
break;
}
}
else if( !strcmp( psz_var, "mouse-y" ) )
{
switch( p_vout->p_sys->i_mode )
{
case TRANSFORM_MODE_90:
newval.i_int = p_vout->p_sys->p_vout->output.i_height
- newval.i_int;
case TRANSFORM_MODE_270: case TRANSFORM_MODE_270:
psz_var = "mouse-x"; x = val.coords.y;
y = p_vout->p_sys->p_vout->output.i_width - val.coords.x;
break;
case TRANSFORM_MODE_HFLIP:
x = p_vout->p_sys->p_vout->output.i_width - val.coords.x;
break; break;
case TRANSFORM_MODE_180:
case TRANSFORM_MODE_VFLIP: case TRANSFORM_MODE_VFLIP:
newval.i_int = p_vout->p_sys->p_vout->output.i_height y = p_vout->p_sys->p_vout->output.i_height - val.coords.y;
- newval.i_int;
break; break;
case TRANSFORM_MODE_HFLIP:
default: default:
break; break;
}
} }
return var_SetCoords( p_vout, psz_var, x, y );
return var_Set( p_vout, psz_var, newval );
} }
static void FilterPlanar( vout_thread_t *p_vout, static void FilterPlanar( vout_thread_t *p_vout,
......
...@@ -454,8 +454,7 @@ static int MouseEvent( vlc_object_t *p_this, char const *psz_var, ...@@ -454,8 +454,7 @@ static int MouseEvent( vlc_object_t *p_this, char const *psz_var,
vlc_mouse_t m; vlc_mouse_t m;
vlc_mouse_Init( &m ); vlc_mouse_Init( &m );
m.i_x = var_GetInteger( p_vout_src, "mouse-x" ); var_GetCoords( p_vout_src, "mouse-moved", &m.i_x, &m.i_y );
m.i_y = var_GetInteger( p_vout_src, "mouse-y" );
m.i_pressed = var_GetInteger( p_vout_src, "mouse-button-down" ); m.i_pressed = var_GetInteger( p_vout_src, "mouse-button-down" );
vlc_mutex_lock( &p_sys->lock ); vlc_mutex_lock( &p_sys->lock );
...@@ -485,9 +484,7 @@ static int MouseEvent( vlc_object_t *p_this, char const *psz_var, ...@@ -485,9 +484,7 @@ static int MouseEvent( vlc_object_t *p_this, char const *psz_var,
if( vlc_mouse_HasMoved( &omouse, &nmouse ) ) if( vlc_mouse_HasMoved( &omouse, &nmouse ) )
{ {
var_SetInteger( p_vout, "mouse-x", nmouse.i_x ); var_SetCoords( p_vout, "mouse-moved", nmouse.i_x, nmouse.i_y );
var_SetInteger( p_vout, "mouse-y", nmouse.i_y );
var_TriggerCallback( p_vout, "mouse-moved" );
} }
if( vlc_mouse_HasButton( &omouse, &nmouse ) ) if( vlc_mouse_HasButton( &omouse, &nmouse ) )
{ {
......
...@@ -303,7 +303,8 @@ static int Manage( vout_thread_t *p_vout ) ...@@ -303,7 +303,8 @@ static int Manage( vout_thread_t *p_vout )
switch( event.pbutton.button ) switch( event.pbutton.button )
{ {
case GII_PBUTTON_LEFT: case GII_PBUTTON_LEFT:
var_SetBool( p_vout, "mouse-clicked", true ); /*FIXME
var_SetCoords( p_vout, "mouse-clicked", x, y );*/
break; break;
case GII_PBUTTON_RIGHT: case GII_PBUTTON_RIGHT:
......
...@@ -129,10 +129,8 @@ static int CreateVout( vlc_object_t *p_this ) ...@@ -129,10 +129,8 @@ static int CreateVout( vlc_object_t *p_this )
VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
/* Forward events from the opengl provider */ /* Forward events from the opengl provider */
var_Create( p_sys->p_vout, "mouse-x", VLC_VAR_INTEGER ); var_Create( p_sys->p_vout, "mouse-moved", VLC_VAR_COORDS );
var_Create( p_sys->p_vout, "mouse-y", VLC_VAR_INTEGER ); var_Create( p_sys->p_vout, "mouse-clicked", VLC_VAR_COORDS );
var_Create( p_sys->p_vout, "mouse-moved", VLC_VAR_VOID );
var_Create( p_sys->p_vout, "mouse-clicked", VLC_VAR_BOOL );
var_Create( p_sys->p_vout, "mouse-button-down", VLC_VAR_INTEGER ); var_Create( p_sys->p_vout, "mouse-button-down", VLC_VAR_INTEGER );
var_Create( p_sys->p_vout, "video-on-top", var_Create( p_sys->p_vout, "video-on-top",
VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
...@@ -141,8 +139,6 @@ static int CreateVout( vlc_object_t *p_this ) ...@@ -141,8 +139,6 @@ static int CreateVout( vlc_object_t *p_this )
var_Create( p_sys->p_vout, "scale", var_Create( p_sys->p_vout, "scale",
VLC_VAR_FLOAT | VLC_VAR_DOINHERIT ); VLC_VAR_FLOAT | VLC_VAR_DOINHERIT );
var_AddCallback( p_sys->p_vout, "mouse-x", SendEvents, p_vout );
var_AddCallback( p_sys->p_vout, "mouse-y", SendEvents, p_vout );
var_AddCallback( p_sys->p_vout, "mouse-moved", SendEvents, p_vout ); var_AddCallback( p_sys->p_vout, "mouse-moved", SendEvents, p_vout );
var_AddCallback( p_sys->p_vout, "mouse-clicked", SendEvents, p_vout ); var_AddCallback( p_sys->p_vout, "mouse-clicked", SendEvents, p_vout );
var_AddCallback( p_sys->p_vout, "mouse-button-down", SendEvents, p_vout ); var_AddCallback( p_sys->p_vout, "mouse-button-down", SendEvents, p_vout );
......
...@@ -387,13 +387,13 @@ static int ...@@ -387,13 +387,13 @@ static int
mouse_moved( vlc_object_t *p_this, char const *psz_cmd, mouse_moved( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data ) vlc_value_t oldval, vlc_value_t newval, void *p_data )
{ {
VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval); VLC_UNUSED(p_this); VLC_UNUSED(newval); VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval); VLC_UNUSED(p_this);
libvlc_media_player_t *mp = p_data; libvlc_media_player_t *mp = p_data;
libvlc_event_t event; libvlc_event_t event;
event.type = libvlc_MediaPlayerMouseMoved; event.type = libvlc_MediaPlayerMouseMoved;
event.u.media_player_mouse_moved.x = var_GetInteger( mp->p_vout_thread, "mouse-x" ); event.u.media_player_mouse_moved.x = newval.coords.x;
event.u.media_player_mouse_moved.y = var_GetInteger( mp->p_vout_thread, "mouse-y" ); event.u.media_player_mouse_moved.y = newval.coords.y;
libvlc_event_send(mp->p_event_manager, &event); libvlc_event_send(mp->p_event_manager, &event);
return VLC_SUCCESS; return VLC_SUCCESS;
......
...@@ -187,14 +187,13 @@ int libvlc_video_get_width( libvlc_media_player_t *p_mi ) ...@@ -187,14 +187,13 @@ int libvlc_video_get_width( libvlc_media_player_t *p_mi )
} }
int libvlc_video_get_cursor( libvlc_media_player_t *mp, unsigned num, int libvlc_video_get_cursor( libvlc_media_player_t *mp, unsigned num,
int *px, int *py ) int *restrict px, int *restrict py )
{ {
vout_thread_t *p_vout = GetVout (mp, num); vout_thread_t *p_vout = GetVout (mp, num);
if (p_vout == NULL) if (p_vout == NULL)
return -1; return -1;
*px = var_GetInteger (p_vout, "mouse-x"); var_GetCoords (p_vout, "mouse-moved", px, py);
*py = var_GetInteger (p_vout, "mouse-y");
vlc_object_release (p_vout); vlc_object_release (p_vout);
return 0; return 0;
} }
......
...@@ -56,9 +56,7 @@ static inline void vout_SendEventKey(vout_thread_t *vout, int key) ...@@ -56,9 +56,7 @@ static inline void vout_SendEventKey(vout_thread_t *vout, int key)
} }
static inline void vout_SendEventMouseMoved(vout_thread_t *vout, int x, int y) static inline void vout_SendEventMouseMoved(vout_thread_t *vout, int x, int y)
{ {
var_SetInteger(vout, "mouse-x", x); var_SetCoords(vout, "mouse-moved", x, y);
var_SetInteger(vout, "mouse-y", y);
var_TriggerCallback(vout, "mouse-moved");
} }
static inline void vout_SendEventMousePressed(vout_thread_t *vout, int button) static inline void vout_SendEventMousePressed(vout_thread_t *vout, int button)
{ {
...@@ -67,9 +65,14 @@ static inline void vout_SendEventMousePressed(vout_thread_t *vout, int button) ...@@ -67,9 +65,14 @@ static inline void vout_SendEventMousePressed(vout_thread_t *vout, int button)
switch (button) switch (button)
{ {
case MOUSE_BUTTON_LEFT: case MOUSE_BUTTON_LEFT:
var_SetBool(vout, "mouse-clicked", true); {
/* FIXME? */
int x, y;
var_GetCoords(vout, "mouse-moved", &x, &y);
var_SetCoords(vout, "mouse-clicked", x, y);
var_SetBool(vout->p_libvlc, "intf-popupmenu", false); var_SetBool(vout->p_libvlc, "intf-popupmenu", false);
break; break;
}
case MOUSE_BUTTON_CENTER: case MOUSE_BUTTON_CENTER:
var_ToggleBool(vout->p_libvlc, "intf-show"); var_ToggleBool(vout->p_libvlc, "intf-show");
break; break;
......
...@@ -402,11 +402,9 @@ vout_thread_t * vout_Create( vlc_object_t *p_parent, video_format_t *p_fmt ) ...@@ -402,11 +402,9 @@ vout_thread_t * vout_Create( vlc_object_t *p_parent, video_format_t *p_fmt )
vlc_mutex_init( &p_vout->p->vfilter_lock ); vlc_mutex_init( &p_vout->p->vfilter_lock );
/* Mouse coordinates */ /* Mouse coordinates */
var_Create( p_vout, "mouse-x", VLC_VAR_INTEGER );
var_Create( p_vout, "mouse-y", VLC_VAR_INTEGER );
var_Create( p_vout, "mouse-button-down", VLC_VAR_INTEGER ); var_Create( p_vout, "mouse-button-down", VLC_VAR_INTEGER );
var_Create( p_vout, "mouse-moved", VLC_VAR_VOID ); var_Create( p_vout, "mouse-moved", VLC_VAR_COORDS );
var_Create( p_vout, "mouse-clicked", VLC_VAR_BOOL ); var_Create( p_vout, "mouse-clicked", VLC_VAR_COORDS );
/* Mouse object (area of interest in a video filter) */ /* Mouse object (area of interest in a video filter) */
var_Create( p_vout, "mouse-object", VLC_VAR_BOOL ); var_Create( p_vout, "mouse-object", VLC_VAR_BOOL );
......
...@@ -363,11 +363,9 @@ void vout_IntfInit( vout_thread_t *p_vout ) ...@@ -363,11 +363,9 @@ void vout_IntfInit( vout_thread_t *p_vout )
var_AddCallback( p_vout, "video-snapshot", SnapshotCallback, NULL ); var_AddCallback( p_vout, "video-snapshot", SnapshotCallback, NULL );
/* Mouse coordinates */ /* Mouse coordinates */
var_Create( p_vout, "mouse-x", VLC_VAR_INTEGER );
var_Create( p_vout, "mouse-y", VLC_VAR_INTEGER );
var_Create( p_vout, "mouse-button-down", VLC_VAR_INTEGER ); var_Create( p_vout, "mouse-button-down", VLC_VAR_INTEGER );
var_Create( p_vout, "mouse-moved", VLC_VAR_VOID ); var_Create( p_vout, "mouse-moved", VLC_VAR_COORDS );
var_Create( p_vout, "mouse-clicked", VLC_VAR_BOOL ); var_Create( p_vout, "mouse-clicked", VLC_VAR_COORDS );
var_Create( p_vout, "mouse-object", VLC_VAR_BOOL ); var_Create( p_vout, "mouse-object", VLC_VAR_BOOL );
var_Create( p_vout, "intf-change", VLC_VAR_BOOL ); var_Create( p_vout, "intf-change", VLC_VAR_BOOL );
......
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