From 00575e158fd10762a688d70bd89359fd38323edc Mon Sep 17 00:00:00 2001 From: Jay Oster Date: Sat, 12 Jun 2021 06:55:08 -0700 Subject: [PATCH] Fix an issue where losing focus could prevent the event loop from receiving events for releasing modifier keys (#479) - This issue was made apparent on macOS since 67c6002578b73aa01872a3378cc5b7debe93a0a7 - Repro: 1. Cmd+Tab away from the window (this will keep the Cmd modifier state `true` until it is pressed again) 2. Cmd+Tab back to the window 3. Try to scroll with the trackpad or mouse wheel ... it won't work until you press and release the Cmd key! 4. Also the plot widget will be stuck in "zoom mode" while the Cmd modifier state is true. - I was not able to reproduce the issue with `egui_web` --- egui_glium/src/lib.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/egui_glium/src/lib.rs b/egui_glium/src/lib.rs index da8ba79d..12ce49e3 100644 --- a/egui_glium/src/lib.rs +++ b/egui_glium/src/lib.rs @@ -172,6 +172,11 @@ pub fn input_to_egui( } } } + WindowEvent::Focused(_) => { + // We will not be given a KeyboardInput event when the modifiers are released while + // the window does not have focus. Unset all modifier state to be safe. + input_state.raw.modifiers = Modifiers::default(); + } WindowEvent::MouseWheel { delta, .. } => { let mut delta = match delta { glutin::event::MouseScrollDelta::LineDelta(x, y) => {