diff options
-rw-r--r-- | native/src/window/action.rs | 24 | ||||
-rw-r--r-- | winit/src/application.rs | 24 | ||||
-rw-r--r-- | winit/src/window.rs | 19 |
3 files changed, 50 insertions, 17 deletions
diff --git a/native/src/window/action.rs b/native/src/window/action.rs index 168974bc..c6361449 100644 --- a/native/src/window/action.rs +++ b/native/src/window/action.rs @@ -70,6 +70,12 @@ pub enum Action<T> { /// /// - **Web / Wayland:** Unsupported. GainFocus, + /// Change whether or not the window will always be on top of other windows. + /// + /// ## Platform-specific + /// + /// - **Web / Wayland:** Unsupported. + ChangeAlwaysOnTop(bool), } impl<T> Action<T> { @@ -85,8 +91,8 @@ impl<T> Action<T> { Self::Close => Action::Close, Self::Drag => Action::Drag, Self::Resize { width, height } => Action::Resize { width, height }, - Self::Maximize(bool) => Action::Maximize(bool), - Self::Minimize(bool) => Action::Minimize(bool), + Self::Maximize(maximized) => Action::Maximize(maximized), + Self::Minimize(minimized) => Action::Minimize(minimized), Self::Move { x, y } => Action::Move { x, y }, Self::ChangeMode(mode) => Action::ChangeMode(mode), Self::FetchMode(o) => Action::FetchMode(Box::new(move |s| f(o(s)))), @@ -96,6 +102,9 @@ impl<T> Action<T> { Action::RequestUserAttention(attention_type) } Self::GainFocus => Action::GainFocus, + Self::ChangeAlwaysOnTop(on_top) => { + Action::ChangeAlwaysOnTop(on_top) + } } } } @@ -109,8 +118,12 @@ impl<T> fmt::Debug for Action<T> { f, "Action::Resize {{ widget: {width}, height: {height} }}" ), - Self::Maximize(value) => write!(f, "Action::Maximize({value})"), - Self::Minimize(value) => write!(f, "Action::Minimize({value}"), + Self::Maximize(maximized) => { + write!(f, "Action::Maximize({maximized})") + } + Self::Minimize(minimized) => { + write!(f, "Action::Minimize({minimized}") + } Self::Move { x, y } => { write!(f, "Action::Move {{ x: {x}, y: {y} }}") } @@ -122,6 +135,9 @@ impl<T> fmt::Debug for Action<T> { write!(f, "Action::RequestUserAttention") } Self::GainFocus => write!(f, "Action::GainFocus"), + Self::ChangeAlwaysOnTop(on_top) => { + write!(f, "Action::AlwaysOnTop({on_top})") + } } } } diff --git a/winit/src/application.rs b/winit/src/application.rs index 769fe9dd..1f37ffef 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -747,11 +747,11 @@ pub fn run_command<A, E>( height, }); } - window::Action::Maximize(value) => { - window.set_maximized(value); + window::Action::Maximize(maximized) => { + window.set_maximized(maximized); } - window::Action::Minimize(value) => { - window.set_minimized(value); + window::Action::Minimize(minimized) => { + window.set_minimized(minimized); } window::Action::Move { x, y } => { window.set_outer_position(winit::dpi::LogicalPosition { @@ -781,13 +781,19 @@ pub fn run_command<A, E>( window.set_maximized(!window.is_maximized()) } window::Action::ToggleDecorations => { - window.set_decorations(!window.is_decorated()) + window.set_decorations(!window.is_decorated()); } - window::Action::RequestUserAttention(user_attention) => window - .request_user_attention( + window::Action::RequestUserAttention(user_attention) => { + window.request_user_attention( user_attention.map(conversion::user_attention), - ), - window::Action::GainFocus => window.focus_window(), + ); + } + window::Action::GainFocus => { + window.focus_window(); + } + window::Action::ChangeAlwaysOnTop(on_top) => { + window.set_always_on_top(on_top); + } }, command::Action::System(action) => match action { system::Action::QueryInformation(_tag) => { diff --git a/winit/src/window.rs b/winit/src/window.rs index 6e3a383a..3d5a765b 100644 --- a/winit/src/window.rs +++ b/winit/src/window.rs @@ -23,13 +23,17 @@ pub fn resize<Message>(width: u32, height: u32) -> Command<Message> { } /// Maximizes the window. -pub fn maximize<Message>(value: bool) -> Command<Message> { - Command::single(command::Action::Window(window::Action::Maximize(value))) +pub fn maximize<Message>(maximized: bool) -> Command<Message> { + Command::single(command::Action::Window(window::Action::Maximize( + maximized, + ))) } /// Minimes the window. -pub fn minimize<Message>(value: bool) -> Command<Message> { - Command::single(command::Action::Window(window::Action::Minimize(value))) +pub fn minimize<Message>(minimized: bool) -> Command<Message> { + Command::single(command::Action::Window(window::Action::Minimize( + minimized, + ))) } /// Moves a window to the given logical coordinates. @@ -84,3 +88,10 @@ pub fn request_user_attention<Message>( pub fn gain_focus<Message>() -> Command<Message> { Command::single(command::Action::Window(window::Action::GainFocus)) } + +/// Changes whether or not the window will always be on top of other windows. +pub fn change_always_on_top<Message>(on_top: bool) -> Command<Message> { + Command::single(command::Action::Window(window::Action::ChangeAlwaysOnTop( + on_top, + ))) +} |