Add FocusWindow to window::Action

This commit is contained in:
Night_Hunter 2022-12-10 01:49:29 +13:00 committed by Héctor Ramón Jiménez
parent c740b3af75
commit 81cd0c45b7
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
2 changed files with 14 additions and 0 deletions

View file

@ -58,6 +58,17 @@ pub enum Action<T> {
/// - **X11:** Requests for user attention must be manually cleared.
/// - **Wayland:** Requires `xdg_activation_v1` protocol, `None` has no effect.
RequestUserAttention(Option<UserAttention>),
/// Brings the window to the front and sets input focus. Has no effect if the window is
/// already in focus, minimized, or not visible.
///
/// This method steals input focus from other applications. Do not use this method unless
/// you are certain that's what the user wants. Focus stealing can cause an extremely disruptive
/// user experience.
///
/// ## Platform-specific
///
/// - **Web / Wayland:** Unsupported.
FocusWindow,
}
impl<T> Action<T> {
@ -83,6 +94,7 @@ impl<T> Action<T> {
Self::RequestUserAttention(attention_type) => {
Action::RequestUserAttention(attention_type)
}
Self::FocusWindow => Action::FocusWindow,
}
}
}
@ -109,6 +121,7 @@ impl<T> fmt::Debug for Action<T> {
Self::RequestUserAttention(_) => {
write!(f, "Action::RequestUserAttention")
}
Self::FocusWindow => write!(f, "Action::FocusWindow"),
}
}
}

View file

@ -678,6 +678,7 @@ pub fn run_command<A, E>(
.request_user_attention(
user_attention.map(conversion::user_attention),
),
window::Action::FocusWindow => window.focus_window(),
},
command::Action::System(action) => match action {
system::Action::QueryInformation(_tag) => {