diff --git a/src/application.rs b/src/application.rs index 7b7de6d4..ee532e0b 100644 --- a/src/application.rs +++ b/src/application.rs @@ -277,6 +277,7 @@ where match self.0.mode() { window::Mode::Windowed => iced_winit::Mode::Windowed, window::Mode::Fullscreen => iced_winit::Mode::Fullscreen, + window::Mode::Hidden => iced_winit::Mode::Hidden, } } diff --git a/src/window/mode.rs b/src/window/mode.rs index 37464711..fdce8e23 100644 --- a/src/window/mode.rs +++ b/src/window/mode.rs @@ -6,4 +6,7 @@ pub enum Mode { /// The application takes the whole screen of its current monitor. Fullscreen, + + /// The application is hidden + Hidden, } diff --git a/winit/src/application/state.rs b/winit/src/application/state.rs index 46297370..b54d3aed 100644 --- a/winit/src/application/state.rs +++ b/winit/src/application/state.rs @@ -182,6 +182,8 @@ impl State { new_mode, )); + window.set_visible(conversion::visible(new_mode)); + self.mode = new_mode; } diff --git a/winit/src/conversion.rs b/winit/src/conversion.rs index 0fa27413..b850a805 100644 --- a/winit/src/conversion.rs +++ b/winit/src/conversion.rs @@ -141,13 +141,21 @@ pub fn fullscreen( mode: Mode, ) -> Option { match mode { - Mode::Windowed => None, + Mode::Windowed | Mode::Hidden => None, Mode::Fullscreen => { Some(winit::window::Fullscreen::Borderless(monitor)) } } } +/// Converts a [`Mode`] to a visibility flag. +pub fn visible(mode: Mode) -> bool { + match mode { + Mode::Windowed | Mode::Fullscreen => true, + Mode::Hidden => false, + } +} + /// Converts a `MouseCursor` from [`iced_native`] to a [`winit`] cursor icon. /// /// [`winit`]: https://github.com/rust-windowing/winit diff --git a/winit/src/mode.rs b/winit/src/mode.rs index 37464711..fdce8e23 100644 --- a/winit/src/mode.rs +++ b/winit/src/mode.rs @@ -6,4 +6,7 @@ pub enum Mode { /// The application takes the whole screen of its current monitor. Fullscreen, + + /// The application is hidden + Hidden, } diff --git a/winit/src/settings.rs b/winit/src/settings.rs index 9ce5cfc5..663fa07a 100644 --- a/winit/src/settings.rs +++ b/winit/src/settings.rs @@ -80,7 +80,8 @@ impl Window { .with_transparent(self.transparent) .with_window_icon(self.icon) .with_always_on_top(self.always_on_top) - .with_fullscreen(conversion::fullscreen(primary_monitor, mode)); + .with_fullscreen(conversion::fullscreen(primary_monitor, mode)) + .with_visible(conversion::visible(mode)); if let Some((width, height)) = self.min_size { window_builder = window_builder