Skip to content

Commit

Permalink
Fix high CPU usage on Windows when app is minimized (#3985)
Browse files Browse the repository at this point in the history
patch #3982
  • Loading branch information
rustbasic authored Feb 6, 2024
1 parent 45e9e8d commit 68eb3db
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 68eb3db

Please sign in to comment.