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
macos-click-through
Serg Tereshchenko 3 years ago committed by Keith Simmons
parent 96f0c636f4
commit 5047637c4f

@ -175,8 +175,13 @@ impl GlutinWindowWrapper {
return; return;
} }
let new_size = window.inner_size();
let settings = SETTINGS.get::<CmdLineSettings>(); let settings = SETTINGS.get::<CmdLineSettings>();
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( window.set_inner_size(
self.renderer self.renderer
.grid_renderer .grid_renderer
@ -184,14 +189,10 @@ impl GlutinWindowWrapper {
); );
self.saved_grid_size = Some(settings.geometry); self.saved_grid_size = Some(settings.geometry);
// Font change at startup is ignored, so grid size (and startup screen) could be preserved. // 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. // But only when not resized yet. With maximized or resized window we should redraw grid.
// font_changed = false;
// temporary disable this: https://github.com/neovide/neovide/issues/918
// font_changed = false;
} }
let new_size = window.inner_size();
if self.saved_inner_size != new_size || font_changed { if self.saved_inner_size != new_size || font_changed {
self.saved_inner_size = new_size; self.saved_inner_size = new_size;
self.handle_new_grid_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) *control_flow = ControlFlow::WaitUntil(previous_frame_start + frame_duration)
}); });
} }
fn is_already_resized(size: PhysicalSize<u32>) -> bool {
size != PhysicalSize::from((800, 600))
}

Loading…
Cancel
Save