From f3f441bb86f3fcf872e4a00233d0e2fc2789a781 Mon Sep 17 00:00:00 2001 From: mewhhaha Date: Sat, 7 Mar 2020 00:59:06 +0100 Subject: [PATCH 1/2] Add workaround for Nordic keyboard --- src/bridge/keybindings.rs | 4 ++-- src/window.rs | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/bridge/keybindings.rs b/src/bridge/keybindings.rs index d448bd2..a4285eb 100644 --- a/src/bridge/keybindings.rs +++ b/src/bridge/keybindings.rs @@ -46,9 +46,9 @@ pub fn parse_keycode(keycode: Keycode) -> Option<(&'static str, bool)> { Keycode::Num9 => Some(("9", false)), Keycode::Colon => Some((":", false)), Keycode::Semicolon => Some((";", false)), - Keycode::Less => Some(("lt", true)), + Keycode::Less => Some(("lt", false)), Keycode::Equals => Some(("=", false)), - Keycode::Greater => Some(("gt", true)), + Keycode::Greater => Some(("gt", false)), Keycode::Question => Some(("?", false)), Keycode::At => Some(("@", false)), Keycode::LeftBracket => Some(("[", false)), diff --git a/src/window.rs b/src/window.rs index 35a6285..bdd98ab 100644 --- a/src/window.rs +++ b/src/window.rs @@ -126,8 +126,11 @@ impl WindowWrapper { pub fn handle_key_down(&mut self, keycode: Keycode, modifiers: Mod) { trace!("KeyDown Received: {}", keycode); + const ALTGR: Mod = Mod::from_bits_truncate(0x0240); + if let Some((key_text, special)) = parse_keycode(keycode) { let will_text_input = + modifiers.contains(ALTGR) || !modifiers.contains(Mod::LCTRLMOD) && !modifiers.contains(Mod::RCTRLMOD) && !modifiers.contains(Mod::LALTMOD) && From 82dd785a266d6bb9b9167556812c0dbdd6da8ea1 Mon Sep 17 00:00:00 2001 From: mewhhaha Date: Sat, 7 Mar 2020 01:55:12 +0100 Subject: [PATCH 2/2] Make changes based on https://github.com/Kethku/neovide/pull/183#discussion_r389208255 --- src/window.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/window.rs b/src/window.rs index bdd98ab..aeaea76 100644 --- a/src/window.rs +++ b/src/window.rs @@ -126,18 +126,18 @@ impl WindowWrapper { pub fn handle_key_down(&mut self, keycode: Keycode, modifiers: Mod) { trace!("KeyDown Received: {}", keycode); - const ALTGR: Mod = Mod::from_bits_truncate(0x0240); if let Some((key_text, special)) = parse_keycode(keycode) { - let will_text_input = - modifiers.contains(ALTGR) || - !modifiers.contains(Mod::LCTRLMOD) && - !modifiers.contains(Mod::RCTRLMOD) && - !modifiers.contains(Mod::LALTMOD) && - !modifiers.contains(Mod::RALTMOD) && - !modifiers.contains(Mod::LGUIMOD) && - !modifiers.contains(Mod::RGUIMOD); - if modifiers.contains(Mod::MODEMOD) || (will_text_input && !special) { + let ctrl = modifiers.contains(Mod::LCTRLMOD) || modifiers.contains(Mod::RCTRLMOD); + let alt = modifiers.contains(Mod::LALTMOD) || modifiers.contains(Mod::RALTMOD); + let gui = modifiers.contains(Mod::LGUIMOD) || modifiers.contains(Mod::RGUIMOD); + + let will_text_input = + modifiers.contains(Mod::MODEMOD) || + (ctrl && alt) || + !ctrl && !alt && !gui; + + if will_text_input && !special { self.ignore_text_input = false; return; }