Use window_builder when configuring initial window

This fixes issue #159 where the window would briefly show with default options.
This commit is contained in:
Jake Kerr 2020-08-13 15:18:10 +09:00
parent 19d2f9c2cd
commit ad446c5f60

View file

@ -15,23 +15,24 @@ impl WinitWindows {
window: &Window, window: &Window,
) { ) {
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
let winit_window = { let winit_window_builder = {
use winit::platform::windows::WindowBuilderExtWindows; use winit::platform::windows::WindowBuilderExtWindows;
winit::window::WindowBuilder::new() winit::window::WindowBuilder::new()
.with_drag_and_drop(false) .with_drag_and_drop(false)
.build(&event_loop)
.unwrap()
}; };
#[cfg(not(target_os = "windows"))] #[cfg(not(target_os = "windows"))]
let winit_window = winit::window::Window::new(&event_loop).unwrap(); let winit_window_builder = winit::window::WindowBuilder::new();
let winit_window = winit_window_builder
.with_title(&window.title)
.with_inner_size(winit::dpi::PhysicalSize::new(window.width, window.height))
.build(&event_loop)
.unwrap();
self.window_id_to_winit.insert(window.id, winit_window.id()); self.window_id_to_winit.insert(window.id, winit_window.id());
self.winit_to_window_id.insert(winit_window.id(), window.id); self.winit_to_window_id.insert(winit_window.id(), window.id);
winit_window.set_title(&window.title);
winit_window.set_inner_size(winit::dpi::PhysicalSize::new(window.width, window.height));
self.windows.insert(winit_window.id(), winit_window); self.windows.insert(winit_window.id(), winit_window);
} }