From 8ff2768ed4165931feac074307c784a7d7b0cb46 Mon Sep 17 00:00:00 2001 From: Serhii Tereshchenko Date: Sun, 23 Jan 2022 20:54:42 +0200 Subject: [PATCH] refactor: Move call to SETTINGS.get inside should_ignore_input (#1169) It wasn't required outside, and this way code is cleaner. --- src/window/keyboard_manager.rs | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/window/keyboard_manager.rs b/src/window/keyboard_manager.rs index dfd134b..d1ce1e8 100644 --- a/src/window/keyboard_manager.rs +++ b/src/window/keyboard_manager.rs @@ -1,15 +1,14 @@ -use glutin::{ - event::{ElementState, Event, KeyEvent, WindowEvent}, - keyboard::{Key, Key::Dead}, - platform::modifier_supplement::KeyEventExtModifierSupplement, -}; - use crate::{ bridge::{SerialCommand, UiCommand}, event_aggregator::EVENT_AGGREGATOR, settings::SETTINGS, window::KeyboardSettings, }; +use glutin::{ + event::{ElementState, Event, KeyEvent, WindowEvent}, + keyboard::{Key, Key::Dead}, + platform::modifier_supplement::KeyEventExtModifierSupplement, +}; enum InputEvent { KeyEvent(KeyEvent), @@ -79,11 +78,9 @@ impl KeyboardManager { self.logo = modifiers.super_key(); } Event::MainEventsCleared => { - // And the window wasn't just focused. - let settings = SETTINGS.get::(); - - if !self.should_ignore_input(&settings) { - // If we have a keyboard event this frame + // If the window wasn't just focused. + if !self.should_ignore_input() { + // And we have a keyboard event this frame for input_event in self.queued_input_events.iter() { let mut next_dead_key = self.prev_dead_key; match input_event { @@ -125,7 +122,8 @@ impl KeyboardManager { } } - fn should_ignore_input(&self, settings: &KeyboardSettings) -> bool { + fn should_ignore_input(&self) -> bool { + let settings = SETTINGS.get::(); self.ignore_input_this_frame || (self.logo && !settings.use_logo) }