* 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:
*
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;
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
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:
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;
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; */
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;
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
*****************************************************************************
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",
}
p_vout->p_sys->b_toggle_fullscreen = 0;
-
+ p_vout->p_sys->b_hide_cursor = 0;
return( 0 );
}
{
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 );
}
SDL_ShowCursor( 1 );
SDL_WM_SetCaption( VOUT_TITLE , VOUT_TITLE );
- SDL_EventState(SDL_KEYUP , SDL_IGNORE); /* ignore keys up */
-
+ 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;
* 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;
+}