Avoid unnecessary request_redraw() calls

This commit is contained in:
Richard Feldman 2022-04-07 21:32:57 -04:00
parent 78feb45d82
commit cf91390e56
No known key found for this signature in database
GPG Key ID: 7E4127D1E4241798

View File

@ -193,15 +193,12 @@ pub fn run_event_loop(title: &str, state: roc::State) -> Result<(), Box<dyn Erro
} => {
keyboard_modifiers = modifiers;
}
Event::MainEventsCleared => window.request_redraw(),
Event::RedrawRequested { .. } => {
// If we shouldn't draw yet, keep waiting until we should.
let current_time = Instant::now();
if next_render_time.saturating_duration_since(current_time) > TIME_BETWEEN_RENDERS {
// Keep waiting until it's time to draw again.
window.request_redraw();
return;
}