@@ -86,7 +86,7 @@ impl AlkahestApp {
8686
8787 let window = winit:: window:: WindowBuilder :: new ( )
8888 . with_title ( "Alkahest" )
89- . with_min_inner_size ( PhysicalSize :: new ( 640 , 360 ) )
89+ . with_min_inner_size ( PhysicalSize :: new ( 1280 , 720 ) )
9090 . with_inner_size ( config:: with ( |c| {
9191 PhysicalSize :: new ( c. window . width , c. window . height )
9292 } ) )
@@ -104,6 +104,14 @@ impl AlkahestApp {
104104 . unwrap ( ) ;
105105 let window = Arc :: new ( window) ;
106106
107+ // Make sure the window size in the config is not below the minimum size
108+ config:: with_mut ( |c| {
109+ let corrected_size = window. inner_size ( ) ;
110+ c. window . width = corrected_size. width ;
111+ c. window . height = corrected_size. height ;
112+ } ) ;
113+ config:: try_persist ( ) . ok ( ) ;
114+
107115 puffin:: set_scopes_on ( cfg ! ( feature = "profiler" ) ) ;
108116
109117 let gctx = Arc :: new ( GpuContext :: create ( & window) . unwrap ( ) ) ;
@@ -274,27 +282,31 @@ impl AlkahestApp {
274282 }
275283 }
276284 WindowEvent :: Resized ( new_dims) => {
277- if let Some ( swap_chain) = gctx. swap_chain . as_ref ( ) {
278- let _ = gui. renderer . as_mut ( ) . map ( |renderer| {
279- let _ = renderer
280- . resize_buffers ( swap_chain, || {
281- gctx. resize_swapchain ( new_dims. width , new_dims. height ) ;
282- HRESULT ( 0 )
283- } )
284- . unwrap ( ) ;
285- } ) ;
286- }
285+ let minimized = window. is_minimized ( ) . unwrap_or ( false ) ;
286+ if !minimized && new_dims. width > 0 && new_dims. height > 0 {
287+ if let Some ( swap_chain) = gctx. swap_chain . as_ref ( ) {
288+ let _ = gui. renderer . as_mut ( ) . map ( |renderer| {
289+ let _ = renderer
290+ . resize_buffers ( swap_chain, || {
291+ gctx. resize_swapchain ( new_dims. width , new_dims. height ) ;
292+ HRESULT ( 0 )
293+ } )
294+ . unwrap ( ) ;
295+ } ) ;
296+ }
287297
288- renderer. resize_buffers ( new_dims. width , new_dims. height ) ;
298+ renderer. resize_buffers ( new_dims. width , new_dims. height ) ;
289299
290- resources. get_mut :: < Camera > ( ) . set_viewport ( Viewport {
291- size : glam:: UVec2 :: new ( new_dims. width , new_dims. height ) ,
292- origin : glam:: UVec2 :: ZERO ,
293- } ) ;
300+ resources. get_mut :: < Camera > ( ) . set_viewport ( Viewport {
301+ size : glam:: UVec2 :: new ( new_dims. width , new_dims. height ) ,
302+ origin : glam:: UVec2 :: ZERO ,
303+ } ) ;
294304
295- config:: with_mut ( |c| {
296- ( c. window . width , c. window . height ) = ( new_dims. width , new_dims. height )
297- } ) ;
305+ config:: with_mut ( |c| {
306+ ( c. window . width , c. window . height ) =
307+ ( new_dims. width , new_dims. height )
308+ } ) ;
309+ }
298310 }
299311 WindowEvent :: RedrawRequested => {
300312 if * next_config_save < std:: time:: Instant :: now ( ) {
0 commit comments