revert idle

Junkui Zhang created

Change summary

crates/gpui/src/platform.rs                | 2 +-
crates/gpui/src/platform/windows/window.rs | 6 +++---
crates/gpui/src/window.rs                  | 6 +-----
3 files changed, 5 insertions(+), 9 deletions(-)

Detailed changes

crates/gpui/src/platform.rs 🔗

@@ -479,7 +479,7 @@ pub(crate) trait PlatformWindow: HasWindowHandle + HasDisplayHandle {
     fn zoom(&self);
     fn toggle_fullscreen(&self);
     fn is_fullscreen(&self) -> bool;
-    fn on_request_frame(&self, callback: Box<dyn FnMut(RequestFrameOptions) -> bool>);
+    fn on_request_frame(&self, callback: Box<dyn FnMut(RequestFrameOptions)>);
     fn on_input(&self, callback: Box<dyn FnMut(PlatformInput) -> DispatchEventResult>);
     fn on_active_status_change(&self, callback: Box<dyn FnMut(bool)>);
     fn on_hover_status_change(&self, callback: Box<dyn FnMut(bool)>);

crates/gpui/src/platform/windows/window.rs 🔗

@@ -38,7 +38,7 @@ pub struct WindowsWindowState {
     pub border_offset: WindowBorderOffset,
     pub appearance: WindowAppearance,
     pub scale_factor: f32,
-    pub restore_from_minimized: Option<Box<dyn FnMut(RequestFrameOptions) -> bool>>,
+    pub restore_from_minimized: Option<Box<dyn FnMut(RequestFrameOptions)>>,
 
     pub callbacks: Callbacks,
     pub input_handler: Option<PlatformInputHandler>,
@@ -312,7 +312,7 @@ impl WindowsWindowStatePtr {
 
 #[derive(Default)]
 pub(crate) struct Callbacks {
-    pub(crate) request_frame: Option<Box<dyn FnMut(RequestFrameOptions) -> bool>>,
+    pub(crate) request_frame: Option<Box<dyn FnMut(RequestFrameOptions)>>,
     pub(crate) input: Option<Box<dyn FnMut(crate::PlatformInput) -> DispatchEventResult>>,
     pub(crate) active_status_change: Option<Box<dyn FnMut(bool)>>,
     pub(crate) hovered_status_change: Option<Box<dyn FnMut(bool)>>,
@@ -734,7 +734,7 @@ impl PlatformWindow for WindowsWindow {
         self.0.state.borrow().is_fullscreen()
     }
 
-    fn on_request_frame(&self, callback: Box<dyn FnMut(RequestFrameOptions) -> bool>) {
+    fn on_request_frame(&self, callback: Box<dyn FnMut(RequestFrameOptions)>) {
         self.0.state.borrow_mut().callbacks.request_frame = Some(callback);
     }
 

crates/gpui/src/window.rs 🔗

@@ -1012,7 +1012,6 @@ impl Window {
                         .log_err();
                 }
 
-                let invalidator_is_dirty = invalidator.is_dirty();
                 // Keep presenting the current scene for 1 extra second since the
                 // last input to prevent the display from underclocking the refresh rate.
                 let needs_present = request_frame_options.require_presentation
@@ -1020,7 +1019,7 @@ impl Window {
                     || (active.get()
                         && last_input_timestamp.get().elapsed() < Duration::from_secs(1));
 
-                if invalidator_is_dirty {
+                if invalidator.is_dirty() {
                     measure("frame duration", || {
                         handle
                             .update(&mut cx, |_, window, cx| {
@@ -1042,9 +1041,6 @@ impl Window {
                         window.complete_frame();
                     })
                     .log_err();
-
-                // Return true if app is idle
-                !(invalidator_is_dirty || needs_present)
             }
         }));
         platform_window.on_resize(Box::new({