refactor: Move call to SETTINGS.get inside should_ignore_input (#1169)

It wasn't required outside, and this way code is cleaner.
macos-click-through
Serhii Tereshchenko 3 years ago committed by GitHub
parent 7308113073
commit 8ff2768ed4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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::<KeyboardSettings>();
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::<KeyboardSettings>();
self.ignore_input_this_frame || (self.logo && !settings.use_logo)
}

Loading…
Cancel
Save