Reduce CPU usage while window is unfocused and not hovered over

Only render if window is focused, hovered, subscript is running,
or coroutine is active.

Closes #18
This commit is contained in:
meehl committed 2025-11-28 18:30:25 +01:00
1 parent 0066a05e13
commit ae6a24f82c
9 files changed
+116 -30

No files matched your search

+10
View File
@@ -13,6 +13,8 @@ pub struct WindowState {
pub size: PhysicalSize<u32>,
pub scale_factor: f32,
pending_window_title: std::cell::Cell<Option<String>>,
pub is_hovered: bool,
pub is_focused: bool,
}
impl Default for WindowState {
@@ -23,6 +25,8 @@ impl Default for WindowState {
scale_factor: 1.0,
pending_window_title: std::cell::Cell::new(None),
clipboard: None,
is_hovered: true,
is_focused: true,
}
}
}
@@ -73,4 +77,10 @@ impl WindowState {
None
}
}
pub fn request_redraw(&self) {
if let Some(ref window) = self.window {
window.request_redraw();
}
}
}