Skip to content

Commit

Permalink
window::change_mode takes priority over initial window visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
hecrj committed Feb 11, 2023
1 parent 83a2711 commit 61367e6
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion winit/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ async fn run_instance<A, E, C>(
physical_size.height,
);

let mut window_mode_changed = false;
run_command(
&application,
&mut cache,
Expand All @@ -310,6 +311,7 @@ async fn run_instance<A, E, C>(
&mut runtime,
&mut clipboard,
&mut should_exit,
&mut window_mode_changed,
&mut proxy,
&mut debug,
&window,
Expand Down Expand Up @@ -342,7 +344,7 @@ async fn run_instance<A, E, C>(
&mut debug,
);

if should_be_visible {
if should_be_visible && !window_mode_changed {
window.set_visible(true);
}

Expand Down Expand Up @@ -397,6 +399,7 @@ async fn run_instance<A, E, C>(
&mut runtime,
&mut clipboard,
&mut should_exit,
&mut window_mode_changed,
&mut proxy,
&mut debug,
&mut messages,
Expand Down Expand Up @@ -695,6 +698,7 @@ pub fn update<A: Application, E: Executor>(
runtime: &mut Runtime<E, Proxy<A::Message>, A::Message>,
clipboard: &mut Clipboard,
should_exit: &mut bool,
window_mode_changed: &mut bool,
proxy: &mut winit::event_loop::EventLoopProxy<A::Message>,
debug: &mut Debug,
messages: &mut Vec<A::Message>,
Expand Down Expand Up @@ -725,6 +729,7 @@ pub fn update<A: Application, E: Executor>(
runtime,
clipboard,
should_exit,
window_mode_changed,
proxy,
debug,
window,
Expand All @@ -746,6 +751,7 @@ pub fn run_command<A, E>(
runtime: &mut Runtime<E, Proxy<A::Message>, A::Message>,
clipboard: &mut Clipboard,
should_exit: &mut bool,
window_mode_changed: &mut bool,
proxy: &mut winit::event_loop::EventLoopProxy<A::Message>,
debug: &mut Debug,
window: &winit::window::Window,
Expand Down Expand Up @@ -802,6 +808,8 @@ pub fn run_command<A, E>(
});
}
window::Action::ChangeMode(mode) => {
*window_mode_changed = true;

window.set_visible(conversion::visible(mode));
window.set_fullscreen(conversion::fullscreen(
window.primary_monitor(),
Expand Down

0 comments on commit 61367e6

Please sign in to comment.