mirror of
https://github.com/YGGverse/xash3d-fwgs.git
synced 2025-01-13 16:47:57 +00:00
engine: client: restore window maximized state after engine restart
This commit is contained in:
parent
73fcb84b62
commit
cb19fa2f6d
@ -549,7 +549,7 @@ static void SetWidthAndHeightFromCommandLine( void )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
R_SaveVideoMode( width, height, width, height );
|
R_SaveVideoMode( width, height, width, height, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SetFullscreenModeFromCommandLine( void )
|
static void SetFullscreenModeFromCommandLine( void )
|
||||||
|
@ -29,7 +29,8 @@ static CVAR_DEFINE_AUTO( vid_rotate, "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "sc
|
|||||||
static CVAR_DEFINE_AUTO( vid_scale, "1.0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "pixel scale" );
|
static CVAR_DEFINE_AUTO( vid_scale, "1.0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "pixel scale" );
|
||||||
|
|
||||||
CVAR_DEFINE_AUTO( vid_highdpi, "1", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "enable High-DPI mode" );
|
CVAR_DEFINE_AUTO( vid_highdpi, "1", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "enable High-DPI mode" );
|
||||||
CVAR_DEFINE( vid_fullscreen, "fullscreen", "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "enable fullscreen mode" );
|
CVAR_DEFINE_AUTO( vid_maximized, "0", FCVAR_RENDERINFO, "window maximized state, read-only" );
|
||||||
|
CVAR_DEFINE( vid_fullscreen, "fullscreen", "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "enable fullscren mode" );
|
||||||
CVAR_DEFINE( window_xpos, "_window_xpos", "-1", FCVAR_RENDERINFO, "window position by horizontal" );
|
CVAR_DEFINE( window_xpos, "_window_xpos", "-1", FCVAR_RENDERINFO, "window position by horizontal" );
|
||||||
CVAR_DEFINE( window_ypos, "_window_ypos", "-1", FCVAR_RENDERINFO, "window position by vertical" );
|
CVAR_DEFINE( window_ypos, "_window_ypos", "-1", FCVAR_RENDERINFO, "window position by vertical" );
|
||||||
|
|
||||||
@ -66,7 +67,7 @@ void VID_InitDefaultResolution( void )
|
|||||||
R_SaveVideoMode
|
R_SaveVideoMode
|
||||||
=================
|
=================
|
||||||
*/
|
*/
|
||||||
void R_SaveVideoMode( int w, int h, int render_w, int render_h )
|
void R_SaveVideoMode( int w, int h, int render_w, int render_h, qboolean maximized )
|
||||||
{
|
{
|
||||||
if( !w || !h || !render_w || !render_h )
|
if( !w || !h || !render_w || !render_h )
|
||||||
{
|
{
|
||||||
@ -79,6 +80,7 @@ void R_SaveVideoMode( int w, int h, int render_w, int render_h )
|
|||||||
|
|
||||||
Cvar_SetValue( "width", w );
|
Cvar_SetValue( "width", w );
|
||||||
Cvar_SetValue( "height", h );
|
Cvar_SetValue( "height", h );
|
||||||
|
Cvar_DirectSet( &vid_maximized, maximized ? "1" : "0" );
|
||||||
|
|
||||||
// immediately drop changed state or we may trigger
|
// immediately drop changed state or we may trigger
|
||||||
// video subsystem to reapply settings
|
// video subsystem to reapply settings
|
||||||
@ -221,6 +223,7 @@ void VID_Init( void )
|
|||||||
Cvar_RegisterVariable( &vid_rotate );
|
Cvar_RegisterVariable( &vid_rotate );
|
||||||
Cvar_RegisterVariable( &vid_scale );
|
Cvar_RegisterVariable( &vid_scale );
|
||||||
Cvar_RegisterVariable( &vid_fullscreen );
|
Cvar_RegisterVariable( &vid_fullscreen );
|
||||||
|
Cvar_RegisterVariable( &vid_maximized );
|
||||||
Cvar_RegisterVariable( &vid_brightness );
|
Cvar_RegisterVariable( &vid_brightness );
|
||||||
Cvar_RegisterVariable( &vid_gamma );
|
Cvar_RegisterVariable( &vid_gamma );
|
||||||
Cvar_RegisterVariable( &window_xpos );
|
Cvar_RegisterVariable( &window_xpos );
|
||||||
|
@ -31,12 +31,13 @@ extern glwstate_t glw_state;
|
|||||||
#define VID_MIN_WIDTH 320
|
#define VID_MIN_WIDTH 320
|
||||||
|
|
||||||
extern convar_t vid_fullscreen;
|
extern convar_t vid_fullscreen;
|
||||||
|
extern convar_t vid_maximized;
|
||||||
extern convar_t vid_highdpi;
|
extern convar_t vid_highdpi;
|
||||||
extern convar_t window_xpos;
|
extern convar_t window_xpos;
|
||||||
extern convar_t window_ypos;
|
extern convar_t window_ypos;
|
||||||
extern convar_t gl_msaa_samples;
|
extern convar_t gl_msaa_samples;
|
||||||
|
|
||||||
void R_SaveVideoMode( int w, int h, int render_w, int render_h );
|
void R_SaveVideoMode( int w, int h, int render_w, int render_h, qboolean maximized );
|
||||||
void VID_SetDisplayTransform( int *render_w, int *render_h );
|
void VID_SetDisplayTransform( int *render_w, int *render_h );
|
||||||
void VID_CheckChanges( void );
|
void VID_CheckChanges( void );
|
||||||
const char *VID_GetModeString( int vid_mode );
|
const char *VID_GetModeString( int vid_mode );
|
||||||
|
@ -631,15 +631,19 @@ static void SDLash_EventFilter( SDL_Event *event )
|
|||||||
|
|
||||||
Q_snprintf( val, sizeof( val ), "%d", event->window.data2 );
|
Q_snprintf( val, sizeof( val ), "%d", event->window.data2 );
|
||||||
Cvar_DirectSet( &window_ypos, val );
|
Cvar_DirectSet( &window_ypos, val );
|
||||||
|
|
||||||
|
Cvar_DirectSet( &vid_maximized, "0" );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_WINDOWEVENT_MINIMIZED:
|
case SDL_WINDOWEVENT_MINIMIZED:
|
||||||
host.status = HOST_SLEEP;
|
host.status = HOST_SLEEP;
|
||||||
|
Cvar_DirectSet( &vid_maximized, "0" );
|
||||||
VID_RestoreScreenResolution( );
|
VID_RestoreScreenResolution( );
|
||||||
break;
|
break;
|
||||||
case SDL_WINDOWEVENT_RESTORED:
|
case SDL_WINDOWEVENT_RESTORED:
|
||||||
host.status = HOST_FRAME;
|
host.status = HOST_FRAME;
|
||||||
host.force_draw_version_time = host.realtime + FORCE_DRAW_VERSION_TIME;
|
host.force_draw_version_time = host.realtime + FORCE_DRAW_VERSION_TIME;
|
||||||
|
Cvar_DirectSet( &vid_maximized, "0" );
|
||||||
if( vid_fullscreen.value )
|
if( vid_fullscreen.value )
|
||||||
VID_SetMode();
|
VID_SetMode();
|
||||||
break;
|
break;
|
||||||
@ -651,12 +655,18 @@ static void SDLash_EventFilter( SDL_Event *event )
|
|||||||
break;
|
break;
|
||||||
case SDL_WINDOWEVENT_RESIZED:
|
case SDL_WINDOWEVENT_RESIZED:
|
||||||
{
|
{
|
||||||
|
SDL_Window *wnd = SDL_GetWindowFromID( event->window.windowID );
|
||||||
|
|
||||||
if( vid_fullscreen.value )
|
if( vid_fullscreen.value )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
VID_SaveWindowSize( event->window.data1, event->window.data2 );
|
VID_SaveWindowSize( event->window.data1, event->window.data2,
|
||||||
|
FBitSet( SDL_GetWindowFlags( wnd ), SDL_WINDOW_MAXIMIZED ) != 0 );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case SDL_WINDOWEVENT_MAXIMIZED:
|
||||||
|
Cvar_DirectSet( &vid_maximized, "1" );
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ qboolean VID_CreateWindow( int width, int height, qboolean fullscreen );
|
|||||||
void VID_DestroyWindow( void );
|
void VID_DestroyWindow( void );
|
||||||
void GL_InitExtensions( void );
|
void GL_InitExtensions( void );
|
||||||
qboolean GL_DeleteContext( void );
|
qboolean GL_DeleteContext( void );
|
||||||
void VID_SaveWindowSize( int width, int height );
|
void VID_SaveWindowSize( int width, int height, qboolean maximized );
|
||||||
|
|
||||||
// joystick events
|
// joystick events
|
||||||
extern SDL_Joystick *g_joy;
|
extern SDL_Joystick *g_joy;
|
||||||
|
@ -520,7 +520,7 @@ static qboolean GL_UpdateContext( void )
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VID_SaveWindowSize( int width, int height )
|
void VID_SaveWindowSize( int width, int height, qboolean maximized )
|
||||||
{
|
{
|
||||||
int render_w = width, render_h = height;
|
int render_w = width, render_h = height;
|
||||||
|
|
||||||
@ -532,7 +532,7 @@ void VID_SaveWindowSize( int width, int height )
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
VID_SetDisplayTransform( &render_w, &render_h );
|
VID_SetDisplayTransform( &render_w, &render_h );
|
||||||
R_SaveVideoMode( width, height, render_w, render_h );
|
R_SaveVideoMode( width, height, render_w, render_h, maximized );
|
||||||
}
|
}
|
||||||
|
|
||||||
static qboolean VID_SetScreenResolution( int width, int height )
|
static qboolean VID_SetScreenResolution( int width, int height )
|
||||||
@ -568,9 +568,9 @@ static qboolean VID_SetScreenResolution( int width, int height )
|
|||||||
//SDL_SetWindowPosition( host.hWnd, 0, 0 );
|
//SDL_SetWindowPosition( host.hWnd, 0, 0 );
|
||||||
SDL_SetWindowSize( host.hWnd, got.w, got.h );
|
SDL_SetWindowSize( host.hWnd, got.w, got.h );
|
||||||
|
|
||||||
VID_SaveWindowSize( got.w, got.h );
|
VID_SaveWindowSize( got.w, got.h, true );
|
||||||
#else
|
#else
|
||||||
VID_SaveWindowSize( width, height );
|
VID_SaveWindowSize( width, height, true );
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -622,6 +622,7 @@ qboolean VID_CreateWindow( int width, int height, qboolean fullscreen )
|
|||||||
char iconpath[MAX_STRING];
|
char iconpath[MAX_STRING];
|
||||||
int xpos, ypos;
|
int xpos, ypos;
|
||||||
const char *localIcoPath;
|
const char *localIcoPath;
|
||||||
|
qboolean maximized = vid_maximized.value != 0.0f;
|
||||||
|
|
||||||
if( vid_highdpi.value ) wndFlags |= SDL_WINDOW_ALLOW_HIGHDPI;
|
if( vid_highdpi.value ) wndFlags |= SDL_WINDOW_ALLOW_HIGHDPI;
|
||||||
Q_strncpy( wndname, GI->title, sizeof( wndname ));
|
Q_strncpy( wndname, GI->title, sizeof( wndname ));
|
||||||
@ -634,6 +635,8 @@ qboolean VID_CreateWindow( int width, int height, qboolean fullscreen )
|
|||||||
SDL_Rect r;
|
SDL_Rect r;
|
||||||
|
|
||||||
wndFlags |= SDL_WINDOW_RESIZABLE;
|
wndFlags |= SDL_WINDOW_RESIZABLE;
|
||||||
|
if( maximized )
|
||||||
|
wndFlags |= SDL_WINDOW_MAXIMIZED;
|
||||||
|
|
||||||
#if SDL_VERSION_ATLEAST( 2, 0, 5 )
|
#if SDL_VERSION_ATLEAST( 2, 0, 5 )
|
||||||
if( SDL_GetDisplayUsableBounds( 0, &r ) < 0 &&
|
if( SDL_GetDisplayUsableBounds( 0, &r ) < 0 &&
|
||||||
@ -691,9 +694,11 @@ qboolean VID_CreateWindow( int width, int height, qboolean fullscreen )
|
|||||||
|
|
||||||
// window creation has failed...
|
// window creation has failed...
|
||||||
if( glw_state.safe >= SAFE_LAST )
|
if( glw_state.safe >= SAFE_LAST )
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
// update window size if it was maximized, just in case
|
||||||
|
if( FBitSet( SDL_GetWindowFlags( host.hWnd ), SDL_WINDOW_MAXIMIZED ) != 0 )
|
||||||
|
SDL_GetWindowSize( host.hWnd, &width, &height );
|
||||||
|
|
||||||
#if !XASH_MOBILE_PLATFORM
|
#if !XASH_MOBILE_PLATFORM
|
||||||
if( fullscreen )
|
if( fullscreen )
|
||||||
@ -840,7 +845,7 @@ qboolean VID_CreateWindow( int width, int height, qboolean fullscreen )
|
|||||||
|
|
||||||
#endif // SDL_VERSION_ATLEAST( 2, 0, 0 )
|
#endif // SDL_VERSION_ATLEAST( 2, 0, 0 )
|
||||||
|
|
||||||
VID_SaveWindowSize( width, height );
|
VID_SaveWindowSize( width, height, maximized );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1094,7 +1099,7 @@ rserr_t R_ChangeDisplaySettings( int width, int height, qboolean fullscreen )
|
|||||||
SDL_SetWindowSize( host.hWnd, width, height );
|
SDL_SetWindowSize( host.hWnd, width, height );
|
||||||
|
|
||||||
#endif // SDL_VERSION_ATLEAST( 2, 0, 0 )
|
#endif // SDL_VERSION_ATLEAST( 2, 0, 0 )
|
||||||
VID_SaveWindowSize( width, height );
|
VID_SaveWindowSize( width, height, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
return rserr_ok;
|
return rserr_ok;
|
||||||
@ -1172,6 +1177,7 @@ qboolean VID_SetMode( void )
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user