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,
/* FIXME? PCI usage thread safe? */
pci_t *pci = dvdnav_get_current_nav_pci( p_sys->dvdnav );
int x = var_GetInteger( p_vout, "mouse-x" );
int y = var_GetInteger( p_vout, "mouse-y" );
int x = val.coords.x;
int y = val.coords.y;
if( psz_var[6] == 'm' ) /* mouse-moved */
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,
ButtonUpdate( p_demux, true );
dvdnav_mouse_activate( p_sys->dvdnav, pci, x, y );
}
(void)oldval; (void)val;
(void)oldval;
return VLC_SUCCESS;
}
......
......@@ -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 )
{
p_sys->i_mouse_x = var_GetInteger( p_sys->p_vout, "mouse-x" );
p_sys->i_mouse_y = var_GetInteger( p_sys->p_vout, "mouse-y" );
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;
......@@ -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 )
{
p_sys->b_button_pressed = true;
p_sys->i_last_x = var_GetInteger( p_sys->p_vout, "mouse-x" );
p_sys->i_last_y = var_GetInteger( p_sys->p_vout, "mouse-y" );
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 )
{
......
......@@ -415,12 +415,11 @@ void * demux_sys_t::EventThread( vlc_object_t *p_this )
/* MOUSE part */
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 );
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 )
{
......@@ -428,7 +427,7 @@ void * demux_sys_t::EventThread( vlc_object_t *p_this )
int32_t best,dist,d;
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;
// get current button
......@@ -438,15 +437,15 @@ void * demux_sys_t::EventThread( vlc_object_t *p_this )
{
btni_t *button_ptr = &(pci->hli.btnit[button-1]);
if(((unsigned)valx.i_int >= button_ptr->x_start)
&& ((unsigned)valx.i_int <= button_ptr->x_end)
&& ((unsigned)valy.i_int >= button_ptr->y_start)
&& ((unsigned)valy.i_int <= button_ptr->y_end))
if(((unsigned)x >= button_ptr->x_start)
&& ((unsigned)x <= button_ptr->x_end)
&& ((unsigned)y >= button_ptr->y_start)
&& ((unsigned)y <= button_ptr->y_end))
{
mx = (button_ptr->x_start + button_ptr->x_end)/2;
my = (button_ptr->y_start + button_ptr->y_end)/2;
dx = mx - valx.i_int;
dy = my - valy.i_int;
dx = mx - x;
dy = my - y;
d = (dx*dx) + (dy*dy);
/* If the mouse is within the button and the mouse is closer
* 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 )
}
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;
......
......@@ -580,7 +580,10 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
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 );
val.i_int &= ~1;
......@@ -646,29 +649,24 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
if( b_inside )
{
vlc_value_t val;
int x, y;
unsigned int i_width, i_height, i_x, i_y;
vout_PlacePicture( p_vout, (unsigned int)s_rect.size.width,
(unsigned int)s_rect.size.height,
&i_x, &i_y, &i_width, &i_height );
val.i_int = ( ((int)ml.x) - i_x ) *
p_vout->render.i_width / i_width;
var_Set( p_vout, "mouse-x", val );
x = (((int)ml.x) - i_x) * p_vout->render.i_width / i_width;
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;
}
else
{
val.i_int = ( ((int)ml.y) - i_y ) *
p_vout->render.i_height / i_height;
y = (((int)ml.y) - i_y) * p_vout->render.i_height / i_height;
}
var_Set( p_vout, "mouse-y", val );
var_TriggerCallback( p_vout, "mouse-moved" );
var_SetCoords( p_vout, "mouse-moved", x, y );
}
if( [self isFullscreen] )
[[[[VLCMain sharedInstance] controls] fspanel] fadeIn];
......
......@@ -976,8 +976,10 @@ static pascal OSStatus WindowEventHandler(EventHandlerCallRef nextHandler, Event
else
{
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 );
val.i_int &= ~1;
......@@ -1017,20 +1019,15 @@ static pascal OSStatus WindowEventHandler(EventHandlerCallRef nextHandler, Event
unsigned int i_x, i_y;
unsigned int i_height = p_vout->p_sys->i_height;
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);
GetEventParameter(event, kEventParamWindowMouseLocation, typeQDPoint, NULL, sizeof(Point), NULL, &ml);
val.i_int = ( ((int)ml.h) - i_x ) *
p_vout->render.i_width / i_width;
var_Set( p_vout, "mouse-x", val );
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" );
x = (((int)ml.h) - i_x) * p_vout->render.i_width / i_width;
y = (((int)ml.v) - i_y) * p_vout->render.i_height / i_height;
var_SetCoords( p_vout, "mouse-moved", x, y );
break;
}
......
......@@ -534,8 +534,10 @@ static pascal OSStatus WindowEventHandler(EventHandlerCallRef nextHandler, Event
else
{
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 );
val.i_int &= ~1;
......@@ -575,20 +577,15 @@ static pascal OSStatus WindowEventHandler(EventHandlerCallRef nextHandler, Event
unsigned int i_x, i_y;
unsigned int i_height = p_vout->p_sys->i_height;
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);
GetEventParameter(event, kEventParamWindowMouseLocation, typeQDPoint, NULL, sizeof(Point), NULL, &ml);
val.i_int = ( ((int)ml.h) - i_x ) *
p_vout->render.i_width / i_width;
var_Set( p_vout, "mouse-x", val );
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" );
x = (((int)ml.h) - i_x) * p_vout->render.i_width / i_width;
y = (((int)ml.v) - i_y) * p_vout->render.i_height / i_height;
var_SetCoords( p_vout, "mouse-moved", x, y );
break;
}
......
......@@ -949,10 +949,7 @@ static int FullscreenControllerWidgetMouseMoved( vlc_object_t *vlc_object, const
FullscreenControllerWidget *p_fs = (FullscreenControllerWidget *)data;
/* Get the value from the Vout - Trust the vout more than Qt */
const int i_mousex = var_GetInteger( p_vout, "mouse-x" );
const int i_mousey = var_GetInteger( p_vout, "mouse-y" );
p_fs->mouseChanged( p_vout, i_mousex, i_mousey );
p_fs->mouseChanged( p_vout, new_val.coords.x, new_val.coords.y );
return VLC_SUCCESS;
}
......
......@@ -831,14 +831,14 @@ static int MouseEvent( vlc_object_t *p_this, char const *psz_var,
vout_thread_t *p_vout = p_data;
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
* FIXME missing lock */
if( !strcmp( psz_var, "mouse-x" ) )
newval.i_int += p_vout->p_sys->i_x;
else if( !strcmp( psz_var, "mouse-y" ) )
newval.i_int += p_vout->p_sys->i_y;
return var_Set( p_vout, psz_var, newval );
newval.coords.x += p_vout->p_sys->i_x;
newval.coords.y += p_vout->p_sys->i_y;
return var_SetChecked( p_vout, psz_var, VLC_VAR_COORDS, newval );
}
#ifdef BEST_AUTOCROP
......
......@@ -494,10 +494,12 @@ static int MouseEvent( vlc_object_t *p_this, char const *psz_var,
vout_thread_t *p_vout = p_data;
VLC_UNUSED(p_this); VLC_UNUSED(oldval);
if( !strcmp( psz_var, "mouse-y" ) && p_vout->p_sys->b_half_height )
newval.i_int *= 2;
if( !strcmp( psz_var, "mouse-button-down" ) )
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,
/* */
if( !pf_mouse_event )
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-clicked", 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 )
p_sys->p_vout = vlc_object_find( p_this, VLC_OBJECT_VOUT, FIND_PARENT );
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",
MouseEvent, p_sys );
}
es_format_Init( &p_filter->fmt_out, SPU_ES, VLC_CODEC_SPU );
p_filter->fmt_out.i_priority = 0;
......@@ -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 "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-visible",
OSDMenuVisibleEvent, p_filter );
}
var_DelCallback( p_sys->p_menu, "osd-menu-update",
OSDMenuUpdateEvent, 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",
MouseEvent, p_sys );
vlc_object_release( p_sys->p_vout );
p_sys->p_vout = NULL;
}
var_Destroy( p_this, OSD_CFG "file-path" );
......@@ -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 "alpha" );
if( p_sys )
{
osd_MenuDelete( p_filter, p_sys->p_menu );
free( p_sys->psz_path );
free( p_sys->psz_file );
free( p_sys );
}
osd_MenuDelete( p_filter, p_sys->p_menu );
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,
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(oldval); VLC_UNUSED(newval);
VLC_UNUSED(oldval);
filter_sys_t *p_sys = (filter_sys_t *)p_data;
vout_thread_t *p_vout = (vout_thread_t*)p_sys->p_vout;
int i_x, i_y;
int i_v;
#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 i_x = newval.coords.x;
int i_y = newval.coords.y;
int v_h = p_vout->output.i_height;
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 )
return VLC_SUCCESS;
if( mouse & MOUSE_CLICKED )
do
{
int i_scale_width, i_scale_height;
osd_button_t *p_button = NULL;
......@@ -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 );
}
}
while(0);
return VLC_SUCCESS;
}
......@@ -1335,10 +1335,8 @@ static int MouseEvent( vlc_object_t *p_this, char const *psz_var,
int i_x, i_y;
int i_v;
i_v = var_GetInteger( p_sys->p_vout, "mouse-button-down" );
i_y = var_GetInteger( p_sys->p_vout, "mouse-y" );
i_x = var_GetInteger( p_sys->p_vout, "mouse-x" );
var_GetCoords( p_sys->p_vout, "mouse-moved", &i_x, &i_y );
vlc_mutex_lock( &p_sys->lock );
......
......@@ -325,59 +325,47 @@ static void Render( vout_thread_t *p_vout, picture_t *p_pic )
* Forward mouse event with proper conversion.
*/
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;
VLC_UNUSED(p_this); VLC_UNUSED(oldval);
/* Translate the mouse coordinates
* 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:
psz_var = "mouse-y";
x = p_vout->p_sys->p_vout->output.i_height - val.coords.y;
y = val.coords.x;
break;
case TRANSFORM_MODE_180:
case TRANSFORM_MODE_HFLIP:
newval.i_int = p_vout->p_sys->p_vout->output.i_width
- newval.i_int;
x = p_vout->p_sys->p_vout->output.i_width - val.coords.x;
y = p_vout->p_sys->p_vout->output.i_height - val.coords.y;
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:
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;
case TRANSFORM_MODE_180:
case TRANSFORM_MODE_VFLIP:
newval.i_int = p_vout->p_sys->p_vout->output.i_height
- newval.i_int;
y = p_vout->p_sys->p_vout->output.i_height - val.coords.y;
break;
case TRANSFORM_MODE_HFLIP:
default:
break;
}
}
return var_Set( p_vout, psz_var, newval );
return var_SetCoords( p_vout, psz_var, x, y );
}
static void FilterPlanar( vout_thread_t *p_vout,
......
......@@ -454,8 +454,7 @@ static int MouseEvent( vlc_object_t *p_this, char const *psz_var,
vlc_mouse_t m;
vlc_mouse_Init( &m );
m.i_x = var_GetInteger( p_vout_src, "mouse-x" );
m.i_y = var_GetInteger( p_vout_src, "mouse-y" );
var_GetCoords( p_vout_src, "mouse-moved", &m.i_x, &m.i_y );
m.i_pressed = var_GetInteger( p_vout_src, "mouse-button-down" );
vlc_mutex_lock( &p_sys->lock );
......@@ -485,9 +484,7 @@ static int MouseEvent( vlc_object_t *p_this, char const *psz_var,
if( vlc_mouse_HasMoved( &omouse, &nmouse ) )
{
var_SetInteger( p_vout, "mouse-x", nmouse.i_x );
var_SetInteger( p_vout, "mouse-y", nmouse.i_y );
var_TriggerCallback( p_vout, "mouse-moved" );
var_SetCoords( p_vout, "mouse-moved", nmouse.i_x, nmouse.i_y );
}
if( vlc_mouse_HasButton( &omouse, &nmouse ) )
{
......
......@@ -303,7 +303,8 @@ static int Manage( vout_thread_t *p_vout )
switch( event.pbutton.button )
{
case GII_PBUTTON_LEFT:
var_SetBool( p_vout, "mouse-clicked", true );
/*FIXME
var_SetCoords( p_vout, "mouse-clicked", x, y );*/
break;
case GII_PBUTTON_RIGHT:
......
......@@ -129,10 +129,8 @@ static int CreateVout( vlc_object_t *p_this )
VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
/* Forward events from the opengl provider */
var_Create( p_sys->p_vout, "mouse-x", VLC_VAR_INTEGER );
var_Create( p_sys->p_vout, "mouse-y", VLC_VAR_INTEGER );
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-moved", VLC_VAR_COORDS );
var_Create( p_sys->p_vout, "mouse-clicked", VLC_VAR_COORDS );
var_Create( p_sys->p_vout, "mouse-button-down", VLC_VAR_INTEGER );
var_Create( p_sys->p_vout, "video-on-top",
VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
......@@ -141,8 +139,6 @@ static int CreateVout( vlc_object_t *p_this )
var_Create( p_sys->p_vout, "scale",
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-clicked", SendEvents, p_vout );
var_AddCallback( p_sys->p_vout, "mouse-button-down", SendEvents, p_vout );
......
......@@ -387,13 +387,13 @@ static int
mouse_moved( vlc_object_t *p_this, char const *psz_cmd,
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_event_t event;
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.y = var_GetInteger( mp->p_vout_thread, "mouse-y" );
event.u.media_player_mouse_moved.x = newval.coords.x;
event.u.media_player_mouse_moved.y = newval.coords.y;
libvlc_event_send(mp->p_event_manager, &event);
return VLC_SUCCESS;
......
......@@ -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 *px, int *py )
int *restrict px, int *restrict py )
{
vout_thread_t *p_vout = GetVout (mp, num);
if (p_vout == NULL)
return -1;
*px = var_GetInteger (p_vout, "mouse-x");
*py = var_GetInteger (p_vout, "mouse-y");
var_GetCoords (p_vout, "mouse-moved", px, py);
vlc_object_release (p_vout);
return 0;
}
......
......@@ -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)
{
var_SetInteger(vout, "mouse-x", x);
var_SetInteger(vout, "mouse-y", y);
var_TriggerCallback(vout, "mouse-moved");
var_SetCoords(vout, "mouse-moved", x, y);
}
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)
{
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);
break;
}
case MOUSE_BUTTON_CENTER:
var_ToggleBool(vout->p_libvlc, "intf-show");
break;
......
......@@ -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 );
/* 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-moved", VLC_VAR_VOID );
var_Create( p_vout, "mouse-clicked", VLC_VAR_BOOL );
var_Create( p_vout, "mouse-moved", VLC_VAR_COORDS );
var_Create( p_vout, "mouse-clicked", VLC_VAR_COORDS );
/* Mouse object (area of interest in a video filter) */
var_Create( p_vout, "mouse-object", VLC_VAR_BOOL );
......
......@@ -363,11 +363,9 @@ void vout_IntfInit( vout_thread_t *p_vout )
var_AddCallback( p_vout, "video-snapshot", SnapshotCallback, NULL );
/* 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-moved", VLC_VAR_VOID );
var_Create( p_vout, "mouse-clicked", VLC_VAR_BOOL );
var_Create( p_vout, "mouse-moved", VLC_VAR_COORDS );
var_Create( p_vout, "mouse-clicked", VLC_VAR_COORDS );
var_Create( p_vout, "mouse-object", 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