From 257a8ad32a8e829fc5ba330d394a3e4e7c669a0c Mon Sep 17 00:00:00 2001 From: keith Date: Sun, 15 Mar 2020 12:18:41 -0700 Subject: [PATCH] ignore text events on frame when focus is regained --- src/window.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/window.rs b/src/window.rs index 124ad15..ff17f61 100644 --- a/src/window.rs +++ b/src/window.rs @@ -302,6 +302,7 @@ pub fn ui_loop() { let mut keycode = None; let mut keytext = None; + let mut ignore_text_this_frame = false; for event in event_pump.poll_iter() { match event { @@ -315,13 +316,18 @@ pub fn ui_loop() { Event::MouseButtonUp { .. } => window.handle_pointer_up(), Event::MouseWheel { x, y, .. } => window.handle_mouse_wheel(x, y), Event::Window { win_event: WindowEvent::FocusLost, .. } => window.handle_focus_lost(), - Event::Window { win_event: WindowEvent::FocusGained, .. } => window.handle_focus_gained(), + Event::Window { win_event: WindowEvent::FocusGained, .. } => { + ignore_text_this_frame = true; // Ignore any text events on the first frame when focus is regained. https://github.com/Kethku/neovide/issues/193 + window.handle_focus_gained(); + }, Event::Window { .. } => REDRAW_SCHEDULER.queue_next_frame(), _ => {} } } - window.handle_keyboard_input(keycode, keytext); + if !ignore_text_this_frame { + window.handle_keyboard_input(keycode, keytext); + } if !window.draw_frame() { break;