diff --git a/src/settings/window_size.rs b/src/settings/window_size.rs index be28fc877f..1da70a35a9 100644 --- a/src/settings/window_size.rs +++ b/src/settings/window_size.rs @@ -3,7 +3,9 @@ use std::path::PathBuf; use serde::{Deserialize, Serialize}; use winit::dpi::{PhysicalPosition, PhysicalSize}; -use crate::{dimensions::Dimensions, settings::SETTINGS, window::WindowSettings}; +use crate::{ + dimensions::Dimensions, settings::SETTINGS, window::WindowSettings, window::WinitWindowWrapper, +}; const SETTINGS_FILE: &str = "neovide-settings.json"; @@ -64,12 +66,17 @@ pub fn load_last_window_settings() -> Result { Ok(loaded_settings) } -pub fn save_window_size( - maximized: bool, - pixel_size: PhysicalSize, - grid_size: Dimensions, - position: Option>, -) { +pub fn save_window_size(window_wrapper: &WinitWindowWrapper) { + let window = window_wrapper.windowed_context.window(); + // Don't save the window size when the window is minimized, since the size can be 0 + // Note wayland can't determine this + if matches!(window.is_minimized(), Some(true)) { + return; + } + let maximized = window.is_maximized(); + let pixel_size = window.inner_size(); + let grid_size = window_wrapper.get_grid_size(); + let position = window.outer_position().ok(); let window_settings = SETTINGS.get::(); let settings = PersistentSettings { diff --git a/src/window/mod.rs b/src/window/mod.rs index ec21c29609..ddcad71ab4 100644 --- a/src/window/mod.rs +++ b/src/window/mod.rs @@ -44,7 +44,6 @@ use keyboard_manager::KeyboardManager; use mouse_manager::MouseManager; use renderer::SkiaRenderer; use update_loop::UpdateLoop; -use window_wrapper::WinitWindowWrapper; use crate::{ cmd_line::{CmdLineSettings, GeometryArgs}, @@ -56,6 +55,7 @@ use crate::{ }; pub use error_window::show_error_window; pub use settings::{WindowSettings, WindowSettingsChanged}; +pub use window_wrapper::WinitWindowWrapper; static ICON: &[u8] = include_bytes!("../../assets/neovide.ico"); @@ -275,13 +275,7 @@ pub fn main_loop( } } - let window = window_wrapper.windowed_context.window(); - save_window_size( - window.is_maximized(), - window.inner_size(), - window_wrapper.get_grid_size(), - window.outer_position().ok(), - ); + save_window_size(&window_wrapper); }); let result = event_loop.run(|e, window_target| { @@ -331,13 +325,7 @@ pub fn main_loop( } if !RUNNING_TRACKER.is_running() { - let window = window_wrapper.windowed_context.window(); - save_window_size( - window.is_maximized(), - window.inner_size(), - window_wrapper.get_grid_size(), - window.outer_position().ok(), - ); + save_window_size(&window_wrapper); window_target.exit(); } else { window_target.set_control_flow(update_loop.step(&mut window_wrapper, Ok(e)).unwrap());