1 Commits

Author SHA1 Message Date
bel
26b415667a exchange on every key press and rare tick to save CPU churn 2023-03-25 10:08:11 -06:00

View File

@@ -253,7 +253,7 @@ impl Application for Main {
self.configuring = None;
},
_ => {},
}
};
},
Message::EventOccurred(event) => {
match event {
@@ -269,6 +269,7 @@ impl Application for Main {
self.keys_newly_down.dedup();
},
};
self.exchange();
},
iced::event::Event::Keyboard(keyboard::Event::KeyReleased{
key_code,
@@ -288,9 +289,10 @@ impl Application for Main {
},
None => {},
};
self.exchange();
},
_ => {},
}
};
},
_ => {
self.configuring = Some(msg.clone());
@@ -306,7 +308,7 @@ impl Application for Main {
iced::Event::Keyboard(_) => Some(Message::EventOccurred(event)),
_ => None,
}),
every(std::time::Duration::from_millis(5)).map(|_| Message::Tick),
every(std::time::Duration::from_millis(5000)).map(|_| Message::Tick),
]);
}