diff options
Diffstat (limited to 'native/src/window/action.rs')
-rw-r--r-- | native/src/window/action.rs | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/native/src/window/action.rs b/native/src/window/action.rs index 009dcc27..f0fe845d 100644 --- a/native/src/window/action.rs +++ b/native/src/window/action.rs @@ -1,10 +1,12 @@ -use crate::window::Mode; +use crate::window::{Mode, UserAttention}; use iced_futures::MaybeSend; use std::fmt; /// An operation to be performed on some window. pub enum Action<T> { + /// Closes the current window and exits the application. + Close, /// Moves the window with the left mouse button until the button is /// released. /// @@ -33,10 +35,29 @@ pub enum Action<T> { }, /// Set the [`Mode`] of the window. SetMode(Mode), - /// Sets the window to maximized or back - ToggleMaximize, /// Fetch the current [`Mode`] of the window. FetchMode(Box<dyn FnOnce(Mode) -> T + 'static>), + /// Sets the window to maximized or back + ToggleMaximize, + /// Toggles whether window has decorations + /// ## Platform-specific + /// - **X11:** Not implemented. + /// - **Web:** Unsupported. + ToggleDecorations, + /// Requests user attention to the window, this has no effect if the application + /// is already focused. How requesting for user attention manifests is platform dependent, + /// see [`UserAttentionType`] for details. + /// + /// Providing `None` will unset the request for user attention. Unsetting the request for + /// user attention might not be done automatically by the WM when the window receives input. + /// + /// ## Platform-specific + /// + /// - **iOS / Android / Web:** Unsupported. + /// - **macOS:** `None` has no effect. + /// - **X11:** Requests for user attention must be manually cleared. + /// - **Wayland:** Requires `xdg_activation_v1` protocol, `None` has no effect. + RequestUserAttention(Option<UserAttention>), } impl<T> Action<T> { @@ -49,14 +70,19 @@ impl<T> Action<T> { T: 'static, { match self { + 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::Move { x, y } => Action::Move { x, y }, Self::SetMode(mode) => Action::SetMode(mode), - Self::ToggleMaximize => Action::ToggleMaximize, Self::FetchMode(o) => Action::FetchMode(Box::new(move |s| f(o(s)))), + Self::ToggleMaximize => Action::ToggleMaximize, + Self::ToggleDecorations => Action::ToggleDecorations, + Self::RequestUserAttention(attention_type) => { + Action::RequestUserAttention(attention_type) + } } } } @@ -64,6 +90,7 @@ impl<T> Action<T> { impl<T> fmt::Debug for Action<T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { + Self::Close => write!(f, "Action::Close"), Self::Drag => write!(f, "Action::Drag"), Self::Resize { width, height } => write!( f, @@ -76,8 +103,12 @@ impl<T> fmt::Debug for Action<T> { write!(f, "Action::Move {{ x: {}, y: {} }}", x, y) } Self::SetMode(mode) => write!(f, "Action::SetMode({:?})", mode), - Self::ToggleMaximize => write!(f, "Action::ToggleMaximize"), Self::FetchMode(_) => write!(f, "Action::FetchMode"), + Self::ToggleMaximize => write!(f, "Action::ToggleMaximize"), + Self::ToggleDecorations => write!(f, "Action::ToggleDecorations"), + Self::RequestUserAttention(_) => { + write!(f, "Action::RequestUserAttention") + } } } } |