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::{ use crate::{
bridge::{SerialCommand, UiCommand}, bridge::{SerialCommand, UiCommand},
event_aggregator::EVENT_AGGREGATOR, event_aggregator::EVENT_AGGREGATOR,
settings::SETTINGS, settings::SETTINGS,
window::KeyboardSettings, window::KeyboardSettings,
}; };
use glutin::{
event::{ElementState, Event, KeyEvent, WindowEvent},
keyboard::{Key, Key::Dead},
platform::modifier_supplement::KeyEventExtModifierSupplement,
};
enum InputEvent { enum InputEvent {
KeyEvent(KeyEvent), KeyEvent(KeyEvent),
@ -79,11 +78,9 @@ impl KeyboardManager {
self.logo = modifiers.super_key(); self.logo = modifiers.super_key();
} }
Event::MainEventsCleared => { Event::MainEventsCleared => {
// And the window wasn't just focused. // If the window wasn't just focused.
let settings = SETTINGS.get::<KeyboardSettings>(); if !self.should_ignore_input() {
// And we have a keyboard event this frame
if !self.should_ignore_input(&settings) {
// If we have a keyboard event this frame
for input_event in self.queued_input_events.iter() { for input_event in self.queued_input_events.iter() {
let mut next_dead_key = self.prev_dead_key; let mut next_dead_key = self.prev_dead_key;
match input_event { 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) self.ignore_input_this_frame || (self.logo && !settings.use_logo)
} }

Loading…
Cancel
Save