Commit 3ea3f9ff authored by Damien Lucas's avatar Damien Lucas

. Mouse pointer hidden/shown with middle button in SDL output

. Default is shown.
. Default in fullscreen is hidden.
parent 3e22bc68
......@@ -2,7 +2,7 @@
* intf_sdl.c: SDL interface plugin
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: intf_sdl.c,v 1.24 2001/01/31 03:42:39 sam Exp $
* $Id: intf_sdl.c,v 1.25 2001/02/05 15:50:57 nitrox Exp $
*
* Authors:
*
......@@ -59,8 +59,10 @@ typedef struct vout_sys_s
SDL_Overlay * p_overlay;
boolean_t b_fullscreen;
boolean_t b_overlay;
boolean_t b_cursor; /* 1 if hide 0 else */
boolean_t b_reopen_display;
boolean_t b_toggle_fullscreen;
boolean_t b_hide_cursor;
Uint8 * p_buffer[2];
/* Buffers informations */
} vout_sys_t;
......@@ -71,7 +73,7 @@ void intf_SDL_Keymap( intf_thread_t * p_intf );
void intf_SDL_Resize( intf_thread_t * p_intf, int width, int height );
void intf_SDL_Fullscreen(intf_thread_t * p_intf);
void intf_SDL_YUVSwitch(intf_thread_t * p_intf);
void intf_SDL_Hidecursor(intf_thread_t * p_intf);
/*****************************************************************************
* intf_SDLCreate: initialize and create SDL interface
......@@ -139,13 +141,12 @@ void intf_SDLManage( intf_thread_t *p_intf )
while ( SDL_PollEvent(&event) )
{
i_key = event.key.keysym.sym; /* forward it */
switch (event.type) {
case SDL_VIDEORESIZE: /* Resizing of window */
intf_SDL_Resize( p_intf, event.resize.w, event.resize.h );
break;
case SDL_KEYDOWN: /* if a key is pressed */
i_key = event.key.keysym.sym; /* forward it */
switch(i_key) {
/* switch to fullscreen */
case SDLK_f:
......@@ -163,6 +164,14 @@ void intf_SDLManage( intf_thread_t *p_intf )
break;
}
break;
case SDL_MOUSEBUTTONDOWN:
if(event.button.button==SDL_BUTTON_MIDDLE)
{
intf_SDL_Hidecursor(p_intf);
}
break;
case SDL_QUIT:
intf_ProcessKey( p_intf, SDLK_q );
break;
......@@ -197,6 +206,14 @@ void intf_SDL_Fullscreen(intf_thread_t * p_intf)
vlc_mutex_unlock( &p_intf->p_vout->change_lock );
}
void intf_SDL_Hidecursor(intf_thread_t * p_intf)
{
vlc_mutex_lock(&p_intf->p_vout->change_lock);
p_intf->p_vout->p_sys->b_cursor = 1 - p_intf->p_vout->p_sys->b_cursor;
p_intf->p_vout->p_sys->b_hide_cursor=1;
vlc_mutex_unlock(&p_intf->p_vout->change_lock);
}
void intf_SDL_Keymap(intf_thread_t * p_intf )
{
/* p_intf->p_intf_getKey = intf_getKey; */
......
......@@ -58,8 +58,10 @@ typedef struct vout_sys_s
SDL_Overlay * p_overlay; /* overlay device */
boolean_t b_fullscreen;
boolean_t b_overlay;
boolean_t b_cursor;
boolean_t b_reopen_display;
boolean_t b_toggle_fullscreen;
boolean_t b_hide_cursor;
Uint8 * p_buffer[2];
/* Buffers informations */
} vout_sys_t;
......@@ -70,7 +72,7 @@ typedef struct vout_sys_s
static int SDLOpenDisplay ( vout_thread_t *p_vout );
static void SDLCloseDisplay ( vout_thread_t *p_vout );
static void SDLToggleFullScreen ( vout_thread_t *p_vout );
static void SDLHideCursor ( vout_thread_t *p_vout );
/*****************************************************************************
* vout_SDLCreate: allocate SDL video thread output method
*****************************************************************************
......@@ -115,6 +117,8 @@ int vout_SDLCreate( vout_thread_t *p_vout, char *psz_display,
p_vout->p_sys->i_height = main_GetIntVariable( VOUT_HEIGHT_VAR,
VOUT_HEIGHT_DEFAULT );
p_vout->p_sys->b_cursor = 0 ; // TODO should be done with a main_GetInt..
if( SDLOpenDisplay(p_vout) )
{
intf_ErrMsg( "error: can't initialize SDL library: %s",
......@@ -123,7 +127,7 @@ int vout_SDLCreate( vout_thread_t *p_vout, char *psz_display,
}
p_vout->p_sys->b_toggle_fullscreen = 0;
p_vout->p_sys->b_hide_cursor = 0;
return( 0 );
}
......@@ -184,6 +188,12 @@ int vout_SDLManage( vout_thread_t *p_vout )
SDLToggleFullScreen(p_vout);
}
/* if pointer has to be hidden/shown we do so */
if( p_vout->p_sys->b_hide_cursor )
{
SDLHideCursor(p_vout);
}
return( 0 );
}
......@@ -342,7 +352,7 @@ static int SDLOpenDisplay( vout_thread_t *p_vout )
SDL_WM_SetCaption( VOUT_TITLE , VOUT_TITLE );
SDL_EventState(SDL_KEYUP , SDL_IGNORE); /* ignore keys up */
SDL_EventState(SDL_MOUSEBUTTONUP, SDL_IGNORE);
if( p_vout->b_need_render )
{
p_vout->p_sys->p_buffer[ 0 ] = p_vout->p_sys->p_display->pixels;
......@@ -422,16 +432,40 @@ static void SDLCloseDisplay( vout_thread_t *p_vout )
* SDLToggleFullScreen: toggle fullscreen
*****************************************************************************
* This function toggles the fullscreen state of the surface.
* And - hide the pointer if switching to fullscreen
* - show the pointer if leaving fullscreen state
*****************************************************************************/
static void SDLToggleFullScreen( vout_thread_t *p_vout )
{
SDL_WM_ToggleFullScreen(p_vout->p_sys->p_display);
if( p_vout->p_sys->b_fullscreen )
SDL_ShowCursor( 0 );
{
p_vout->p_sys->b_cursor=1;
}
else
SDL_ShowCursor( 1 );
{
p_vout->p_sys->b_cursor=0;
}
p_vout->p_sys->b_toggle_fullscreen = 0;
SDLHideCursor(p_vout);
}
/*****************************************************************************
* SDLHideCursor: Hide/Show mouse pointer
*****************************************************************************
* This function hides/shows the mouse pointer inside the main window.
*****************************************************************************/
static void SDLHideCursor( vout_thread_t *p_vout )
{
if( p_vout->p_sys->b_cursor==1 )
{
SDL_ShowCursor( 0 );
}
else
{
SDL_ShowCursor( 1 );
}
p_vout->p_sys->b_hide_cursor = 0;
}
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