]> git.sesse.net Git - vlc/commitdiff
* ./src/video_output/video_output.c: mouse coordinates are now variables.
authorSam Hocevar <sam@videolan.org>
Thu, 17 Oct 2002 16:03:18 +0000 (16:03 +0000)
committerSam Hocevar <sam@videolan.org>
Thu, 17 Oct 2002 16:03:18 +0000 (16:03 +0000)
  * ./modules/access/dvdplay/intf.c: instead of probing the mouse on each
    loop iteration, we set a callback on the corresponding variables.

include/video_output.h
modules/access/dvdplay/intf.c
modules/video_output/x11/xcommon.c
src/video_output/video_output.c

index 71e577661d3d457cfd2d9150797b6182f308906c..c6ae12e4312c30ba3dbda31a6e2b5494a0783705 100644 (file)
@@ -5,7 +5,7 @@
  * thread, and destroy a previously opened video output thread.
  *****************************************************************************
  * Copyright (C) 1999, 2000 VideoLAN
- * $Id: video_output.h,v 1.83 2002/08/08 00:35:10 sam Exp $
+ * $Id: video_output.h,v 1.84 2002/10/17 16:03:18 sam Exp $
  *
  * Authors: Vincent Seguin <seguin@via.ecp.fr>
  *          Samuel Hocevar <sam@via.ecp.fr>
@@ -50,25 +50,6 @@ typedef struct vout_chroma_t
 
 } vout_chroma_t;
 
-/*****************************************************************************
- * vout_fifo_t
- *****************************************************************************/
-typedef struct vout_fifo_t
-{
-    /* See the fifo types below */
-    int                 i_type;
-    vlc_bool_t          b_die;
-    int                 i_fifo;      /* Just to keep track of the fifo index */
-
-    vlc_mutex_t         data_lock;
-    vlc_cond_t          data_wait;
-
-} vout_fifo_t;
-
-#define VOUT_EMPTY_FIFO         0
-#define VOUT_YUV_FIFO           1
-#define VOUT_SPU_FIFO           2
-
 /*****************************************************************************
  * vout_thread_t: video output thread descriptor
  *****************************************************************************
@@ -133,9 +114,6 @@ struct vout_thread_t
     count_t             c_jitter_samples;  /* number of samples used for the *
                                             * calculation of the jitter      */
 
-    /* Mouse */
-    int                 i_mouse_x, i_mouse_y, i_mouse_button;
-
     /* Filter chain */
     char *psz_filter_chain;
 };
@@ -167,10 +145,6 @@ struct vout_thread_t
 VLC_EXPORT( vout_thread_t *, __vout_CreateThread,   ( vlc_object_t *, int, int, u32, int ) );
 VLC_EXPORT( void,              vout_DestroyThread,  ( vout_thread_t * ) );
 
-vout_fifo_t *   vout_CreateFifo     ( void );
-void            vout_DestroyFifo    ( vout_fifo_t * );
-void            vout_FreeFifo       ( vout_fifo_t * );
-
 VLC_EXPORT( int,             vout_ChromaCmp,      ( u32, u32 ) );
 
 VLC_EXPORT( picture_t *,     vout_CreatePicture,  ( vout_thread_t *, vlc_bool_t, vlc_bool_t, vlc_bool_t ) );
index 7c10f201adbbbadef28338dc465b02bf4d4d82f9..38f0a5f75e3cef6b33992f8c1e0de928a4805f12 100644 (file)
@@ -2,7 +2,7 @@
  * intf.c: interface for DVD video manager
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: intf.c,v 1.1 2002/08/04 17:23:42 sam Exp $
+ * $Id: intf.c,v 1.2 2002/10/17 16:03:18 sam Exp $
  *
  * Authors: Stéphane Borel <stef@via.ecp.fr>
  *
@@ -34,9 +34,6 @@
 #include "stream_control.h"
 #include "input_ext-intf.h"
 
-#include "video.h"
-#include "video_output.h"
-
 #include "dvd.h"
 
 /*****************************************************************************
@@ -51,12 +48,16 @@ struct intf_sys_t
     vlc_bool_t          b_inf_still;
     mtime_t             m_still_time;
 
+    dvdplay_ctrl_t      control;
+    vlc_bool_t          b_click, b_move;
 };
 
 /*****************************************************************************
  * Local prototypes.
  *****************************************************************************/
 static int  InitThread     ( intf_thread_t *p_intf );
