From 81cd0c45b7f18d6f695c16bb1f5ab05b29dc7037 Mon Sep 17 00:00:00 2001 From: Night_Hunter Date: Sat, 10 Dec 2022 01:49:29 +1300 Subject: Add `FocusWindow` to `window::Action` --- native/src/window/action.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'native/src') diff --git a/native/src/window/action.rs b/native/src/window/action.rs index f0fe845d..41d41ee7 100644 --- a/native/src/window/action.rs +++ b/native/src/window/action.rs @@ -58,6 +58,17 @@ pub enum Action { /// - **X11:** Requests for user attention must be manually cleared. /// - **Wayland:** Requires `xdg_activation_v1` protocol, `None` has no effect. RequestUserAttention(Option), + /// 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 Action { @@ -83,6 +94,7 @@ impl Action { Self::RequestUserAttention(attention_type) => { Action::RequestUserAttention(attention_type) } + Self::FocusWindow => Action::FocusWindow, } } } @@ -109,6 +121,7 @@ impl fmt::Debug for Action { Self::RequestUserAttention(_) => { write!(f, "Action::RequestUserAttention") } + Self::FocusWindow => write!(f, "Action::FocusWindow"), } } } -- cgit From dd25e93be0d5e5772bf535de38894f285cfb7768 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 2 Jan 2023 21:14:41 +0100 Subject: Rename `FocusWindow` to `GainFocus` in `window::Action` --- native/src/window/action.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'native/src') diff --git a/native/src/window/action.rs b/native/src/window/action.rs index 41d41ee7..37fcc273 100644 --- a/native/src/window/action.rs +++ b/native/src/window/action.rs @@ -68,7 +68,7 @@ pub enum Action { /// ## Platform-specific /// /// - **Web / Wayland:** Unsupported. - FocusWindow, + GainFocus, } impl Action { @@ -94,7 +94,7 @@ impl Action { Self::RequestUserAttention(attention_type) => { Action::RequestUserAttention(attention_type) } - Self::FocusWindow => Action::FocusWindow, + Self::GainFocus => Action::GainFocus, } } } @@ -121,7 +121,7 @@ impl fmt::Debug for Action { Self::RequestUserAttention(_) => { write!(f, "Action::RequestUserAttention") } - Self::FocusWindow => write!(f, "Action::FocusWindow"), + Self::GainFocus => write!(f, "Action::GainFocus"), } } } -- cgit