Commit 0a47ec01 authored by Sam Hocevar's avatar Sam Hocevar

* ./src/video_output/video_output.c: mouse coordinates are now variables.

  * ./modules/access/dvdplay/intf.c: instead of probing the mouse on each
    loop iteration, we set a callback on the corresponding variables.
parent ce7d29b2
......@@ -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 ) );
......
......@@ -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: Stphane 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,8 +102,7 @@ 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;
......@@ -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 )
if( p_intf->p_sys->b_click )
{
control.type = DVDCtrlMouseActivate;
msg_Dbg( p_intf, "Activate coordinates: %dx%d",
p_vout->i_mouse_x, p_vout->i_mouse_y );
p_intf->p_sys->control.type = DVDCtrlMouseActivate;
p_intf->p_sys->b_click = VLC_FALSE;
}
else
{
control.type = DVDCtrlMouseSelect;
msg_Dbg( p_intf, "Select coordinates: %dx%d",
p_vout->i_mouse_x, p_vout->i_mouse_y );
p_intf->p_sys->control.type = DVDCtrlMouseSelect;
p_intf->p_sys->b_move = VLC_FALSE;
}
p_vout->i_mouse_button = 0;
vlc_mutex_unlock( &p_vout->change_lock );
msg_Dbg( p_intf, "send button" );
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, &control );
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 );
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;
}
}
else
{
vlc_mutex_unlock( &p_vout->change_lock );
}
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;
}
vlc_mutex_unlock( &p_intf->change_lock );
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 );
}
/*****************************************************************************
......@@ -266,6 +271,9 @@ static int InitThread( intf_thread_t * p_intf )
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
......@@ -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 );
......
......@@ -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 )
val.i_int = ( xevent.xmotion.x - i_x )
* p_vout->render.i_width / i_width;
p_vout->i_mouse_y = ( xevent.xmotion.y - i_y )
var_Set( p_vout, "mouse-x", val );
val.i_int = ( xevent.xmotion.y - i_y )
* p_vout->render.i_height / i_height;
p_vout->i_mouse_button = 1;
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,10 +681,15 @@ 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 )
val.i_int = ( xevent.xmotion.x - i_x )
* p_vout->render.i_width / i_width;
p_vout->i_mouse_y = ( xevent.xmotion.y - i_y )
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 )
......
......@@ -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" ) )
......
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