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 */
return VLC_ENOMEM;
}
+ /* Check if SDL video module has been initialized */
if( SDL_WasInit( SDL_INIT_VIDEO ) != 0 )
{
vlc_mutex_unlock( lock );
}
/* Allocate structure */
-
p_vout->pf_init = Init;
p_vout->pf_end = End;
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" );
return VLC_EGENERIC;
}
+ vlc_mutex_unlock( lock );
+
/* Translate keys into unicode */
SDL_EnableUNICODE(1);
- vlc_mutex_unlock( lock );
+ /* 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 ) )
{
{
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 )
{
}
break;
- /* Mouse button pressed */
+ /* Mouse button released */
case SDL_MOUSEBUTTONUP:
switch( event.button.button )
{
}
break;
- /* Mouse button released */
+ /* Mouse button pressed */
case SDL_MOUSEBUTTONDOWN:
switch( event.button.button )
{
/* 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;
}
}
p_vout->b_fullscreen = !p_vout->b_fullscreen;
var_Set( p_vout, "fullscreen", val_fs );
- /*TODO: add the always on top code !*/
+ /*TODO: add the "always on top" code here !*/
p_vout->p_sys->b_cursor_autohidden = 0;
SDL_ShowCursor( p_vout->p_sys->b_cursor &&
p_vout->i_changes |= VOUT_SIZE_CHANGE;
}
+ /* Crop or Aspect Ratio Changes */
+ if( p_vout->i_changes & VOUT_CROP_CHANGE ||
+ p_vout->i_changes & VOUT_ASPECT_CHANGE )
+ {
+ p_vout->i_changes &= ~VOUT_CROP_CHANGE;
+ p_vout->i_changes &= ~VOUT_ASPECT_CHANGE;
+
+ p_vout->fmt_out.i_x_offset = p_vout->fmt_in.i_x_offset;
+ p_vout->fmt_out.i_y_offset = p_vout->fmt_in.i_y_offset;
+ p_vout->fmt_out.i_visible_width = p_vout->fmt_in.i_visible_width;
+ p_vout->fmt_out.i_visible_height = p_vout->fmt_in.i_visible_height;
+ p_vout->fmt_out.i_aspect = p_vout->fmt_in.i_aspect;
+ p_vout->fmt_out.i_sar_num = p_vout->fmt_in.i_sar_num;
+ p_vout->fmt_out.i_sar_den = p_vout->fmt_in.i_sar_den;
+ p_vout->output.i_aspect = p_vout->fmt_in.i_aspect;
+
+ p_vout->i_changes |= VOUT_SIZE_CHANGE;
+ }
+
/* Size change */
if( p_vout->i_changes & VOUT_SIZE_CHANGE )
{
* we can handle rescaling ourselves */
if( p_vout->p_sys->p_overlay != NULL )
p_vout->i_changes &= ~VOUT_SIZE_CHANGE;
-
}
/* Pointer change */
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;