1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-31 05:40:03 -04:00

eframe: Don't show window until after initialization (#2279)

* Don't show window until after initialization

Shortens #1802, but does not completely solve it

* format code

* Present first frame immediately before showing window

This resolves the white flash almost completely, but is a hack. Window
visibility should be derived from the AppOutput, and the first frame
should not be painted before the event loop has processed initial
events.

Working on a better implementation.

* Integrate window showing with AppOutput

This allows an app to keep the window hidden (never shown) by calling
Frame.set_visible(false) on the first update. This includes a slightly
less nasty hack than the last commit did.

Also fixes an accidental cross-contamination of pull requests.

* fmt

* add comments

* add comments

* add comments

* add comments

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
This commit is contained in:
LoganDark
2022-11-13 11:30:52 -08:00
committed by GitHub
parent 5bac853d9c
commit f0f41d60e1
2 changed files with 19 additions and 8 deletions

View File

@@ -349,8 +349,9 @@ mod glow_integration {
};
let window_settings = epi_integration::load_window_settings(storage);
let window_builder =
epi_integration::window_builder(native_options, &window_settings).with_title(title);
let window_builder = epi_integration::window_builder(native_options, &window_settings)
.with_title(title)
.with_visible(false); // Keep hidden until we've painted something. See https://github.com/emilk/egui/pull/2279
let gl_window = unsafe {
glutin::ContextBuilder::new()
@@ -512,6 +513,8 @@ mod glow_integration {
gl_window.swap_buffers().unwrap();
}
integration.post_present(window);
let control_flow = if integration.should_close() {
EventResult::Exit
} else if repaint_after.is_zero() {
@@ -733,6 +736,7 @@ mod wgpu_integration {
let window_settings = epi_integration::load_window_settings(storage);
epi_integration::window_builder(native_options, &window_settings)
.with_title(title)
.with_visible(false) // Keep hidden until we've painted something. See https://github.com/emilk/egui/pull/2279
.build(event_loop)
.unwrap()
}
@@ -891,6 +895,7 @@ mod wgpu_integration {
);
integration.post_rendering(app.as_mut(), window);
integration.post_present(window);
let control_flow = if integration.should_close() {
EventResult::Exit