mirror of
https://github.com/UberGames/lilium-voyager.git
synced 2024-12-12 21:22:14 +00:00
Fix mouse grab after toggling fullscreen
cls.glconfig.isFullscreen was not updated when changing r_fullscreen without a vid_restart. Starting in fullscreen and switching to windowed mode would not release the mouse. Mods calling trap_GetGlconfig() after a fullscreen toggle now get the correct value for isFullscreen. (Note: Mods already got the correct value at start up and after vid_restart.) Reported by Mickaël "mickael9" Thomas.
This commit is contained in:
parent
e986384fde
commit
699cbed7c7
1 changed files with 14 additions and 11 deletions
|
@ -341,7 +341,7 @@ static void IN_GobbleMotionEvents( void )
|
|||
IN_ActivateMouse
|
||||
===============
|
||||
*/
|
||||
static void IN_ActivateMouse( void )
|
||||
static void IN_ActivateMouse( qboolean isFullscreen )
|
||||
{
|
||||
if (!mouseAvailable || !SDL_WasInit( SDL_INIT_VIDEO ) )
|
||||
return;
|
||||
|
@ -355,7 +355,7 @@ static void IN_ActivateMouse( void )
|
|||
}
|
||||
|
||||
// in_nograb makes no sense in fullscreen mode
|
||||
if( !Cvar_VariableIntegerValue("r_fullscreen") )
|
||||
if( !isFullscreen )
|
||||
{
|
||||
if( in_nograb->modified || !mouseActive )
|
||||
{
|
||||
|
@ -379,15 +379,15 @@ static void IN_ActivateMouse( void )
|
|||
IN_DeactivateMouse
|
||||
===============
|
||||
*/
|
||||
static void IN_DeactivateMouse( void )
|
||||
static void IN_DeactivateMouse( qboolean isFullscreen )
|
||||
{
|
||||
if( !SDL_WasInit( SDL_INIT_VIDEO ) )
|
||||
return;
|
||||
|
||||
// Always show the cursor when the mouse is disabled,
|
||||
// but not when fullscreen
|
||||
if( !Cvar_VariableIntegerValue("r_fullscreen") )
|
||||
SDL_ShowCursor( 1 );
|
||||
if( !isFullscreen )
|
||||
SDL_ShowCursor( SDL_TRUE );
|
||||
|
||||
if( !mouseAvailable )
|
||||
return;
|
||||
|
@ -1174,23 +1174,26 @@ void IN_Frame( void )
|
|||
// If not DISCONNECTED (main menu) or ACTIVE (in game), we're loading
|
||||
loading = ( clc.state != CA_DISCONNECTED && clc.state != CA_ACTIVE );
|
||||
|
||||
// update isFullscreen since it might of changed since the last vid_restart
|
||||
cls.glconfig.isFullscreen = Cvar_VariableIntegerValue( "r_fullscreen" ) != 0;
|
||||
|
||||
if( !cls.glconfig.isFullscreen && ( Key_GetCatcher( ) & KEYCATCH_CONSOLE ) )
|
||||
{
|
||||
// Console is down in windowed mode
|
||||
IN_DeactivateMouse( );
|
||||
IN_DeactivateMouse( cls.glconfig.isFullscreen );
|
||||
}
|
||||
else if( !cls.glconfig.isFullscreen && loading )
|
||||
{
|
||||
// Loading in windowed mode
|
||||
IN_DeactivateMouse( );
|
||||
IN_DeactivateMouse( cls.glconfig.isFullscreen );
|
||||
}
|
||||
else if( !( SDL_GetWindowFlags( SDL_window ) & SDL_WINDOW_INPUT_FOCUS ) )
|
||||
{
|
||||
// Window not got focus
|
||||
IN_DeactivateMouse( );
|
||||
IN_DeactivateMouse( cls.glconfig.isFullscreen );
|
||||
}
|
||||
else
|
||||
IN_ActivateMouse( );
|
||||
IN_ActivateMouse( cls.glconfig.isFullscreen );
|
||||
|
||||
IN_ProcessEvents( );
|
||||
|
||||
|
@ -1236,7 +1239,7 @@ void IN_Init( void *windowData )
|
|||
SDL_StartTextInput( );
|
||||
|
||||
mouseAvailable = ( in_mouse->value != 0 );
|
||||
IN_DeactivateMouse( );
|
||||
IN_DeactivateMouse( Cvar_VariableIntegerValue( "r_fullscreen" ) != 0 );
|
||||
|
||||
appState = SDL_GetWindowFlags( SDL_window );
|
||||
Cvar_SetValue( "com_unfocused", !( appState & SDL_WINDOW_INPUT_FOCUS ) );
|
||||
|
@ -1255,7 +1258,7 @@ void IN_Shutdown( void )
|
|||
{
|
||||
SDL_StopTextInput( );
|
||||
|
||||
IN_DeactivateMouse( );
|
||||
IN_DeactivateMouse( Cvar_VariableIntegerValue( "r_fullscreen" ) != 0 );
|
||||
mouseAvailable = qfalse;
|
||||
|
||||
IN_ShutdownJoystick( );
|
||||
|
|
Loading…
Reference in a new issue