mirror of
https://github.com/emilk/egui.git
synced 2026-08-30 13:20:05 -04:00
Add Context::request_repaint_after (#1694)
This commit is contained in:
@@ -120,7 +120,7 @@ pub fn run_glow(
|
||||
|
||||
let egui::FullOutput {
|
||||
platform_output,
|
||||
needs_repaint,
|
||||
repaint_after,
|
||||
textures_delta,
|
||||
shapes,
|
||||
} = integration.update(app.as_mut(), window);
|
||||
@@ -148,9 +148,18 @@ pub fn run_glow(
|
||||
|
||||
*control_flow = if integration.should_quit() {
|
||||
winit::event_loop::ControlFlow::Exit
|
||||
} else if needs_repaint {
|
||||
} else if repaint_after.is_zero() {
|
||||
window.request_redraw();
|
||||
winit::event_loop::ControlFlow::Poll
|
||||
} else if let Some(repaint_after_instant) =
|
||||
std::time::Instant::now().checked_add(repaint_after)
|
||||
{
|
||||
// if repaint_after is something huge and can't be added to Instant,
|
||||
// we will use `ControlFlow::Wait` instead.
|
||||
// technically, this might lead to some weird corner cases where the user *WANTS*
|
||||
// winit to use `WaitUntil(MAX_INSTANT)` explicitly. they can roll their own
|
||||
// egui backend impl i guess.
|
||||
winit::event_loop::ControlFlow::WaitUntil(repaint_after_instant)
|
||||
} else {
|
||||
winit::event_loop::ControlFlow::Wait
|
||||
};
|
||||
@@ -167,7 +176,6 @@ pub fn run_glow(
|
||||
std::thread::sleep(std::time::Duration::from_millis(10));
|
||||
}
|
||||
};
|
||||
|
||||
match event {
|
||||
// Platform-dependent event handlers to workaround a winit bug
|
||||
// See: https://github.com/rust-windowing/winit/issues/987
|
||||
@@ -209,7 +217,12 @@ pub fn run_glow(
|
||||
painter.destroy();
|
||||
}
|
||||
winit::event::Event::UserEvent(RequestRepaintEvent) => window.request_redraw(),
|
||||
_ => (),
|
||||
winit::event::Event::NewEvents(winit::event::StartCause::ResumeTimeReached {
|
||||
..
|
||||
}) => {
|
||||
window.request_redraw();
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -298,7 +311,7 @@ pub fn run_wgpu(
|
||||
|
||||
let egui::FullOutput {
|
||||
platform_output,
|
||||
needs_repaint,
|
||||
repaint_after,
|
||||
textures_delta,
|
||||
shapes,
|
||||
} = integration.update(app.as_mut(), window);
|
||||
@@ -319,9 +332,18 @@ pub fn run_wgpu(
|
||||
|
||||
*control_flow = if integration.should_quit() {
|
||||
winit::event_loop::ControlFlow::Exit
|
||||
} else if needs_repaint {
|
||||
} else if repaint_after.is_zero() {
|
||||
window.request_redraw();
|
||||
winit::event_loop::ControlFlow::Poll
|
||||
} else if let Some(repaint_after_instant) =
|
||||
std::time::Instant::now().checked_add(repaint_after)
|
||||
{
|
||||
// if repaint_after is something huge and can't be added to Instant,
|
||||
// we will use `ControlFlow::Wait` instead.
|
||||
// technically, this might lead to some weird corner cases where the user *WANTS*
|
||||
// winit to use `WaitUntil(MAX_INSTANT)` explicitly. they can roll their own
|
||||
// egui backend impl i guess.
|
||||
winit::event_loop::ControlFlow::WaitUntil(repaint_after_instant)
|
||||
} else {
|
||||
winit::event_loop::ControlFlow::Wait
|
||||
};
|
||||
@@ -395,6 +417,11 @@ pub fn run_wgpu(
|
||||
painter.destroy();
|
||||
}
|
||||
winit::event::Event::UserEvent(RequestRepaintEvent) => window.request_redraw(),
|
||||
winit::event::Event::NewEvents(winit::event::StartCause::ResumeTimeReached {
|
||||
..
|
||||
}) => {
|
||||
window.request_redraw();
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user