exchange on every key press and rare tick to save CPU churn

master v0.1.3
bel 2023-03-25 10:08:11 -06:00
parent b1cb419f3d
commit 26b415667a
1 changed files with 5 additions and 3 deletions

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),
]);
}