Remove window::Mode and introduce Settings::visible

Additionally, only show the window once one frame has been rendered to avoid blank flashes on Windows.
This commit is contained in:
Héctor Ramón Jiménez 2022-07-18 18:37:41 +02:00
parent 07cbed1064
commit 277b848ad8
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
11 changed files with 52 additions and 121 deletions

View file

@ -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<A, E, C>(
mut receiver: mpsc::UnboundedReceiver<glutin::event::Event<'_, A::Message>>,
mut context: glutin::ContextWrapper<glutin::PossiblyCurrent, Window>,
init_command: Command<A::Message>,
should_be_visible: bool,
exit_on_close_request: bool,
) where
A: Application + 'static,
@ -200,6 +206,7 @@ async fn run_instance<A, E, C>(
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<A, E, C>(
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.
}