From 4a95265a63091fee2bd7ef99ababec5ff0090b6d Mon Sep 17 00:00:00 2001 From: =?utf8?q?R=C3=A9mi=20Denis-Courmont?= Date: Sat, 13 Feb 2010 19:50:51 +0200 Subject: [PATCH] Make mouse-moved and mouse-clicked coordinates, remove mouse-x and -y This simplifies callbacks a bit, and fixes a race condition. --- modules/access/dvdnav.c | 7 ++- modules/control/gestures.c | 8 +-- modules/demux/mkv/demux.cpp | 21 ++++---- modules/gui/macosx/vout.m | 20 ++++--- modules/gui/macosx/voutgl.m | 17 +++--- modules/gui/minimal_macosx/voutagl.m | 17 +++--- modules/gui/qt4/components/controller.cpp | 5 +- modules/video_filter/crop.c | 12 ++--- modules/video_filter/deinterlace.c | 8 +-- modules/video_filter/filter_common.h | 2 - modules/video_filter/osdmenu.c | 63 +++++------------------ modules/video_filter/remoteosd.c | 4 +- modules/video_filter/transform.c | 50 +++++++----------- modules/video_filter/wrapper.c | 7 +-- modules/video_output/ggi.c | 3 +- modules/video_output/opengl.c | 8 +-- src/control/media_player.c | 6 +-- src/control/video.c | 5 +- src/video_output/event.h | 11 ++-- src/video_output/video_output.c | 6 +-- src/video_output/vout_intf.c | 6 +-- 21 files changed, 108 insertions(+), 178 deletions(-) diff --git a/modules/access/dvdnav.c b/modules/access/dvdnav.c index 2aed51993e..c4bb1c61db 100644 --- a/modules/access/dvdnav.c +++ b/modules/access/dvdnav.c @@ -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; } diff --git a/modules/control/gestures.c b/modules/control/gestures.c index cfc7a37f67..9305cce64e 100644 --- a/modules/control/gestures.c +++ b/modules/control/gestures.c @@ -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 ) { diff --git a/modules/demux/mkv/demux.cpp b/modules/demux/mkv/demux.cpp index aa15ea7c5c..fc2253e08a 100644 --- a/modules/demux/mkv/demux.cpp +++ b/modules/demux/mkv/demux.cpp @@ -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; diff --git a/modules/gui/macosx/vout.m b/modules/gui/macosx/vout.m index d65dbbca79..554b90a2e9 100644 --- a/modules/gui/macosx/vout.m +++ b/modules/gui/macosx/vout.m @@ -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]; diff --git a/modules/gui/macosx/voutgl.m b/modules/gui/macosx/voutgl.m index 4a496cd53c..7319374e27 100644 --- a/modules/gui/macosx/voutgl.m +++ b/modules/gui/macosx/voutgl.m @@ -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; } diff --git a/modules/gui/minimal_macosx/voutagl.m b/modules/gui/minimal_macosx/voutagl.m index 58f457f2de..7dd2b3907d 100644 --- a/modules/gui/minimal_macosx/voutagl.m +++ b/modules/gui/minimal_macosx/voutagl.m @@ -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; } diff --git a/modules/gui/qt4/components/controller.cpp b/modules/gui/qt4/components/controller.cpp index 3e03a37408..02866ff123 100644 --- a/modules/gui/qt4/components/controller.cpp +++ b/modules/gui/qt4/components/controller.cpp @@ -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; } diff --git a/modules/video_filter/crop.c b/modules/video_filter/crop.c index b334217314..b48cd08ed2 100644 --- a/modules/video_filter/crop.c +++ b/modules/video_filter/crop.c @@ -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 diff --git a/modules/video_filter/deinterlace.c b/modules/video_filter/deinterlace.c index 60254eff62..af6bb8c606 100644 --- a/modules/video_filter/deinterlace.c +++ b/modules/video_filter/deinterlace.c @@ -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 ); } /***************************************************************************** diff --git a/modules/video_filter/filter_common.h b/modules/video_filter/filter_common.h index 04097c543a..9a0b076825 100644 --- a/modules/video_filter/filter_common.h +++ b/modules/video_filter/filter_common.h @@ -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 ); diff --git a/modules/video_filter/osdmenu.c b/modules/video_filter/osdmenu.c index 732d1854b3..377f7407b2 100644 --- a/modules/video_filter/osdmenu.c +++ b/modules/video_filter/osdmenu.c @@ -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; } diff --git a/modules/video_filter/remoteosd.c b/modules/video_filter/remoteosd.c index 69bb931c0e..98d21f8fbc 100644 --- a/modules/video_filter/remoteosd.c +++ b/modules/video_filter/remoteosd.c @@ -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 ); diff --git a/modules/video_filter/transform.c b/modules/video_filter/transform.c index 82913ecab8..ce62bb2af0 100644 --- a/modules/video_filter/transform.c +++ b/modules/video_filter/transform.c @@ -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, diff --git a/modules/video_filter/wrapper.c b/modules/video_filter/wrapper.c index d01527fc88..1dec62f49d 100644 --- a/modules/video_filter/wrapper.c +++ b/modules/video_filter/wrapper.c @@ -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 ) ) { diff --git a/modules/video_output/ggi.c b/modules/video_output/ggi.c index af88df0fbf..3ec10a7459 100644 --- a/modules/video_output/ggi.c +++ b/modules/video_output/ggi.c @@ -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: diff --git a/modules/video_output/opengl.c b/modules/video_output/opengl.c index fa1d048637..f448356465 100644 --- a/modules/video_output/opengl.c +++ b/modules/video_output/opengl.c @@ -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 ); diff --git a/src/control/media_player.c b/src/control/media_player.c index ba2c1890f7..6bc0a6ea26 100644 --- a/src/control/media_player.c +++ b/src/control/media_player.c @@ -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; diff --git a/src/control/video.c b/src/control/video.c index db90825c92..aac2c653ab 100644 --- a/src/control/video.c +++ b/src/control/video.c @@ -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; } diff --git a/src/video_output/event.h b/src/video_output/event.h index bf9087c163..948d317fd1 100644 --- a/src/video_output/event.h +++ b/src/video_output/event.h @@ -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; diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c index 2f4bbd71d7..aafb98ba32 100644 --- a/src/video_output/video_output.c +++ b/src/video_output/video_output.c @@ -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 ); diff --git a/src/video_output/vout_intf.c b/src/video_output/vout_intf.c index 93efb3bd96..16b635d0e9 100644 --- a/src/video_output/vout_intf.c +++ b/src/video_output/vout_intf.c @@ -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 ); -- 2.39.2