+static int  MouseEvent     ( vlc_object_t *, char const *,
+                             vlc_value_t, vlc_value_t, void * );
 
 /* Exported functions */
 static void RunIntf        ( intf_thread_t *p_intf );
@@ -101,11 +102,10 @@ void E_(CloseIntf) ( vlc_object_t *p_this )
  *****************************************************************************/
 static void RunIntf( intf_thread_t *p_intf )
 {
-    vout_thread_t *     p_vout;
-    dvdplay_ctrl_t      control;
+    vlc_object_t *      p_vout = NULL;
     mtime_t             mtime = 0;
     mtime_t             mlast = 0;
-    
+
     if( InitThread( p_intf ) < 0 )
     {
         msg_Err( p_intf, "can't initialize intf" );
@@ -113,10 +113,6 @@ static void RunIntf( intf_thread_t *p_intf )
     }
     msg_Dbg( p_intf, "intf initialized" );
 
-    p_vout = NULL;
-    control.mouse.i_x = 0;
-    control.mouse.i_y = 0;
-    
     /* Main loop */
     while( !p_intf->b_die )
     {
@@ -173,76 +169,85 @@ static void RunIntf( intf_thread_t *p_intf )
         /* 
          * mouse cursor
          */
-        p_vout = vlc_object_find( p_intf->p_sys->p_input,
-                                  VLC_OBJECT_VOUT, FIND_CHILD );
-        if( p_vout != NULL )
+        if( p_vout && ( p_intf->p_sys->b_click || p_intf->p_sys->b_move ) )
         {
-            vlc_mutex_lock( &p_vout->change_lock );
+            vlc_value_t val;
+            int i_activate;
 
-            if( control.mouse.i_x != p_vout->i_mouse_x ||
-                control.mouse.i_y != p_vout->i_mouse_y ||
-                p_vout->i_mouse_button )
-            {
-                int i_activate = 0;
-                
-                control.mouse.i_x = p_vout->i_mouse_x;
-                control.mouse.i_y = p_vout->i_mouse_y;
+            var_Get( p_vout, "mouse-x", &val );
+            p_intf->p_sys->control.mouse.i_x = val.i_int;
+            var_Get( p_vout, "mouse-y", &val );
+            p_intf->p_sys->control.mouse.i_y = val.i_int;
 
-                if( p_vout->i_mouse_button )
-                {
-                    control.type = DVDCtrlMouseActivate;
-                    
-                    msg_Dbg( p_intf, "Activate coordinates: %dx%d",
-                                 p_vout->i_mouse_x, p_vout->i_mouse_y );
-                }
-                else
-                {
-                    control.type = DVDCtrlMouseSelect;
-                    
-                    msg_Dbg( p_intf, "Select coordinates: %dx%d",
-                                 p_vout->i_mouse_x, p_vout->i_mouse_y );
-                }
-                p_vout->i_mouse_button = 0;
-                vlc_mutex_unlock( &p_vout->change_lock );
-                
-                msg_Dbg( p_intf, "send button" );
-                
-                /* we can safely interact with libdvdplay
-                 * with the stream lock */
-                vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
-                
-                i_activate =
-                    dvdplay_button( p_intf->p_sys->p_dvd->vmg, &control );
-                  
-                vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
-                
-
-                if( i_activate && p_intf->p_sys->b_still )
-                {
-                    input_SetStatus( p_intf->p_sys->p_input,
-                                     INPUT_STATUS_PLAY );
-                    p_intf->p_sys->b_still = 0;
-                    p_intf->p_sys->b_inf_still = 0;
-                    p_intf->p_sys->m_still_time = 0;
-                }
+            if( p_intf->p_sys->b_click )
+            {
+                p_intf->p_sys->control.type = DVDCtrlMouseActivate;
+                p_intf->p_sys->b_click = VLC_FALSE;
             }
             else
             {
-                vlc_mutex_unlock( &p_vout->change_lock );
+                p_intf->p_sys->control.type = DVDCtrlMouseSelect;
+                p_intf->p_sys->b_move = VLC_FALSE;
             }
-            
 
-            vlc_object_release( p_vout );
+            msg_Dbg( p_intf, "send button coordinates: %dx%d",
+                             p_intf->p_sys->control.mouse.i_x,
+                             p_intf->p_sys->control.mouse.i_y );
+
+            /* we can safely interact with libdvdplay
+             * with the stream lock */
+            vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
+
+            i_activate = dvdplay_button( p_intf->p_sys->p_dvd->vmg,
+                                         &p_intf->p_sys->control );
+
+            vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
+
+            if( i_activate && p_intf->p_sys->b_still )
+            {
+                input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY );
+                p_intf->p_sys->b_still = 0;
+                p_intf->p_sys->b_inf_still = 0;
+                p_intf->p_sys->m_still_time = 0;
+            }
         }
-            
+
         vlc_mutex_unlock( &p_intf->change_lock );
-          
+
+        /* 
+         * video output
+         */
+        if( p_vout && p_vout->b_die )
+        {
+            var_DelCallback( p_vout, "mouse-moved", MouseEvent, p_intf );
+            var_DelCallback( p_vout, "mouse-clicked", MouseEvent, p_intf );
+            vlc_object_release( p_vout );
+            p_vout = NULL;
+        }
+
+        if( p_vout == NULL )
+        {
+            p_vout = vlc_object_find( p_intf->p_sys->p_input,
+                                      VLC_OBJECT_VOUT, FIND_CHILD );
+            if( p_vout )
+            {
+                var_AddCallback( p_vout, "mouse-moved", MouseEvent, p_intf );
+                var_AddCallback( p_vout, "mouse-clicked", MouseEvent, p_intf );
+            }
+        }
+
         /* Wait a bit */
         msleep( INTF_IDLE_SLEEP );
     }
-    
-    vlc_object_release( p_intf->p_sys->p_input );
 
+    if( p_vout )
+    {
+        var_DelCallback( p_vout, "mouse-moved", MouseEvent, p_intf );
+        var_DelCallback( p_vout, "mouse-clicked", MouseEvent, p_intf );
+        vlc_object_release( p_vout );
+    }
+
+    vlc_object_release( p_intf->p_sys->p_input );
 }
 
 /*****************************************************************************
@@ -255,17 +260,20 @@ static int InitThread( intf_thread_t * p_intf )
     {
         input_thread_t * p_input;
         dvd_data_t * p_dvd;
-        
+
         p_input = vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_PARENT );
         p_dvd = (dvd_data_t*)p_input->p_access_data;
 
         p_dvd->p_intf = p_intf;
-                    
+
         vlc_mutex_lock( &p_intf->change_lock );
-    
+
         p_intf->p_sys->p_input = p_input;
         p_intf->p_sys->p_dvd = p_dvd;
 
+        p_intf->p_sys->b_move = VLC_FALSE;
+        p_intf->p_sys->b_click = VLC_FALSE;
+
         vlc_mutex_unlock( &p_intf->change_lock );
 
         return 0;
@@ -276,6 +284,30 @@ static int InitThread( intf_thread_t * p_intf )
     }
 }
 
+/*****************************************************************************
+ * MouseEvent: callback for mouse events
+ *****************************************************************************/
+static int MouseEvent( vlc_object_t *p_this, char const *psz_var,
+                       vlc_value_t oldval, vlc_value_t newval, void *p_data )
+{
+    intf_thread_t *p_intf = (intf_thread_t *)p_data;
+
+    vlc_mutex_lock( &p_intf->change_lock );
+
+    if( psz_var[6] == 'c' ) /* "mouse-clicked" */
+    {
+        p_intf->p_sys->b_click = VLC_TRUE;
+    }
+    else if( psz_var[6] == 'm' ) /* "mouse-moved" */
+    {
+        p_intf->p_sys->b_move = VLC_TRUE;
+    }
+
+    vlc_mutex_unlock( &p_intf->change_lock );
+
+    return VLC_SUCCESS;
+}
+
 /*****************************************************************************
  * dvdIntfStillTime: function provided to demux plugin to request
  * still images
@@ -284,7 +316,7 @@ int dvdIntfStillTime( intf_thread_t *p_intf, int i_sec )
 {
     vlc_mutex_lock( &p_intf->change_lock );
 #if 1
-    
+
     if( i_sec == 0xff )
     {
         p_intf->p_sys->b_still = 1;
@@ -307,7 +339,6 @@ int dvdIntfStillTime( intf_thread_t *p_intf, int i_sec )
         {
             p_intf->p_sys->m_still_time = 1000000 * i_sec;
         }
-        
     }
 #endif
     vlc_mutex_unlock( &p_intf->change_lock );
index f68fb51051e1326258b989efbec517ca454f1ef0..e1585f5414796131e44e7821470eaf8db85370ea 100644 (file)
@@ -2,7 +2,7 @@
  * xcommon.c: Functions common to the X11 and XVideo plugins
  *****************************************************************************
  * Copyright (C) 1998-2001 VideoLAN
- * $Id: xcommon.c,v 1.4 2002/09/10 12:15:07 sam Exp $
+ * $Id: xcommon.c,v 1.5 2002/10/17 16:03:18 sam Exp $
  *
  * Authors: Vincent Seguin <seguin@via.ecp.fr>
  *          Samuel Hocevar <sam@zoy.org>
@@ -607,16 +607,21 @@ static int ManageVideo( vout_thread_t *p_vout )
         else if( xevent.type == ButtonPress )
         {
             int i_width, i_height, i_x, i_y;
+            vlc_value_t val;
 
             vout_PlacePicture( p_vout, p_vout->p_sys->p_win->i_width,
                                p_vout->p_sys->p_win->i_height,
                                &i_x, &i_y, &i_width, &i_height );
 
-            p_vout->i_mouse_x = ( xevent.xmotion.x - i_x )
-                * p_vout->render.i_width / i_width;
-            p_vout->i_mouse_y = ( xevent.xmotion.y - i_y )
-                * p_vout->render.i_height / i_height;
-            p_vout->i_mouse_button = 1;
+            val.i_int = ( xevent.xmotion.x - i_x )
+                         * p_vout->render.i_width / i_width;
+            var_Set( p_vout, "mouse-x", val );
+            val.i_int = ( xevent.xmotion.y - i_y )
+                         * p_vout->render.i_height / i_height;
+            var_Set( p_vout, "mouse-y", val );
+
+            val.b_bool = VLC_TRUE;
+            var_Set( p_vout, "mouse-clicked", val );
 
             switch( ((XButtonEvent *)&xevent)->button )
             {
@@ -667,6 +672,7 @@ static int ManageVideo( vout_thread_t *p_vout )
         else if( xevent.type == MotionNotify )
         {
             int i_width, i_height, i_x, i_y;
+            vlc_value_t val;
 
             /* somewhat different use for vout_PlacePicture:
              * here the values are needed to give to mouse coordinates
@@ -675,11 +681,16 @@ static int ManageVideo( vout_thread_t *p_vout )
                                p_vout->p_sys->p_win->i_height,
                                &i_x, &i_y, &i_width, &i_height );
 
-            p_vout->i_mouse_x = ( xevent.xmotion.x - i_x )
-                * p_vout->render.i_width / i_width;
-            p_vout->i_mouse_y = ( xevent.xmotion.y - i_y )
-                * p_vout->render.i_height / i_height;
+            val.i_int = ( xevent.xmotion.x - i_x )
+                         * p_vout->render.i_width / i_width;
+            var_Set( p_vout, "mouse-x", val );
+            val.i_int = ( xevent.xmotion.y - i_y )
+                         * p_vout->render.i_height / i_height;
+            var_Set( p_vout, "mouse-y", val );
+
+            val.b_bool = VLC_TRUE;
+            var_Set( p_vout, "mouse-moved", val );
+
             p_vout->p_sys->i_time_mouse_last_moved = mdate();
             if( ! p_vout->p_sys->b_mouse_pointer_visible )
             {
index ad727c3b6f5eb715b27c4f5a55f491c82fba1270..652c36d3aadccc416bf537117bdbf82fbb6d7655 100644 (file)
@@ -5,7 +5,7 @@
  * thread, and destroy a previously oppened video output thread.
  *****************************************************************************
  * Copyright (C) 2000-2001 VideoLAN
- * $Id: video_output.c,v 1.192 2002/10/17 08:24:12 sam Exp $
+ * $Id: video_output.c,v 1.193 2002/10/17 16:03:18 sam Exp $
  *
  * Authors: Vincent Seguin <seguin@via.ecp.fr>
  *
@@ -165,9 +165,11 @@ vout_thread_t * __vout_CreateThread ( vlc_object_t *p_parent,
     p_vout->render_time  = 10;
     p_vout->c_fps_samples= 0;
 
-    p_vout->i_mouse_x = 0;
-    p_vout->i_mouse_y = 0;
-    p_vout->i_mouse_button = 0;
+    /* 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-moved", VLC_VAR_BOOL );
+    var_Create( p_vout, "mouse-clicked", VLC_VAR_INTEGER );
 
     /* user requested fullscreen? */
     if( config_GetInt( p_vout, "fullscreen" ) )