1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-01 06:10:06 -04:00

eframe: sleep a bit only when minimized (#3139)

This commit is contained in:
icedrocket
2023-07-10 17:56:24 +09:00
committed by GitHub
parent 9478e50d01
commit 2a2529bb9c

View File

@@ -914,12 +914,9 @@ mod glow_integration {
integration.maybe_autosave(app.as_mut(), window); integration.maybe_autosave(app.as_mut(), window);
if !self.is_focused { if window.is_minimized() == Some(true) {
// On Mac, a minimized Window uses up all CPU: https://github.com/emilk/egui/issues/325 // On Mac, a minimized Window uses up all CPU:
// We can't know if we are minimized: https://github.com/rust-windowing/winit/issues/208 // https://github.com/emilk/egui/issues/325
// But we know if we are focused (in foreground). When minimized, we are not focused.
// However, a user may want an egui with an animation in the background,
// so we still need to repaint quite fast.
crate::profile_scope!("bg_sleep"); crate::profile_scope!("bg_sleep");
std::thread::sleep(std::time::Duration::from_millis(10)); std::thread::sleep(std::time::Duration::from_millis(10));
} }
@@ -1335,12 +1332,9 @@ mod wgpu_integration {
integration.maybe_autosave(app.as_mut(), window); integration.maybe_autosave(app.as_mut(), window);
if !self.is_focused { if window.is_minimized() == Some(true) {
// On Mac, a minimized Window uses up all CPU: https://github.com/emilk/egui/issues/325 // On Mac, a minimized Window uses up all CPU:
// We can't know if we are minimized: https://github.com/rust-windowing/winit/issues/208 // https://github.com/emilk/egui/issues/325
// But we know if we are focused (in foreground). When minimized, we are not focused.
// However, a user may want an egui with an animation in the background,
// so we still need to repaint quite fast.
crate::profile_scope!("bg_sleep"); crate::profile_scope!("bg_sleep");
std::thread::sleep(std::time::Duration::from_millis(10)); std::thread::sleep(std::time::Duration::from_millis(10));
} }