From 11f5527d7645619f49b030e30485f24ac637efbd Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 18 Aug 2022 14:39:15 +0200 Subject: Implement `SetMode` and `FetchMode` window actions --- winit/src/window.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'winit/src/window.rs') diff --git a/winit/src/window.rs b/winit/src/window.rs index f3207e68..265139f7 100644 --- a/winit/src/window.rs +++ b/winit/src/window.rs @@ -2,7 +2,7 @@ use crate::command::{self, Command}; use iced_native::window; -pub use window::Event; +pub use window::{Event, Mode}; /// Resizes the window to the given logical dimensions. pub fn resize(width: u32, height: u32) -> Command { @@ -16,3 +16,17 @@ pub fn resize(width: u32, height: u32) -> Command { pub fn move_to(x: i32, y: i32) -> Command { Command::single(command::Action::Window(window::Action::Move { x, y })) } + +/// Sets the [`Mode`] of the window. +pub fn set_mode(mode: Mode) -> Command { + Command::single(command::Action::Window(window::Action::SetMode(mode))) +} + +/// Fetches the current [`Mode`] of the window. +pub fn fetch_mode( + f: impl FnOnce(Mode) -> Message + 'static, +) -> Command { + Command::single(command::Action::Window(window::Action::FetchMode( + Box::new(f), + ))) +} -- cgit