From 277b848ad8df1e8d038e33707548a45d63a601db Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 18 Jul 2022 18:37:41 +0200 Subject: Remove `window::Mode` and introduce `Settings::visible` Additionally, only show the window once one frame has been rendered to avoid blank flashes on Windows. --- glutin/src/application.rs | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'glutin/src/application.rs') diff --git a/glutin/src/application.rs b/glutin/src/application.rs index 24f315fb..054cf839 100644 --- a/glutin/src/application.rs +++ b/glutin/src/application.rs @@ -54,13 +54,17 @@ where runtime.enter(|| A::new(flags)) }; + let should_be_visible = settings.window.visible; + let context = { - let builder = settings.window.into_builder( - &application.title(), - application.mode(), - event_loop.primary_monitor(), - settings.id, - ); + let builder = settings + .window + .into_builder( + &application.title(), + event_loop.primary_monitor(), + settings.id, + ) + .with_visible(false); log::info!("Window builder: {:#?}", builder); @@ -135,6 +139,7 @@ where receiver, context, init_command, + should_be_visible, settings.exit_on_close_request, )); @@ -187,6 +192,7 @@ async fn run_instance( mut receiver: mpsc::UnboundedReceiver>, mut context: glutin::ContextWrapper, init_command: Command, + should_be_visible: bool, exit_on_close_request: bool, ) where A: Application + 'static, @@ -200,6 +206,7 @@ async fn run_instance( let mut clipboard = Clipboard::connect(context.window()); let mut cache = user_interface::Cache::default(); let mut state = application::State::new(&application, context.window()); + let mut visible = false; let mut viewport_version = state.viewport_version(); application::run_command( @@ -399,6 +406,12 @@ async fn run_instance( debug.render_finished(); + if !visible && should_be_visible { + context.window().set_visible(true); + + visible = true; + } + // TODO: Handle animations! // Maybe we can use `ControlFlow::WaitUntil` for this. } -- cgit