sdl: partially fix maximizing window on Windows

This commit is contained in:
a1batross 2018-11-29 21:43:51 +03:00
parent f173ce11f7
commit 0964fb11e4
4 changed files with 22 additions and 41 deletions

View File

@ -380,9 +380,9 @@ static void SDLash_EventFilter( SDL_Event *event )
if( event->window.windowID != SDL_GetWindowID( host.hWnd ) ) if( event->window.windowID != SDL_GetWindowID( host.hWnd ) )
return; return;
if( ( host.status == HOST_SHUTDOWN ) || if( host.status == HOST_SHUTDOWN || Host_IsDedicated() )
( Host_IsDedicated() ) )
break; // no need to activate break; // no need to activate
switch( event->window.event ) switch( event->window.event )
{ {
case SDL_WINDOWEVENT_MOVED: case SDL_WINDOWEVENT_MOVED:
@ -392,10 +392,14 @@ static void SDLash_EventFilter( SDL_Event *event )
Cvar_SetValue( "_window_ypos", (float)event->window.data1 ); Cvar_SetValue( "_window_ypos", (float)event->window.data1 );
} }
break; break;
case SDL_WINDOWEVENT_MINIMIZED:
host.status = HOST_SLEEP;
VID_RestoreScreenResolution( );
break;
case SDL_WINDOWEVENT_RESTORED: case SDL_WINDOWEVENT_RESTORED:
host.status = HOST_FRAME; host.status = HOST_FRAME;
host.force_draw_version = true; host.force_draw_version = true;
host.force_draw_version_time = host.realtime + 2; host.force_draw_version_time = host.realtime + FORCE_DRAW_VERSION_TIME;
if( vid_fullscreen->value ) if( vid_fullscreen->value )
VID_SetMode(); VID_SetMode();
break; break;
@ -407,16 +411,11 @@ static void SDLash_EventFilter( SDL_Event *event )
S_Activate( true ); S_Activate( true );
} }
host.force_draw_version = true; host.force_draw_version = true;
host.force_draw_version_time = host.realtime + 2; host.force_draw_version_time = host.realtime + FORCE_DRAW_VERSION_TIME;
if( vid_fullscreen->value ) if( vid_fullscreen->value )
VID_SetMode(); VID_SetMode();
break; break;
case SDL_WINDOWEVENT_MINIMIZED:
host.status = HOST_SLEEP;
VID_RestoreScreenResolution();
break;
case SDL_WINDOWEVENT_FOCUS_LOST: case SDL_WINDOWEVENT_FOCUS_LOST:
#if TARGET_OS_IPHONE #if TARGET_OS_IPHONE
{ {
// Keep running if ftp server enabled // Keep running if ftp server enabled
@ -431,24 +430,19 @@ static void SDLash_EventFilter( SDL_Event *event )
S_Activate( false ); S_Activate( false );
} }
host.force_draw_version = true; host.force_draw_version = true;
host.force_draw_version_time = host.realtime + 1; host.force_draw_version_time = host.realtime + 2;
VID_RestoreScreenResolution(); VID_RestoreScreenResolution();
break; break;
case SDL_WINDOWEVENT_CLOSE:
Sys_Quit();
break;
case SDL_WINDOWEVENT_RESIZED: case SDL_WINDOWEVENT_RESIZED:
if( vid_fullscreen->value ) break;
R_ChangeDisplaySettingsFast( event->window.data1,
event->window.data2 );
break;
case SDL_WINDOWEVENT_MAXIMIZED: case SDL_WINDOWEVENT_MAXIMIZED:
{ {
int w, h; int w = VID_MIN_WIDTH, h = VID_MIN_HEIGHT;
if( vid_fullscreen->value ) break; if( vid_fullscreen->value )
break;
SDL_GL_GetDrawableSize( host.hWnd, &w, &h ); SDL_GL_GetDrawableSize( host.hWnd, &w, &h );
R_ChangeDisplaySettingsFast( w, h ); R_SaveVideoMode( w, h );
SCR_VidInit(); // tell the client.dll what vid_mode has changed
break; break;
} }
default: default:

View File

@ -22,7 +22,6 @@ GNU General Public License for more details.
// window management // window management
void VID_RestoreScreenResolution( void ); void VID_RestoreScreenResolution( void );
void R_ChangeDisplaySettingsFast( int width, int height ); // for fast resizing
qboolean VID_CreateWindow( int width, int height, qboolean fullscreen ); 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 );

View File

@ -517,7 +517,7 @@ qboolean VID_SetScreenResolution( int width, int height )
SDL_GL_GetDrawableSize( host.hWnd, &got.w, &got.h ); SDL_GL_GetDrawableSize( host.hWnd, &got.w, &got.h );
R_ChangeDisplaySettingsFast( got.w, got.h ); R_SaveVideoMode( got.w, got.h );
return true; return true;
} }
@ -571,8 +571,10 @@ qboolean VID_CreateWindow( int width, int height, qboolean fullscreen )
if( !fullscreen ) if( !fullscreen )
{ {
wndFlags |= SDL_WINDOW_RESIZABLE; wndFlags |= SDL_WINDOW_RESIZABLE;
xpos = max( 0, Cvar_VariableInteger( "_window_xpos" ) ); xpos = Cvar_VariableInteger( "_window_xpos" );
ypos = max( 0, Cvar_VariableInteger( "_window_ypos" ) ); ypos = Cvar_VariableInteger( "_window_ypos" );
if( xpos < 0 ) xpos = SDL_WINDOWPOS_CENTERED;
if( ypos < 0 ) ypos = SDL_WINDOWPOS_CENTERED;
} }
else else
{ {
@ -675,7 +677,7 @@ qboolean VID_CreateWindow( int width, int height, qboolean fullscreen )
return false; return false;
SDL_GL_GetDrawableSize( host.hWnd, &width, &height ); SDL_GL_GetDrawableSize( host.hWnd, &width, &height );
R_ChangeDisplaySettingsFast( width, height ); R_SaveVideoMode( width, height );
return true; return true;
} }
@ -1126,20 +1128,6 @@ void GL_InitExtensions( void )
glw_state.initialized = true; glw_state.initialized = true;
} }
/*
==================
R_ChangeDisplaySettingsFast
Change window size fastly to custom values, without setting vid mode
==================
*/
void R_ChangeDisplaySettingsFast( int width, int height )
{
R_SaveVideoMode( width, height );
SCR_VidInit();
}
rserr_t R_ChangeDisplaySettings( int width, int height, qboolean fullscreen ) rserr_t R_ChangeDisplaySettings( int width, int height, qboolean fullscreen )
{ {
SDL_DisplayMode displayMode; SDL_DisplayMode displayMode;
@ -1177,7 +1165,7 @@ rserr_t R_ChangeDisplaySettings( int width, int height, qboolean fullscreen )
SDL_SetWindowBordered( host.hWnd, true ); SDL_SetWindowBordered( host.hWnd, true );
SDL_SetWindowSize( host.hWnd, width, height ); SDL_SetWindowSize( host.hWnd, width, height );
SDL_GL_GetDrawableSize( host.hWnd, &width, &height ); SDL_GL_GetDrawableSize( host.hWnd, &width, &height );
R_ChangeDisplaySettingsFast( width, height ); R_SaveVideoMode( width, height );
} }
return rserr_ok; return rserr_ok;

2
mainui

@ -1 +1 @@
Subproject commit 4e061f6eb58884ca04b75aac2b0016cbe67132f5 Subproject commit 7af08ccb66b5a74ec6cab298b63f4b829585fd12