]> git.sesse.net Git - vlc/commitdiff
Make mouse-moved and mouse-clicked coordinates, remove mouse-x and -y
authorRémi Denis-Courmont <remi@remlab.net>
Sat, 13 Feb 2010 17:50:51 +0000 (19:50 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Sat, 13 Feb 2010 18:30:11 +0000 (20:30 +0200)
This simplifies callbacks a bit, and fixes a race condition.

21 files changed:
modules/access/dvdnav.c
modules/control/gestures.c
modules/demux/mkv/demux.cpp
modules/gui/macosx/vout.m
modules/gui/macosx/voutgl.m
modules/gui/minimal_macosx/voutagl.m
modules/gui/qt4/components/controller.cpp
modules/video_filter/crop.c
modules/video_filter/deinterlace.c
modules/video_filter/filter_common.h
modules/video_filter/osdmenu.c
modules/video_filter/remoteosd.c
modules/video_filter/transform.c
modules/video_filter/wrapper.c
modules/video_output/ggi.c
modules/video_output/opengl.c
src/control/media_player.c
src/control/video.c
src/video_output/event.h
src/video_output/video_output.c
src/video_output/vout_intf.c

index 2aed51993e65ffabf658bbb83f620dd3c7561a16..c4bb1c61db305b480f0a8c7daaf3a0d97822546e 100644 (file)
@@ -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;
 }
 
index cfc7a37f67588e4b34b1d0fcf061839c8a31a6eb..9305cce64e12aec49895a70a16fdde4d7a65ac65 100644 (file)
@@ -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 )
         {
index aa15ea7c5cd86013629bab11011c57528f24813e..fc2253e08ad5a688c4fce82307d579a8512b1006 100644 (file)
@@ -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;
index d65dbbca7988d93ad2aae885475634cb109c71b4..554b90a2e99821c0511de637f3815972d4e442ba 100644 (file)
@@ -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];
index 4a496cd53c37595cbfa5f574c85b880488142293..7319374e27c82510c401de42a1a245aa068dd117 100644 (file)
@@ -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;
             }
  
index 58f457f2de68ed87967be13b31fde5db04a21d55..7dd2b3907dbd9385798cadc228e0769fa3a38b93 100644 (file)
@@ -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;
             }
  
index 3e03a374084428dfdce9ca32dbaf0940c47614a7..02866ff1235cb9f2d60be6f57ba489ff6f9a00d1 100644 (file)
@@ -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;
 }
index b3342173143b1760d9008c5ada5b55f10b9a1202..b48cd08ed2ce3ca9bd28a234889cf2c8acc5c448 100644 (file)
@@ -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
index 60254eff6253b46c5e61290d24d27b300b84a1ae..af6bb8c606d99b0b3b1496773ded0ebcc36a5530 100644 (file)
@@ -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 );
 }
 
 /*****************************************************************************
index 04097c543ac704f70adcade92d002433db763419..9a0b076825db743b5395f66600208b92f31d5a5c 100644 (file)
@@ -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 );
index 732d1854b3621422edb4e10838334ede7fe6ee7e..377f7407b23d657002931dac12b9d1c0af06c98b 100644 (file)
@@ -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;
 }
index 69bb931c0e2e0320e70d31efa9ef06d5cace6545..98d21f8fbc4108e74f66e0642068f27c3c76ee8c 100644 (file)
@@ -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 );
 
index 82913ecab8f2f57eeb4e03a5370ccece0ace5343..ce62bb2af068ff1b73d92b6ef10fee233649b873 100644 (file)
@@ -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,
index d01527fc880368d31477eef55e87226f529c004d..1dec62f49d3f1f8cb9f08345904e96d263acfef1 100644 (file)
@@ -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 ) )
     {
index af88df0fbf0e510fa6aee657897f98f9ce35da1e..3ec10a7459693bef6b38671d9afd0d08ba9b7aeb 100644 (file)
@@ -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:
index fa1d0486371d0264d9896f8d8939b214531ac9d0..f448356465d2a1f4c8af183bcf2d6384a13b5aba 100644 (file)
@@ -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 );
index ba2c1890f764faafe5a6f88bcbef86a463791d24..6bc0a6ea26e9368ff4b16e3166678d7b532ff739 100644 (file)
@@ -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;
index db90825c92744bdd3e4bbbbe25e959f900f6146b..aac2c653ab92194e14330c853da6754f6eb082d7 100644 (file)
@@ -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;
 }
index bf9087c1633538230f9b6b2ce0585a5631c9a12a..948d317fd14f2902d8356425fa5021773339621b 100644 (file)
@@ -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;
index 2f4bbd71d7eb21650e82795ac4d5cc75df1d27c5..aafb98ba32142589c6bb5c88e26aa5b5625a3113 100644 (file)
@@ -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 );
 
index 93efb3bd96dec56be3d7312775d38a802a51671f..16b635d0e921ad1d9b46a8061c64704b88b8d6eb 100644 (file)
@@ -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 );