* Don't set SE_KEY event to ctrl-h; I don't think this makes sense
* Don't warp the mouse on deactivation unless the cursor is in the window already; this fixes in_nograb * Stop grabbing the mouse in windowed mode when there is no sense in doing so * Make sure that IN_Restart is only called on r_fullscreen modification if a mode change actually takes place
This commit is contained in:
parent
e4e0568641
commit
acbf982689
2 changed files with 53 additions and 36 deletions
|
@ -725,16 +725,14 @@ void GLimp_EndFrame( void )
|
||||||
if( r_fullscreen->modified )
|
if( r_fullscreen->modified )
|
||||||
{
|
{
|
||||||
qboolean fullscreen;
|
qboolean fullscreen;
|
||||||
|
qboolean needToToggle = qtrue;
|
||||||
qboolean sdlToggled = qfalse;
|
qboolean sdlToggled = qfalse;
|
||||||
SDL_Surface *s = SDL_GetVideoSurface( );
|
SDL_Surface *s = SDL_GetVideoSurface( );
|
||||||
|
|
||||||
if( s )
|
if( s )
|
||||||
{
|
{
|
||||||
// Find out the current state
|
// Find out the current state
|
||||||
if( s->flags & SDL_FULLSCREEN )
|
fullscreen = !!( s->flags & SDL_FULLSCREEN );
|
||||||
fullscreen = qtrue;
|
|
||||||
else
|
|
||||||
fullscreen = qfalse;
|
|
||||||
|
|
||||||
if( r_fullscreen->integer && Cvar_VariableIntegerValue( "in_nograb" ) )
|
if( r_fullscreen->integer && Cvar_VariableIntegerValue( "in_nograb" ) )
|
||||||
{
|
{
|
||||||
|
@ -744,17 +742,20 @@ void GLimp_EndFrame( void )
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is the state we want different from the current state?
|
// Is the state we want different from the current state?
|
||||||
if( !!r_fullscreen->integer != fullscreen )
|
needToToggle = !!r_fullscreen->integer != fullscreen;
|
||||||
|
|
||||||
|
if( needToToggle )
|
||||||
sdlToggled = SDL_WM_ToggleFullScreen( s );
|
sdlToggled = SDL_WM_ToggleFullScreen( s );
|
||||||
else
|
|
||||||
sdlToggled = qtrue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( needToToggle )
|
||||||
|
{
|
||||||
// SDL_WM_ToggleFullScreen didn't work, so do it the slow way
|
// SDL_WM_ToggleFullScreen didn't work, so do it the slow way
|
||||||
if( !sdlToggled )
|
if( !sdlToggled )
|
||||||
Cbuf_AddText( "vid_restart" );
|
Cbuf_AddText( "vid_restart" );
|
||||||
|
|
||||||
IN_Restart( );
|
IN_Restart( );
|
||||||
|
}
|
||||||
|
|
||||||
r_fullscreen->modified = qfalse;
|
r_fullscreen->modified = qfalse;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,9 +58,9 @@ static qboolean mouseAvailable = qfalse;
|
||||||
static qboolean mouseActive = qfalse;
|
static qboolean mouseActive = qfalse;
|
||||||
static qboolean keyRepeatEnabled = qfalse;
|
static qboolean keyRepeatEnabled = qfalse;
|
||||||
|
|
||||||
static cvar_t *in_mouse;
|
static cvar_t *in_mouse = NULL;
|
||||||
#ifdef MACOS_X_ACCELERATION_HACK
|
#ifdef MACOS_X_ACCELERATION_HACK
|
||||||
static cvar_t *in_disablemacosxmouseaccel;
|
static cvar_t *in_disablemacosxmouseaccel = NULL;
|
||||||
static double originalMouseSpeed = -1.0;
|
static double originalMouseSpeed = -1.0;
|
||||||
#endif
|
#endif
|
||||||
static cvar_t *in_nograb;
|
static cvar_t *in_nograb;
|
||||||
|
@ -231,8 +231,7 @@ static const char *IN_TranslateSDLToQ3Key( SDL_keysym *keysym,
|
||||||
if( *key != K_DEL )
|
if( *key != K_DEL )
|
||||||
{
|
{
|
||||||
// ctrl-h
|
// ctrl-h
|
||||||
*key = CTRL('h');
|
*buf = CTRL('h');
|
||||||
*buf = *key;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// fallthrough
|
// fallthrough
|
||||||
|
@ -393,6 +392,9 @@ static void IN_DeactivateMouse( void )
|
||||||
if( mouseActive )
|
if( mouseActive )
|
||||||
{
|
{
|
||||||
SDL_WM_GrabInput( SDL_GRAB_OFF );
|
SDL_WM_GrabInput( SDL_GRAB_OFF );
|
||||||
|
|
||||||
|
// Don't warp the mouse unless the cursor is within the window
|
||||||
|
if( SDL_GetAppState( ) & SDL_APPMOUSEFOCUS )
|
||||||
SDL_WarpMouse( glConfig.vidWidth / 2, glConfig.vidHeight / 2 );
|
SDL_WarpMouse( glConfig.vidWidth / 2, glConfig.vidHeight / 2 );
|
||||||
|
|
||||||
mouseActive = qfalse;
|
mouseActive = qfalse;
|
||||||
|
@ -784,17 +786,31 @@ IN_Frame
|
||||||
*/
|
*/
|
||||||
void IN_Frame( void )
|
void IN_Frame( void )
|
||||||
{
|
{
|
||||||
IN_JoyMove( );
|
qboolean loading;
|
||||||
|
|
||||||
// Release the mouse if the console is down in windowed mode
|
IN_JoyMove( );
|
||||||
// or if the window loses focus due to task switching
|
IN_ProcessEvents( );
|
||||||
if( ( ( Key_GetCatcher( ) & KEYCATCH_CONSOLE ) && !r_fullscreen->integer ) ||
|
|
||||||
!( SDL_GetAppState() & SDL_APPINPUTFOCUS ) )
|
// If not DISCONNECTED (main menu) or ACTIVE (in game), we're loading
|
||||||
|
loading = !!( cls.state != CA_DISCONNECTED && cls.state != CA_ACTIVE );
|
||||||
|
|
||||||
|
if( !r_fullscreen->integer && ( Key_GetCatcher( ) & KEYCATCH_CONSOLE ) )
|
||||||
|
{
|
||||||
|
// Console is down in windowed mode
|
||||||
IN_DeactivateMouse( );
|
IN_DeactivateMouse( );
|
||||||
|
}
|
||||||
|
else if( !r_fullscreen->integer && loading )
|
||||||
|
{
|
||||||
|
// Loading in windowed mode
|
||||||
|
IN_DeactivateMouse( );
|
||||||
|
}
|
||||||
|
else if( !( SDL_GetAppState() & SDL_APPINPUTFOCUS ) )
|
||||||
|
{
|
||||||
|
// Window not got focus
|
||||||
|
IN_DeactivateMouse( );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
IN_ActivateMouse( );
|
IN_ActivateMouse( );
|
||||||
|
|
||||||
IN_ProcessEvents( );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue