check loaded window size before running

macos-click-through
Keith Simmons 3 years ago
parent 7390e1aae5
commit 76bddae01a

44
Cargo.lock generated

@ -880,7 +880,7 @@ checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
[[package]] [[package]]
name = "glutin" name = "glutin"
version = "0.26.0" version = "0.26.0"
source = "git+https://github.com/Kethku/glutin?branch=new-keyboard-all#cf509674b403e0f90f2db41a084e303cbd90fbf5" source = "git+https://github.com/neovide/glutin?branch=new-keyboard-all#cf509674b403e0f90f2db41a084e303cbd90fbf5"
dependencies = [ dependencies = [
"android_glue", "android_glue",
"cgl", "cgl",
@ -900,13 +900,13 @@ dependencies = [
"wayland-client", "wayland-client",
"wayland-egl", "wayland-egl",
"winapi", "winapi",
"winit", "winit 0.24.0 (git+https://github.com/Kethku/winit?branch=new-keyboard-all)",
] ]
[[package]] [[package]]
name = "glutin_egl_sys" name = "glutin_egl_sys"
version = "0.1.5" version = "0.1.5"
source = "git+https://github.com/Kethku/glutin?branch=new-keyboard-all#cf509674b403e0f90f2db41a084e303cbd90fbf5" source = "git+https://github.com/neovide/glutin?branch=new-keyboard-all#cf509674b403e0f90f2db41a084e303cbd90fbf5"
dependencies = [ dependencies = [
"gl_generator", "gl_generator",
"winapi", "winapi",
@ -915,12 +915,12 @@ dependencies = [
[[package]] [[package]]
name = "glutin_emscripten_sys" name = "glutin_emscripten_sys"
version = "0.1.1" version = "0.1.1"
source = "git+https://github.com/Kethku/glutin?branch=new-keyboard-all#cf509674b403e0f90f2db41a084e303cbd90fbf5" source = "git+https://github.com/neovide/glutin?branch=new-keyboard-all#cf509674b403e0f90f2db41a084e303cbd90fbf5"
[[package]] [[package]]
name = "glutin_gles2_sys" name = "glutin_gles2_sys"
version = "0.1.5" version = "0.1.5"
source = "git+https://github.com/Kethku/glutin?branch=new-keyboard-all#cf509674b403e0f90f2db41a084e303cbd90fbf5" source = "git+https://github.com/neovide/glutin?branch=new-keyboard-all#cf509674b403e0f90f2db41a084e303cbd90fbf5"
dependencies = [ dependencies = [
"gl_generator", "gl_generator",
"objc", "objc",
@ -929,7 +929,7 @@ dependencies = [
[[package]] [[package]]
name = "glutin_glx_sys" name = "glutin_glx_sys"
version = "0.1.7" version = "0.1.7"
source = "git+https://github.com/Kethku/glutin?branch=new-keyboard-all#cf509674b403e0f90f2db41a084e303cbd90fbf5" source = "git+https://github.com/neovide/glutin?branch=new-keyboard-all#cf509674b403e0f90f2db41a084e303cbd90fbf5"
dependencies = [ dependencies = [
"gl_generator", "gl_generator",
"x11-dl", "x11-dl",
@ -938,7 +938,7 @@ dependencies = [
[[package]] [[package]]
name = "glutin_wgl_sys" name = "glutin_wgl_sys"
version = "0.1.5" version = "0.1.5"
source = "git+https://github.com/Kethku/glutin?branch=new-keyboard-all#cf509674b403e0f90f2db41a084e303cbd90fbf5" source = "git+https://github.com/neovide/glutin?branch=new-keyboard-all#cf509674b403e0f90f2db41a084e303cbd90fbf5"
dependencies = [ dependencies = [
"gl_generator", "gl_generator",
] ]
@ -1351,7 +1351,7 @@ dependencies = [
"unicode-segmentation", "unicode-segmentation",
"which", "which",
"winapi", "winapi",
"winit", "winit 0.24.0 (git+https://github.com/neovide/winit?branch=new-keyboard-all)",
"winres", "winres",
] ]
@ -2597,6 +2597,34 @@ dependencies = [
"xkbcommon-dl", "xkbcommon-dl",
] ]
[[package]]
name = "winit"
version = "0.24.0"
source = "git+https://github.com/neovide/winit?branch=new-keyboard-all#3b5462ec315aae8d95b9440ff6c52a5412c2cca4"
dependencies = [
"bitflags",
"cocoa",
"core-foundation 0.9.1",
"core-graphics 0.22.2",
"core-video-sys",
"dispatch",
"instant",
"lazy_static",
"libc",
"log",
"nameof",
"ndk",
"ndk-glue",
"ndk-sys",
"objc",
"parking_lot 0.11.2",
"raw-window-handle",
"scopeguard",
"unicode-segmentation",
"winapi",
"xkbcommon-dl",
]
[[package]] [[package]]
name = "winres" name = "winres"
version = "0.1.11" version = "0.1.11"

@ -8,6 +8,11 @@ const SETTINGS_PATH: &str = ".local/share/nvim/neovide-settings.json";
#[cfg(windows)] #[cfg(windows)]
const SETTINGS_PATH: &str = "AppData/Local/nvim-data/neovide-settings.json"; const SETTINGS_PATH: &str = "AppData/Local/nvim-data/neovide-settings.json";
pub const DEFAULT_WINDOW_GEOMETRY: Dimensions = Dimensions {
width: 100,
height: 50,
};
fn neovim_std_datapath() -> PathBuf { fn neovim_std_datapath() -> PathBuf {
let mut settings_path = dirs::home_dir().unwrap(); let mut settings_path = dirs::home_dir().unwrap();
settings_path.push(SETTINGS_PATH); settings_path.push(SETTINGS_PATH);
@ -18,14 +23,16 @@ pub fn try_to_load_last_window_size() -> Result<Dimensions, String> {
let settings_path = neovim_std_datapath(); let settings_path = neovim_std_datapath();
let json = std::fs::read_to_string(&settings_path).map_err(|e| e.to_string())?; let json = std::fs::read_to_string(&settings_path).map_err(|e| e.to_string())?;
let geometry: Dimensions = serde_json::from_str(&json).map_err(|e| e.to_string())?; let loaded_geometry: Dimensions = serde_json::from_str(&json).map_err(|e| e.to_string())?;
log::debug!("Loaded Window Size: {:?}", geometry); log::debug!("Loaded Window Size: {:?}", loaded_geometry);
Ok(geometry)
if loaded_geometry.width == 0 || loaded_geometry.height == 0 {
log::warn!("Invalid Saved Window Size. Reverting to default");
Ok(DEFAULT_WINDOW_GEOMETRY)
} else {
Ok(loaded_geometry)
}
} }
pub const DEFAULT_WINDOW_GEOMETRY: Dimensions = Dimensions {
width: 100,
height: 50,
};
pub fn maybe_save_window_size(grid_size: Option<Dimensions>) { pub fn maybe_save_window_size(grid_size: Option<Dimensions>) {
let settings = SETTINGS.get::<WindowSettings>(); let settings = SETTINGS.get::<WindowSettings>();

@ -1,7 +1,7 @@
use glutin::event::{ElementState, Event, KeyEvent, WindowEvent}; use glutin::event::{ElementState, Event, KeyEvent, WindowEvent};
use glutin::keyboard::Key; use glutin::keyboard::Key;
use winit::platform::modifier_supplement::KeyEventExtModifierSupplement; use glutin::platform::modifier_supplement::KeyEventExtModifierSupplement;
use crate::bridge::{SerialCommand, UiCommand}; use crate::bridge::{SerialCommand, UiCommand};
use crate::channel_utils::LoggingTx; use crate::channel_utils::LoggingTx;

Loading…
Cancel
Save