Skip to content

Commit

Permalink
refactor: default to ControlFlow::Wait in general
Browse files Browse the repository at this point in the history
This seems to improve CPU usage, especially when not interacting with the applets after the latest updates
  • Loading branch information
wash2 committed Sep 26, 2023
1 parent 6c1706b commit c337fa5
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions sctk/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1174,18 +1174,15 @@ where
redraw_request: Some(redraw_request),
} => {
match redraw_request {
crate::core::window::RedrawRequest::NextFrame => {
ControlFlow::Poll
}
crate::core::window::RedrawRequest::At(at) => {
ControlFlow::WaitUntil(at)
crate::core::window::RedrawRequest::NextFrame => {
ControlFlow::Wait
}
crate::core::window::RedrawRequest::At(at) => {
ControlFlow::WaitUntil(at)
}
}
}},
_ => if needs_update {
ControlFlow::Poll
} else {
ControlFlow::Wait
},
_ => ControlFlow::Wait,
});
}
redraw_pending = false;
Expand Down Expand Up @@ -1214,6 +1211,7 @@ where
// NOTE Ashley: this is done here only after a redraw for now instead of the event handler.
// Otherwise cpu goes up in the running application as well as in cosmic-comp
if let Some(surface) = state.frame.take() {
dbg!("frame");
surface.frame(&queue_handle, surface.clone());
surface.commit();
}
Expand Down

0 comments on commit c337fa5

Please sign in to comment.