Skip to content

Commit

Permalink
Fix high CPU usage on Windows when app is minimized (emilk#3985)
Browse files Browse the repository at this point in the history
  • Loading branch information
rustbasic authored and hacknus committed Oct 30, 2024
1 parent f45e143 commit 3609e85
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions crates/eframe/src/native/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,13 @@ fn run_and_return(

if let Some(window) = winit_app.window(*window_id) {
log::trace!("request_redraw for {window_id:?}");
if !window.is_minimized().unwrap_or(false) {
let is_minimized = window.is_minimized().unwrap_or(false);
if is_minimized {
false
} else {
window.request_redraw();
true
}
true
} else {
log::trace!("No window found for {window_id:?}");
false
Expand Down Expand Up @@ -347,10 +350,13 @@ fn run_and_exit(

if let Some(window) = winit_app.window(*window_id) {
log::trace!("request_redraw for {window_id:?}");
if !window.is_minimized().unwrap_or(false) {
let is_minimized = window.is_minimized().unwrap_or(false);
if is_minimized {
false
} else {
window.request_redraw();
true
}
true
} else {
log::trace!("No window found for {window_id:?}");
false
Expand Down

0 comments on commit 3609e85

Please sign in to comment.