mirror of
https://github.com/emilk/egui.git
synced 2026-09-03 07:10:04 -04:00
Remove clone and fix ClontrolFlow::Pull overrided by WaitUntil
This commit is contained in:
@@ -261,34 +261,39 @@ fn run_and_return(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is for not duplicating redraw requests
|
let mut next_repaint_time = windows_next_repaint_times.values().min().cloned();
|
||||||
|
|
||||||
|
// This is for not duplicating redraw requests
|
||||||
use winit::event::Event;
|
use winit::event::Event;
|
||||||
if matches!(
|
if matches!(
|
||||||
event,
|
event,
|
||||||
Event::RedrawEventsCleared | Event::RedrawRequested(_) | Event::Resumed
|
Event::RedrawEventsCleared | Event::RedrawRequested(_) | Event::Resumed
|
||||||
) {
|
) {
|
||||||
for (window_id, repaint_time) in &windows_next_repaint_times.clone() {
|
windows_next_repaint_times.retain(|window_id, repaint_time| {
|
||||||
if *repaint_time <= Instant::now() {
|
if *repaint_time > Instant::now() {
|
||||||
if let Some(window) = winit_app.window(*window_id) {
|
return true;
|
||||||
log::trace!("request_redraw");
|
};
|
||||||
window.request_redraw();
|
|
||||||
} else {
|
|
||||||
windows_next_repaint_times.remove(window_id);
|
|
||||||
}
|
|
||||||
control_flow.set_poll();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let next_repaint_time = windows_next_repaint_times.values().min();
|
next_repaint_time = None;
|
||||||
|
control_flow.set_poll();
|
||||||
|
|
||||||
|
if let Some(window) = winit_app.window(*window_id) {
|
||||||
|
log::trace!("request_redraw for {window_id:?}");
|
||||||
|
window.request_redraw();
|
||||||
|
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(next_repaint_time) = next_repaint_time {
|
if let Some(next_repaint_time) = next_repaint_time {
|
||||||
let time_until_next = next_repaint_time.saturating_duration_since(Instant::now());
|
let time_until_next = next_repaint_time.saturating_duration_since(Instant::now());
|
||||||
if time_until_next < std::time::Duration::from_secs(10_000) {
|
if time_until_next < std::time::Duration::from_secs(10_000) {
|
||||||
log::trace!("WaitUntil {time_until_next:?}");
|
log::trace!("WaitUntil {time_until_next:?}");
|
||||||
}
|
}
|
||||||
control_flow.set_wait_until(*next_repaint_time);
|
control_flow.set_wait_until(next_repaint_time);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -391,27 +396,32 @@ fn run_and_exit(event_loop: EventLoop<UserEvent>, mut winit_app: impl WinitApp +
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is for not duplicating redraw requests
|
let mut next_repaint_time = windows_next_repaint_times.values().min().cloned();
|
||||||
|
|
||||||
|
// This is for not duplicating redraw requests
|
||||||
use winit::event::Event;
|
use winit::event::Event;
|
||||||
if matches!(
|
if matches!(
|
||||||
event,
|
event,
|
||||||
Event::RedrawEventsCleared | Event::RedrawRequested(_) | Event::Resumed
|
Event::RedrawEventsCleared | Event::RedrawRequested(_) | Event::Resumed
|
||||||
) {
|
) {
|
||||||
for (window_id, repaint_time) in &windows_next_repaint_times.clone() {
|
windows_next_repaint_times.retain(|window_id, repaint_time| {
|
||||||
if *repaint_time <= Instant::now() {
|
if *repaint_time > Instant::now() {
|
||||||
if let Some(window) = winit_app.window(*window_id) {
|
return true;
|
||||||
log::trace!("request_redraw");
|
|
||||||
window.request_redraw();
|
|
||||||
} else {
|
|
||||||
windows_next_repaint_times.remove(window_id);
|
|
||||||
}
|
|
||||||
control_flow.set_poll();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let next_repaint_time = windows_next_repaint_times.values().min();
|
next_repaint_time = None;
|
||||||
|
control_flow.set_poll();
|
||||||
|
|
||||||
|
if let Some(window) = winit_app.window(*window_id) {
|
||||||
|
log::trace!("request_redraw for {window_id:?}");
|
||||||
|
window.request_redraw();
|
||||||
|
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(next_repaint_time) = next_repaint_time {
|
if let Some(next_repaint_time) = next_repaint_time {
|
||||||
let time_until_next = next_repaint_time.saturating_duration_since(Instant::now());
|
let time_until_next = next_repaint_time.saturating_duration_since(Instant::now());
|
||||||
@@ -429,7 +439,7 @@ fn run_and_exit(event_loop: EventLoop<UserEvent>, mut winit_app: impl WinitApp +
|
|||||||
.map(|window| window.request_redraw())
|
.map(|window| window.request_redraw())
|
||||||
});
|
});
|
||||||
|
|
||||||
control_flow.set_wait_until(*next_repaint_time);
|
control_flow.set_wait_until(next_repaint_time);
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user