int i_width;
int i_height;
+#if SDL_VERSION_ATLEAST(1,2,10)
unsigned int i_desktop_width;
unsigned int i_desktop_height;
+#endif
/* For YUV output */
SDL_Overlay * p_overlay; /* An overlay we keep to grab the XVideo port */
vlc_bool_t b_cursor_autohidden;
mtime_t i_lastmoved;
mtime_t i_lastpressed; /* to track dbl-clicks */
-
- vlc_mutex_t lock;
};
/*****************************************************************************
return VLC_ENOMEM;
}
- vlc_mutex_init( p_vout, &p_vout->p_sys->lock );
-
/* Check if SDL video module has been initialized */
if( SDL_WasInit( SDL_INIT_VIDEO ) != 0 )
{
p_vout->pf_manage = Manage;
p_vout->pf_render = NULL;
p_vout->pf_display = Display;
+ p_vout->pf_control = NULL;
#ifdef HAVE_SETENV
psz_method = config_GetPsz( p_vout, "vout" );
SDL_EnableUNICODE(1);
/* Get the desktop resolution */
+#if SDL_VERSION_ATLEAST(1,2,10)
+ /* FIXME: SDL has a problem with virtual desktop */
p_vout->p_sys->i_desktop_width = SDL_GetVideoInfo()->current_w;
p_vout->p_sys->i_desktop_height = SDL_GetVideoInfo()->current_h;
+#endif
+ /* Create the cursor */
p_vout->p_sys->b_cursor = 1;
p_vout->p_sys->b_cursor_autohidden = 0;
- p_vout->p_sys->i_lastmoved = mdate();
+ p_vout->p_sys->i_lastmoved = p_vout->p_sys->i_lastpressed = mdate();
if( OpenDisplay( p_vout ) )
{
CloseDisplay( p_vout );
SDL_QuitSubSystem( SDL_INIT_VIDEO );
- vlc_mutex_destroy( &p_vout->p_sys->lock );
-
free( p_vout->p_sys );
}
vlc_value_t val;
unsigned int i_width, i_height, i_x, i_y;
- vlc_mutex_lock( &p_vout->p_sys->lock );
-
/* Process events */
while( SDL_PollEvent( &event ) )
{
switch( event.type )
{
- case SDL_VIDEORESIZE: /* Resizing of window */
- /* Update dimensions */
+ /* Resizing of window */
+ case SDL_VIDEORESIZE:
p_vout->i_changes |= VOUT_SIZE_CHANGE;
p_vout->i_window_width = p_vout->p_sys->i_width = event.resize.w;
p_vout->i_window_height = p_vout->p_sys->i_height = event.resize.h;
p_vout->p_sys->i_height,
&i_x, &i_y, &i_width, &i_height );
- val.i_int = ( event.motion.x - i_x )
- * p_vout->render.i_width / i_width;
+ /* Compute the x coordinate and check if the value is
+ in [0,p_vout->fmt_in.i_visible_width] */
+ val.i_int = ( event.motion.x - i_x ) *
+ p_vout->fmt_in.i_visible_width / i_width +
+ p_vout->fmt_in.i_x_offset;
+
+ if( (int)(event.motion.x - i_x) < 0 )
+ val.i_int = 0;
+ else if( (unsigned int)val.i_int > p_vout->fmt_in.i_visible_width )
+ val.i_int = p_vout->fmt_in.i_visible_width;
+
var_Set( p_vout, "mouse-x", val );
- val.i_int = ( event.motion.y - i_y )
- * p_vout->render.i_height / i_height;
+
+ /* compute the y coordinate and check if the value is
+ in [0,p_vout->fmt_in.i_visible_height] */
+ val.i_int = ( event.motion.y - i_y ) *
+ p_vout->fmt_in.i_visible_height / i_height +
+ p_vout->fmt_in.i_y_offset;
+
+ if( (int)(event.motion.y - i_y) < 0 )
+ val.i_int = 0;
+ else if( (unsigned int)val.i_int > p_vout->fmt_in.i_visible_height )
+ val.i_int = p_vout->fmt_in.i_visible_height;
+
var_Set( p_vout, "mouse-y", val );
val.b_bool = VLC_TRUE;
var_Set( p_vout, "mouse-moved", val );
- if( p_vout->p_sys->b_cursor &&
- (abs(event.motion.xrel) > 2 || abs(event.motion.yrel) > 2) )
+ if( p_vout->p_sys->b_cursor )
{
if( p_vout->p_sys->b_cursor_autohidden )
{
/* Key pressed */
case SDL_KEYDOWN:
+ /* convert the key if possible */
val.i_int = ConvertKey( event.key.keysym.sym );
if( !val.i_int )
{
+ /* Find the right caracter */
if( ( event.key.keysym.unicode & 0xff80 ) == 0 )
{
val.i_int = event.key.keysym.unicode & 0x7f;
+ /* FIXME: find a better solution than this
+ hack to find the right caracter */
+ if( val.i_int >= 1 && val.i_int <= 26 )
+ val.i_int += 96;
+ else if( val.i_int >= 65 && val.i_int <= 90 )
+ val.i_int += 32;
}
}
SDL_ShowCursor( 0 );
}
- vlc_mutex_unlock( &p_vout->p_sys->lock );
-
return VLC_SUCCESS;
}
unsigned int x, y, w, h;
SDL_Rect disp;
- vlc_mutex_lock( &p_vout->p_sys->lock );
-
vout_PlacePicture( p_vout, p_vout->p_sys->i_width, p_vout->p_sys->i_height,
&x, &y, &w, &h );
disp.x = x;
SDL_DisplayYUVOverlay( p_pic->p_sys->p_overlay , &disp );
SDL_LockYUVOverlay( p_pic->p_sys->p_overlay);
}
-
- vlc_mutex_unlock( &p_vout->p_sys->lock );
}
/* following functions are local */
uint32_t i_chroma = 0;
/* Set main window's size */
+#if SDL_VERSION_ATLEAST(1,2,10)
p_vout->p_sys->i_width = p_vout->b_fullscreen ? p_vout->p_sys->i_desktop_width :
p_vout->i_window_width;
p_vout->p_sys->i_height = p_vout->b_fullscreen ? p_vout->p_sys->i_desktop_height :
p_vout->i_window_height;
+#else
+ p_vout->p_sys->i_width = p_vout->b_fullscreen ? p_vout->output.i_width :
+ p_vout->i_window_width;
+ p_vout->p_sys->i_height = p_vout->b_fullscreen ? p_vout->output.i_height :
+ p_vout->i_window_height;
+#endif
/* Initialize flags and cursor */
i_flags = SDL_ANYFORMAT | SDL_HWPALETTE | SDL_HWSURFACE | SDL_DOUBLEBUF;
}
p_vout->p_sys->p_display = SDL_SetVideoMode( p_vout->p_sys->i_width,
- p_vout->p_sys->i_height,
- i_bpp, i_flags );
+ p_vout->p_sys->i_height,
+ i_bpp, i_flags );
if( p_vout->p_sys->p_display == NULL )
{