diff options
author | 2019-12-03 07:20:22 +0100 | |
---|---|---|
committer | 2019-12-03 07:20:22 +0100 | |
commit | 7756081fdbc93aee3f5d11fbd14e3d9f2cbefe57 (patch) | |
tree | 4dfbc85275a853a168aa68f3b51da6d55d09146b /winit/src/application.rs | |
parent | 369ed9bc2e3c09666458bd0a0c0834a402239b3f (diff) | |
download | iced-7756081fdbc93aee3f5d11fbd14e3d9f2cbefe57.tar.gz iced-7756081fdbc93aee3f5d11fbd14e3d9f2cbefe57.tar.bz2 iced-7756081fdbc93aee3f5d11fbd14e3d9f2cbefe57.zip |
Refactor window creation in `iced_winit`
Diffstat (limited to 'winit/src/application.rs')
-rw-r--r-- | winit/src/application.rs | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/winit/src/application.rs b/winit/src/application.rs index a75d57af..00625052 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -96,25 +96,12 @@ pub trait Application: Sized { let mut title = application.title(); - let (width, height) = settings.window.size; - - #[cfg(not(target_os = "windows"))] - let window = WindowBuilder::new() - .with_title(&title) - .with_inner_size(winit::dpi::LogicalSize { - width: f64::from(width), - height: f64::from(height), - }) - .with_resizable(settings.window.resizable) - .with_decorations(settings.window.decorations) - .build(&event_loop) - .expect("Open window"); - - #[cfg(target_os = "windows")] let window = { - use winit::platform::windows::WindowBuilderExtWindows; + let mut window_builder = WindowBuilder::new(); - let mut window_builder = WindowBuilder::new() + let (width, height) = settings.window.size; + + window_builder = window_builder .with_title(&title) .with_inner_size(winit::dpi::LogicalSize { width: f64::from(width), @@ -123,8 +110,13 @@ pub trait Application: Sized { .with_resizable(settings.window.resizable) .with_decorations(settings.window.decorations); - if let Some(parent) = settings.window.platform_specific.parent { - window_builder = window_builder.with_parent_window(parent); + #[cfg(target_os = "windows")] + { + use winit::platform::windows::WindowBuilderExtWindows; + + if let Some(parent) = settings.window.platform_specific.parent { + window_builder = window_builder.with_parent_window(parent); + } } window_builder.build(&event_loop).expect("Open window") |