diff options
Diffstat (limited to 'winit')
-rw-r--r-- | winit/src/application.rs | 29 | ||||
-rw-r--r-- | winit/src/window.rs | 25 |
2 files changed, 41 insertions, 13 deletions
diff --git a/winit/src/application.rs b/winit/src/application.rs index 692c2f74..3123a318 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -752,11 +752,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 { @@ -786,13 +786,24 @@ 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); + } + window::Action::FetchId(tag) => { + proxy + .send_event(tag(window.id().into())) + .expect("Send message to event loop"); + } }, command::Action::System(action) => match action { system::Action::QueryInformation(_tag) => { diff --git a/winit/src/window.rs b/winit/src/window.rs index 97d80c38..88cd3f14 100644 --- a/winit/src/window.rs +++ b/winit/src/window.rs @@ -38,18 +38,18 @@ pub fn resize<Message>( } /// Maximizes the window. -pub fn maximize<Message>(id: window::Id, value: bool) -> Command<Message> { +pub fn maximize<Message>(id: window::Id, maximized: bool) -> Command<Message> { Command::single(command::Action::Window( id, - window::Action::Maximize(value), + window::Action::Maximize(maximized), )) } /// Minimes the window. -pub fn minimize<Message>(id: window::Id, value: bool) -> Command<Message> { +pub fn minimize<Message>(id: window::Id, minimized: bool) -> Command<Message> { Command::single(command::Action::Window( id, - window::Action::Minimize(value), + window::Action::Minimize(minimized), )) } @@ -109,3 +109,20 @@ pub fn request_user_attention<Message>( pub fn gain_focus<Message>(id: window::Id) -> Command<Message> { Command::single(command::Action::Window(id, window::Action::GainFocus)) } + +/// Changes whether or not the window will always be on top of other windows. +pub fn change_always_on_top<Message>(id: window::Id, on_top: bool) -> Command<Message> { + Command::single(command::Action::Window(id, window::Action::ChangeAlwaysOnTop( + on_top, + ))) +} + +/// Fetches an identifier unique to the window. +pub fn fetch_id<Message>( + id: window::Id, + f: impl FnOnce(u64) -> Message + 'static, +) -> Command<Message> { + Command::single(command::Action::Window(id: window::Id, window::Action::FetchId(Box::new( + f, + )))) +} |