Fix invisible window on Windows

... by reverting the changes that were supposed to hide the window
initially and only show it after rendering the first frame.
This commit is contained in:
Héctor Ramón Jiménez 2022-08-26 19:48:40 +02:00
parent da7e859840
commit c08c78ad17
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
3 changed files with 12 additions and 38 deletions

View file

@ -54,17 +54,12 @@ where
runtime.enter(|| A::new(flags)) runtime.enter(|| A::new(flags))
}; };
let should_be_visible = settings.window.visible;
let context = { let context = {
let builder = settings let builder = settings.window.into_builder(
.window &application.title(),
.into_builder( event_loop.primary_monitor(),
&application.title(), settings.id,
event_loop.primary_monitor(), );
settings.id,
)
.with_visible(false);
log::info!("Window builder: {:#?}", builder); log::info!("Window builder: {:#?}", builder);
@ -139,7 +134,6 @@ where
receiver, receiver,
context, context,
init_command, init_command,
should_be_visible,
settings.exit_on_close_request, settings.exit_on_close_request,
)); ));
@ -192,7 +186,6 @@ async fn run_instance<A, E, C>(
mut receiver: mpsc::UnboundedReceiver<glutin::event::Event<'_, A::Message>>, mut receiver: mpsc::UnboundedReceiver<glutin::event::Event<'_, A::Message>>,
mut context: glutin::ContextWrapper<glutin::PossiblyCurrent, Window>, mut context: glutin::ContextWrapper<glutin::PossiblyCurrent, Window>,
init_command: Command<A::Message>, init_command: Command<A::Message>,
should_be_visible: bool,
exit_on_close_request: bool, exit_on_close_request: bool,
) where ) where
A: Application + 'static, A: Application + 'static,
@ -206,7 +199,6 @@ async fn run_instance<A, E, C>(
let mut clipboard = Clipboard::connect(context.window()); let mut clipboard = Clipboard::connect(context.window());
let mut cache = user_interface::Cache::default(); let mut cache = user_interface::Cache::default();
let mut state = application::State::new(&application, context.window()); let mut state = application::State::new(&application, context.window());
let mut visible = false;
let mut viewport_version = state.viewport_version(); let mut viewport_version = state.viewport_version();
application::run_command( application::run_command(
@ -406,12 +398,6 @@ async fn run_instance<A, E, C>(
debug.render_finished(); debug.render_finished();
if !visible && should_be_visible {
context.window().set_visible(true);
visible = true;
}
// TODO: Handle animations! // TODO: Handle animations!
// Maybe we can use `ControlFlow::WaitUntil` for this. // Maybe we can use `ControlFlow::WaitUntil` for this.
} }

View file

@ -137,15 +137,11 @@ where
runtime.enter(|| A::new(flags)) runtime.enter(|| A::new(flags))
}; };
let should_be_visible = settings.window.visible; let builder = settings.window.into_builder(
let builder = settings &application.title(),
.window event_loop.primary_monitor(),
.into_builder( settings.id,
&application.title(), );
event_loop.primary_monitor(),
settings.id,
)
.with_visible(false);
log::info!("Window builder: {:#?}", builder); log::info!("Window builder: {:#?}", builder);
@ -182,7 +178,6 @@ where
receiver, receiver,
init_command, init_command,
window, window,
should_be_visible,
settings.exit_on_close_request, settings.exit_on_close_request,
)); ));
@ -233,7 +228,6 @@ async fn run_instance<A, E, C>(
mut receiver: mpsc::UnboundedReceiver<winit::event::Event<'_, A::Message>>, mut receiver: mpsc::UnboundedReceiver<winit::event::Event<'_, A::Message>>,
init_command: Command<A::Message>, init_command: Command<A::Message>,
window: winit::window::Window, window: winit::window::Window,
should_be_visible: bool,
exit_on_close_request: bool, exit_on_close_request: bool,
) where ) where
A: Application + 'static, A: Application + 'static,
@ -247,7 +241,6 @@ async fn run_instance<A, E, C>(
let mut clipboard = Clipboard::connect(&window); let mut clipboard = Clipboard::connect(&window);
let mut cache = user_interface::Cache::default(); let mut cache = user_interface::Cache::default();
let mut surface = compositor.create_surface(&window); let mut surface = compositor.create_surface(&window);
let mut visible = false;
let mut state = State::new(&application, &window); let mut state = State::new(&application, &window);
let mut viewport_version = state.viewport_version(); let mut viewport_version = state.viewport_version();
@ -447,12 +440,6 @@ async fn run_instance<A, E, C>(
Ok(()) => { Ok(()) => {
debug.render_finished(); debug.render_finished();
if !visible && should_be_visible {
window.set_visible(true);
visible = true;
}
// TODO: Handle animations! // TODO: Handle animations!
// Maybe we can use `ControlFlow::WaitUntil` for this. // Maybe we can use `ControlFlow::WaitUntil` for this.
} }

View file

@ -106,7 +106,8 @@ impl Window {
.with_decorations(self.decorations) .with_decorations(self.decorations)
.with_transparent(self.transparent) .with_transparent(self.transparent)
.with_window_icon(self.icon) .with_window_icon(self.icon)
.with_always_on_top(self.always_on_top); .with_always_on_top(self.always_on_top)
.with_visible(self.visible);
if let Some(position) = conversion::position( if let Some(position) = conversion::position(
primary_monitor.as_ref(), primary_monitor.as_ref(),