aboutsummaryrefslogtreecommitdiff
path: root/src/app
diff options
context:
space:
mode:
authorOgulcan Celik <ogulcancelik@gmail.com>2026-04-21 17:37:41 +0300
committerOgulcan Celik <ogulcancelik@gmail.com>2026-04-21 17:37:41 +0300
commitb1c9833b828d12e7e0196c5607ae63372998e25a (patch)
treec8b1ff84cea1cf4367c5163e4721d028cf7856cf /src/app
parent8a4571198d013451743d1238f80a6bd69d67b32d (diff)
fix: stop headless idle spin and skip unnecessary macos probes
Diffstat (limited to 'src/app')
-rw-r--r--src/app/mod.rs29
-rw-r--r--src/app/runtime.rs19
2 files changed, 47 insertions, 1 deletions
diff --git a/src/app/mod.rs b/src/app/mod.rs
index 51a6678e..a598100a 100644
--- a/src/app/mod.rs
+++ b/src/app/mod.rs
@@ -1148,6 +1148,35 @@ mod tests {
}
#[test]
+ fn headless_next_loop_deadline_ignores_resize_poll() {
+ let mut app = test_app();
+ let now = Instant::now();
+ app.next_resize_poll = now + Duration::from_millis(100);
+ app.session_save_deadline = Some(now + Duration::from_secs(2));
+ app.next_auto_update_check = Some(now + Duration::from_secs(6));
+
+ assert_eq!(
+ app.next_headless_loop_deadline(now, false),
+ app.session_save_deadline
+ );
+ }
+
+ #[test]
+ fn headless_next_loop_deadline_returns_none_when_resize_poll_is_only_deadline() {
+ let mut app = test_app();
+ let now = Instant::now();
+ app.next_resize_poll = now - Duration::from_millis(1);
+ app.config_diagnostic_deadline = None;
+ app.toast_deadline = None;
+ app.next_animation_tick = None;
+ app.next_auto_update_check = None;
+ app.session_save_deadline = None;
+ app.state.workspaces.clear();
+
+ assert_eq!(app.next_headless_loop_deadline(now, false), None);
+ }
+
+ #[test]
fn due_session_save_deadline_is_cleared() {
let mut app = test_app();
app.session_save_deadline = Some(Instant::now() - Duration::from_secs(1));
diff --git a/src/app/runtime.rs b/src/app/runtime.rs
index d82f6440..b6ad806b 100644
--- a/src/app/runtime.rs
+++ b/src/app/runtime.rs
@@ -227,6 +227,23 @@ impl App {
}
pub(crate) fn next_loop_deadline(&self, now: Instant, needs_render: bool) -> Option<Instant> {
+ self.next_loop_deadline_with_resize_poll(now, needs_render, true)
+ }
+
+ pub(crate) fn next_headless_loop_deadline(
+ &self,
+ now: Instant,
+ needs_render: bool,
+ ) -> Option<Instant> {
+ self.next_loop_deadline_with_resize_poll(now, needs_render, false)
+ }
+
+ fn next_loop_deadline_with_resize_poll(
+ &self,
+ now: Instant,
+ needs_render: bool,
+ include_resize_poll: bool,
+ ) -> Option<Instant> {
let render_deadline = if needs_render {
self.last_render_at
.map(|last_render_at| last_render_at + MIN_RENDER_INTERVAL)
@@ -236,7 +253,7 @@ impl App {
};
[
- Some(self.next_resize_poll),
+ include_resize_poll.then_some(self.next_resize_poll),
self.config_diagnostic_deadline,
self.toast_deadline,
self.next_animation_tick,