From a620665bedd00f5cfe11c1b0024a6b99085d3d79 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Fri, 13 May 2022 13:57:39 -0600 Subject: [PATCH] Only synthesize mouse moves on scene construction if window is active --- crates/gpui/src/app.rs | 7 +++++++ crates/gpui/src/presenter.rs | 6 ++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/crates/gpui/src/app.rs b/crates/gpui/src/app.rs index 3aba2cbffba0c71c82aae899a66178748718c33e..4fc5dc564cc0e4c1cc3aaa117a7d7485922c9df5 100644 --- a/crates/gpui/src/app.rs +++ b/crates/gpui/src/app.rs @@ -1005,6 +1005,13 @@ impl MutableAppContext { .and_then(|window| window.root_view.clone().downcast::()) } + pub fn window_is_active(&self, window_id: usize) -> bool { + self.cx + .windows + .get(&window_id) + .map_or(false, |window| window.is_active) + } + pub fn render_view( &mut self, window_id: usize, diff --git a/crates/gpui/src/presenter.rs b/crates/gpui/src/presenter.rs index a7d715fadf2fb68b957702d052c54c25aec35980..451f14567a1acc5e1fb69683cc8dc20c02e4624b 100644 --- a/crates/gpui/src/presenter.rs +++ b/crates/gpui/src/presenter.rs @@ -122,8 +122,10 @@ impl Presenter { self.text_layout_cache.finish_frame(); self.cursor_styles = scene.cursor_styles(); - if let Some(event) = self.last_mouse_moved_event.clone() { - self.dispatch_event(event, cx) + if cx.window_is_active(self.window_id) { + if let Some(event) = self.last_mouse_moved_event.clone() { + self.dispatch_event(event, cx) + } } } else { log::error!("could not find root_view_id for window {}", self.window_id);