From 8448d1b5a971843419dce1dff3bb347bae89e157 Mon Sep 17 00:00:00 2001 From: keith Date: Mon, 17 Feb 2020 19:31:52 -0800 Subject: [PATCH] fix key binding issue, text scaling, and maybe render bug --- Cargo.lock | 2 -- Cargo.toml | 1 + src/settings.rs | 4 ++-- src/window.rs | 19 +++++++++++++------ 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0d03d09..474713e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1635,7 +1635,6 @@ dependencies = [ "bitflags", "lazy_static", "libc", - "raw-window-handle", "sdl2-sys", ] @@ -1785,7 +1784,6 @@ dependencies = [ [[package]] name = "skulpin" version = "0.5.2" -source = "git+https://github.com/Kethku/skulpin?branch=sdl2#396bc7d52240a05384c73de1e117a601b1e2e5ff" dependencies = [ "ash", "cocoa", diff --git a/Cargo.toml b/Cargo.toml index 28e31c0..6c4e7d6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,7 @@ font-kit = "0.5.0" skribo = { git = "https://github.com/linebender/skribo" } lru = "0.4.3" skulpin = { git = "https://github.com/Kethku/skulpin", branch = "sdl2" } +# skulpin = { path = "../skulpin" } derive-new = "0.5" rmpv = "0.4.4" rust-embed = { version = "5.2.0", features = ["debug-embed"] } diff --git a/src/settings.rs b/src/settings.rs index ebdd7e1..b5bebc8 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -113,7 +113,7 @@ pub struct Settings { impl Settings { pub async fn read_initial_values(&self, nvim: &Neovim>) { - let keys : Vec= self.settings.lock().keys().cloned().collect(); + let keys : Vec = self.settings.lock().keys().cloned().collect(); for name in keys { let variable_name = format!("neovide_{}", name.to_string()); match nvim.get_var(&variable_name).await { @@ -128,7 +128,7 @@ impl Settings { } pub async fn setup_changed_listeners(&self, nvim: &Neovim>) { - let keys : Vec= self.settings.lock().keys().cloned().collect(); + let keys : Vec = self.settings.lock().keys().cloned().collect(); for name in keys { let vimscript = format!("function NeovideNotify{}Changed(d, k, z)\n", name) + diff --git a/src/window.rs b/src/window.rs index 5523415..7522aff 100644 --- a/src/window.rs +++ b/src/window.rs @@ -76,7 +76,7 @@ pub fn ui_loop() { let mut skulpin_renderer = RendererBuilder::new() .prefer_integrated_gpu() .use_vulkan_debug_layer(true) - .present_mode_priority(vec![PresentMode::Mailbox, PresentMode::Immediate]) + .present_mode_priority(vec![PresentMode::Immediate]) .coordinate_system(CoordinateSystem::Logical) .build(&window) .expect("Failed to create renderer"); @@ -100,6 +100,7 @@ pub fn ui_loop() { window.set_title(&title).expect("Could not set title"); } + let mut ignore_text_input = false; for event in event_pump.poll_iter() { match event { Event::Quit {..} => break 'running, @@ -107,6 +108,7 @@ pub fn ui_loop() { Event::KeyDown { keycode: Some(keycode), keymod: modifiers, .. } => { if let Some((key_text, special)) = parse_keycode(keycode) { let will_text_input = + !modifiers.contains(Mod::LCTRLMOD) && !modifiers.contains(Mod::RCTRLMOD) && !modifiers.contains(Mod::LALTMOD) && @@ -118,15 +120,20 @@ pub fn ui_loop() { } BRIDGE.queue_command(UiCommand::Keyboard(append_modifiers(modifiers, key_text, special))); + ignore_text_input = true; } }, Event::TextInput { text, .. } => { - let text = if text == "<" { - String::from("") + if ignore_text_input { + ignore_text_input = false; } else { - text - }; - BRIDGE.queue_command(UiCommand::Keyboard(text)) + let text = if text == "<" { + String::from("") + } else { + text + }; + BRIDGE.queue_command(UiCommand::Keyboard(text)) + } }, Event::MouseMotion { x, y, .. } => { let grid_x = (x as f32 / renderer.font_width) as i64;