From 61367e6dbf60ed2f1a9dfde9ceada4a074f6e0d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Sat, 11 Feb 2023 03:56:53 +0100 Subject: [PATCH] `window::change_mode` takes priority over initial window visibility --- winit/src/application.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/winit/src/application.rs b/winit/src/application.rs index 3c0599792e..e5622f0ad5 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -301,6 +301,7 @@ async fn run_instance( physical_size.height, ); + let mut window_mode_changed = false; run_command( &application, &mut cache, @@ -310,6 +311,7 @@ async fn run_instance( &mut runtime, &mut clipboard, &mut should_exit, + &mut window_mode_changed, &mut proxy, &mut debug, &window, @@ -342,7 +344,7 @@ async fn run_instance( &mut debug, ); - if should_be_visible { + if should_be_visible && !window_mode_changed { window.set_visible(true); } @@ -397,6 +399,7 @@ async fn run_instance( &mut runtime, &mut clipboard, &mut should_exit, + &mut window_mode_changed, &mut proxy, &mut debug, &mut messages, @@ -695,6 +698,7 @@ pub fn update( runtime: &mut Runtime, A::Message>, clipboard: &mut Clipboard, should_exit: &mut bool, + window_mode_changed: &mut bool, proxy: &mut winit::event_loop::EventLoopProxy, debug: &mut Debug, messages: &mut Vec, @@ -725,6 +729,7 @@ pub fn update( runtime, clipboard, should_exit, + window_mode_changed, proxy, debug, window, @@ -746,6 +751,7 @@ pub fn run_command( runtime: &mut Runtime, A::Message>, clipboard: &mut Clipboard, should_exit: &mut bool, + window_mode_changed: &mut bool, proxy: &mut winit::event_loop::EventLoopProxy, debug: &mut Debug, window: &winit::window::Window, @@ -802,6 +808,8 @@ pub fn run_command( }); } window::Action::ChangeMode(mode) => { + *window_mode_changed = true; + window.set_visible(conversion::visible(mode)); window.set_fullscreen(conversion::fullscreen( window.primary_monitor(),