Browse Source

sdl: partially fix maximizing window on Windows

pull/2/head
a1batross 6 years ago
parent
commit
0964fb11e4
  1. 34
      engine/platform/sdl/events.c
  2. 1
      engine/platform/sdl/events.h
  3. 26
      engine/platform/sdl/vid_sdl.c
  4. 2
      mainui

34
engine/platform/sdl/events.c

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

1
engine/platform/sdl/events.h

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

26
engine/platform/sdl/vid_sdl.c

@ -517,7 +517,7 @@ qboolean VID_SetScreenResolution( int width, int height ) @@ -517,7 +517,7 @@ qboolean VID_SetScreenResolution( int width, int height )
SDL_GL_GetDrawableSize( host.hWnd, &got.w, &got.h );
R_ChangeDisplaySettingsFast( got.w, got.h );
R_SaveVideoMode( got.w, got.h );
return true;
}
@ -571,8 +571,10 @@ qboolean VID_CreateWindow( int width, int height, qboolean fullscreen ) @@ -571,8 +571,10 @@ qboolean VID_CreateWindow( int width, int height, qboolean fullscreen )
if( !fullscreen )
{
wndFlags |= SDL_WINDOW_RESIZABLE;
xpos = max( 0, Cvar_VariableInteger( "_window_xpos" ) );
ypos = max( 0, Cvar_VariableInteger( "_window_ypos" ) );
xpos = Cvar_VariableInteger( "_window_xpos" );
ypos = Cvar_VariableInteger( "_window_ypos" );
if( xpos < 0 ) xpos = SDL_WINDOWPOS_CENTERED;
if( ypos < 0 ) ypos = SDL_WINDOWPOS_CENTERED;
}
else
{
@ -675,7 +677,7 @@ qboolean VID_CreateWindow( int width, int height, qboolean fullscreen ) @@ -675,7 +677,7 @@ qboolean VID_CreateWindow( int width, int height, qboolean fullscreen )
return false;
SDL_GL_GetDrawableSize( host.hWnd, &width, &height );
R_ChangeDisplaySettingsFast( width, height );
R_SaveVideoMode( width, height );
return true;
}
@ -1126,20 +1128,6 @@ void GL_InitExtensions( void ) @@ -1126,20 +1128,6 @@ void GL_InitExtensions( void )
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 )
{
SDL_DisplayMode displayMode;
@ -1177,7 +1165,7 @@ rserr_t R_ChangeDisplaySettings( int width, int height, qboolean fullscreen ) @@ -1177,7 +1165,7 @@ rserr_t R_ChangeDisplaySettings( int width, int height, qboolean fullscreen )
SDL_SetWindowBordered( host.hWnd, true );
SDL_SetWindowSize( host.hWnd, width, height );
SDL_GL_GetDrawableSize( host.hWnd, &width, &height );
R_ChangeDisplaySettingsFast( width, height );
R_SaveVideoMode( width, height );
}
return rserr_ok;

2
mainui

@ -1 +1 @@ @@ -1 +1 @@
Subproject commit 4e061f6eb58884ca04b75aac2b0016cbe67132f5
Subproject commit 7af08ccb66b5a74ec6cab298b63f4b829585fd12
Loading…
Cancel
Save