From a490fd54c9b262c9d8ac946f75a0016fbb81848b Mon Sep 17 00:00:00 2001 From: Katherine Philip Date: Mon, 17 Aug 2020 15:38:02 +0700 Subject: [PATCH 1/3] Add 'transparent' in window setting --- src/window/settings.rs | 5 +++++ winit/src/settings.rs | 15 ++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/window/settings.rs b/src/window/settings.rs index 2046f2d9..7bc49ce1 100644 --- a/src/window/settings.rs +++ b/src/window/settings.rs @@ -18,6 +18,9 @@ pub struct Settings { /// Whether the window should have a border, a title bar, etc. or not. pub decorations: bool, + /// Whether the window should be transparent + pub transparent: bool, + /// The icon of the window. pub icon: Option, } @@ -30,6 +33,7 @@ impl Default for Settings { max_size: None, resizable: true, decorations: true, + transparent: false, icon: None, } } @@ -44,6 +48,7 @@ impl From for iced_winit::settings::Window { max_size: settings.max_size, resizable: settings.resizable, decorations: settings.decorations, + transparent: settings.transparent, icon: settings.icon.map(Icon::into), platform_specific: Default::default(), } diff --git a/winit/src/settings.rs b/winit/src/settings.rs index 4155bf7d..418c7582 100644 --- a/winit/src/settings.rs +++ b/winit/src/settings.rs @@ -45,6 +45,8 @@ pub struct Window { /// Whether the window should have a border, a title bar, etc. pub decorations: bool, + pub transparent: bool, + /// The window icon, which is also usually used in the taskbar pub icon: Option, @@ -64,11 +66,13 @@ impl Window { let (width, height) = self.size; + println!("patched window with trasparent"); window_builder = window_builder .with_title(title) .with_inner_size(winit::dpi::LogicalSize { width, height }) .with_resizable(self.resizable) .with_decorations(self.decorations) + .with_transparent(self.transparent) .with_window_icon(self.icon) .with_fullscreen(conversion::fullscreen(primary_monitor, mode)); @@ -83,13 +87,13 @@ impl Window { } #[cfg(target_os = "windows")] - { - use winit::platform::windows::WindowBuilderExtWindows; + { + use winit::platform::windows::WindowBuilderExtWindows; - if let Some(parent) = self.platform_specific.parent { - window_builder = window_builder.with_parent_window(parent); + if let Some(parent) = self.platform_specific.parent { + window_builder = window_builder.with_parent_window(parent); + } } - } window_builder } @@ -103,6 +107,7 @@ impl Default for Window { max_size: None, resizable: true, decorations: true, + transparent: false, icon: None, platform_specific: Default::default(), } From fe75646f8234a25fc5b9217247d773dd62bb017b Mon Sep 17 00:00:00 2001 From: Katherine Philip Date: Tue, 18 Aug 2020 05:54:55 +0700 Subject: [PATCH 2/3] Add missing comment --- winit/src/settings.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/winit/src/settings.rs b/winit/src/settings.rs index 418c7582..85168eb7 100644 --- a/winit/src/settings.rs +++ b/winit/src/settings.rs @@ -45,6 +45,7 @@ pub struct Window { /// Whether the window should have a border, a title bar, etc. pub decorations: bool, + /// Whether the window should be transparent pub transparent: bool, /// The window icon, which is also usually used in the taskbar From 6de9a5e076889350a361899ca2356dddf5b1d18f Mon Sep 17 00:00:00 2001 From: Katherine Philip Date: Tue, 18 Aug 2020 05:56:15 +0700 Subject: [PATCH 3/3] Remove debug println & accidentally added whitespace --- winit/src/settings.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/winit/src/settings.rs b/winit/src/settings.rs index 85168eb7..92541e7d 100644 --- a/winit/src/settings.rs +++ b/winit/src/settings.rs @@ -67,7 +67,6 @@ impl Window { let (width, height) = self.size; - println!("patched window with trasparent"); window_builder = window_builder .with_title(title) .with_inner_size(winit::dpi::LogicalSize { width, height }) @@ -88,13 +87,13 @@ impl Window { } #[cfg(target_os = "windows")] - { - use winit::platform::windows::WindowBuilderExtWindows; + { + use winit::platform::windows::WindowBuilderExtWindows; - if let Some(parent) = self.platform_specific.parent { - window_builder = window_builder.with_parent_window(parent); - } + if let Some(parent) = self.platform_specific.parent { + window_builder = window_builder.with_parent_window(parent); } + } window_builder }