From 765c3f9c18e7de60a4a355c2638cdd8739ba6f12 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Tue, 6 Apr 2021 06:29:42 -0600 Subject: [PATCH] Open platform window before first invalidation This ensures we have an invalidation handler present so we render the first frame in all cases. --- gpui/src/app.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/gpui/src/app.rs b/gpui/src/app.rs index 20560fe6fe..8dbc34b893 100644 --- a/gpui/src/app.rs +++ b/gpui/src/app.rs @@ -380,6 +380,7 @@ impl MutableAppContext { ) { self.invalidation_callbacks .insert(window_id, Box::new(callback)); + self.update_windows(); } pub fn add_action(&mut self, name: S, mut handler: F) @@ -612,13 +613,19 @@ impl MutableAppContext { T: View, F: FnOnce(&mut ViewContext) -> T, { + self.pending_flushes += 1; let window_id = post_inc(&mut self.next_window_id); self.ctx.windows.insert(window_id, Window::default()); - + self.open_platform_window(window_id); let root_handle = self.add_view(window_id, build_root_view); self.ctx.windows.get_mut(&window_id).unwrap().root_view = Some(root_handle.clone().into()); self.focus(window_id, root_handle.id()); + self.flush_effects(); + (window_id, root_handle) + } + + fn open_platform_window(&mut self, window_id: usize) { match self.platform.open_window( WindowOptions { bounds: RectF::new(vec2f(0., 0.), vec2f(1024., 768.)), @@ -693,8 +700,6 @@ impl MutableAppContext { }); } } - - (window_id, root_handle) } pub fn add_view(&mut self, window_id: usize, build_view: F) -> ViewHandle