diff options
author | 2020-01-16 04:54:48 +0100 | |
---|---|---|
committer | 2020-01-16 04:54:48 +0100 | |
commit | d6b20d3e796951e6b42726fddc78fbb1b9aaa094 (patch) | |
tree | ad48fcbb6f1c9bd3724fdd781691d2de8ee6871e /winit/src/application.rs | |
parent | 17873774502b20cdcaaf96f88f6f6c705f91e15c (diff) | |
download | iced-d6b20d3e796951e6b42726fddc78fbb1b9aaa094.tar.gz iced-d6b20d3e796951e6b42726fddc78fbb1b9aaa094.tar.bz2 iced-d6b20d3e796951e6b42726fddc78fbb1b9aaa094.zip |
Add `Application::mode` to `iced_winit`
Diffstat (limited to 'winit/src/application.rs')
-rw-r--r-- | winit/src/application.rs | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/winit/src/application.rs b/winit/src/application.rs index a712632e..3de0476f 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -72,6 +72,18 @@ pub trait Application: Sized { /// [`Application`]: trait.Application.html fn view(&mut self) -> Element<'_, Self::Message, Self::Renderer>; + /// Returns the current [`Application`] mode. + /// + /// The runtime will automatically transition your application if a new mode + /// is returned. + /// + /// By default, an application will run in windowed mode. + /// + /// [`Application`]: trait.Application.html + fn mode(&self) -> window::Mode { + window::Mode::Windowed + } + /// Runs the [`Application`]. /// /// This method will take control of the current thread and __will NOT @@ -110,6 +122,7 @@ pub trait Application: Sized { subscription_pool.update(subscription, &mut thread_pool, &proxy); let mut title = application.title(); + let mut mode = application.mode(); let window = { let mut window_builder = WindowBuilder::new(); @@ -123,7 +136,11 @@ pub trait Application: Sized { height: f64::from(height), }) .with_resizable(settings.window.resizable) - .with_decorations(settings.window.decorations); + .with_decorations(settings.window.decorations) + .with_fullscreen(conversion::fullscreen( + event_loop.primary_monitor(), + mode, + )); #[cfg(target_os = "windows")] { @@ -244,6 +261,18 @@ pub trait Application: Sized { title = new_title; } + // Update window mode + let new_mode = application.mode(); + + if mode != new_mode { + window.set_fullscreen(conversion::fullscreen( + window.current_monitor(), + new_mode, + )); + + mode = new_mode; + } + let user_interface = build_user_interface( &mut application, temp_cache, |