Skip to content

Commit 4e93ae8

Browse files
authored
Merge pull request #1698 from iced-rs/hide-window-until-ready
Hide window until `Renderer` has been initialized
2 parents efbf66b + 9506fb1 commit 4e93ae8

2 files changed

Lines changed: 16 additions & 7 deletions

File tree

winit/src/application.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,15 @@ where
147147
#[cfg(target_arch = "wasm32")]
148148
let target = settings.window.platform_specific.target.clone();
149149

150-
let builder = settings.window.into_builder(
151-
&application.title(),
152-
event_loop.primary_monitor(),
153-
settings.id,
154-
);
150+
let should_be_visible = settings.window.visible;
151+
let builder = settings
152+
.window
153+
.into_builder(
154+
&application.title(),
155+
event_loop.primary_monitor(),
156+
settings.id,
157+
)
158+
.with_visible(false);
155159

156160
log::info!("Window builder: {:#?}", builder);
157161

@@ -202,6 +206,7 @@ where
202206
control_sender,
203207
init_command,
204208
window,
209+
should_be_visible,
205210
settings.exit_on_close_request,
206211
);
207212

@@ -268,6 +273,7 @@ async fn run_instance<A, E, C>(
268273
mut control_sender: mpsc::UnboundedSender<winit::event_loop::ControlFlow>,
269274
init_command: Command<A::Message>,
270275
window: winit::window::Window,
276+
should_be_visible: bool,
271277
exit_on_close_request: bool,
272278
) where
273279
A: Application + 'static,
@@ -295,6 +301,10 @@ async fn run_instance<A, E, C>(
295301
physical_size.height,
296302
);
297303

304+
if should_be_visible {
305+
window.set_visible(true);
306+
}
307+
298308
run_command(
299309
&application,
300310
&mut cache,

winit/src/settings.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,7 @@ impl Window {
114114
.with_decorations(self.decorations)
115115
.with_transparent(self.transparent)
116116
.with_window_icon(self.icon)
117-
.with_always_on_top(self.always_on_top)
118-
.with_visible(self.visible);
117+
.with_always_on_top(self.always_on_top);
119118

120119
if let Some(position) = conversion::position(
121120
primary_monitor.as_ref(),

0 commit comments

Comments
 (0)