From 5047637c4f64253b427d8a377f7a41d51015ead7 Mon Sep 17 00:00:00 2001 From: Serg Tereshchenko Date: Sun, 29 Aug 2021 00:36:20 +0300 Subject: [PATCH] refactor: Allow resize at startup for tiling WM ... but preserve startup screen for normal WM. Tiling WM is detected by initial window size, which is already changed on first render pass. Refs #918 --- src/window/window_wrapper/mod.rs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/window/window_wrapper/mod.rs b/src/window/window_wrapper/mod.rs index 427af0a..cf0ba99 100644 --- a/src/window/window_wrapper/mod.rs +++ b/src/window/window_wrapper/mod.rs @@ -175,8 +175,13 @@ impl GlutinWindowWrapper { return; } + let new_size = window.inner_size(); let settings = SETTINGS.get::(); - if self.saved_grid_size.is_none() && !settings.maximized { + // Resize at startup happens when window is maximized or when using tiling WM + // which already resized window. + let resized_at_startup = settings.maximized || is_already_resized(new_size); + + if self.saved_grid_size.is_none() && !resized_at_startup { window.set_inner_size( self.renderer .grid_renderer @@ -184,14 +189,10 @@ impl GlutinWindowWrapper { ); self.saved_grid_size = Some(settings.geometry); // Font change at startup is ignored, so grid size (and startup screen) could be preserved. - // But only when --maximize is not used. With maximized window we should redraw grid. - // - // temporary disable this: https://github.com/neovide/neovide/issues/918 - // font_changed = false; + // But only when not resized yet. With maximized or resized window we should redraw grid. + font_changed = false; } - let new_size = window.inner_size(); - if self.saved_inner_size != new_size || font_changed { self.saved_inner_size = new_size; self.handle_new_grid_size(new_size); @@ -321,3 +322,7 @@ pub fn create_window( *control_flow = ControlFlow::WaitUntil(previous_frame_start + frame_duration) }); } + +fn is_already_resized(size: PhysicalSize) -> bool { + size != PhysicalSize::from((800, 600)) +}