1- use crate :: window:: Mode ;
1+ use crate :: window:: { Mode , UserAttention } ;
22
33use iced_futures:: MaybeSend ;
44use std:: fmt;
@@ -35,15 +35,29 @@ pub enum Action<T> {
3535 } ,
3636 /// Set the [`Mode`] of the window.
3737 SetMode ( Mode ) ,
38+ /// Fetch the current [`Mode`] of the window.
39+ FetchMode ( Box < dyn FnOnce ( Mode ) -> T + ' static > ) ,
3840 /// Sets the window to maximized or back
3941 ToggleMaximize ,
4042 /// Toggles whether window has decorations
4143 /// ## Platform-specific
4244 /// - **X11:** Not implemented.
4345 /// - **Web:** Unsupported.
4446 ToggleDecorations ,
45- /// Fetch the current [`Mode`] of the window.
46- FetchMode ( Box < dyn FnOnce ( Mode ) -> T + ' static > ) ,
47+ /// Requests user attention to the window, this has no effect if the application
48+ /// is already focused. How requesting for user attention manifests is platform dependent,
49+ /// see [`UserAttentionType`] for details.
50+ ///
51+ /// Providing `None` will unset the request for user attention. Unsetting the request for
52+ /// user attention might not be done automatically by the WM when the window receives input.
53+ ///
54+ /// ## Platform-specific
55+ ///
56+ /// - **iOS / Android / Web:** Unsupported.
57+ /// - **macOS:** `None` has no effect.
58+ /// - **X11:** Requests for user attention must be manually cleared.
59+ /// - **Wayland:** Requires `xdg_activation_v1` protocol, `None` has no effect.
60+ RequestUserAttention ( Option < UserAttention > ) ,
4761}
4862
4963impl < T > Action < T > {
@@ -63,9 +77,12 @@ impl<T> Action<T> {
6377 Self :: Minimize ( bool) => Action :: Minimize ( bool) ,
6478 Self :: Move { x, y } => Action :: Move { x, y } ,
6579 Self :: SetMode ( mode) => Action :: SetMode ( mode) ,
80+ Self :: FetchMode ( o) => Action :: FetchMode ( Box :: new ( move |s| f ( o ( s) ) ) ) ,
6681 Self :: ToggleMaximize => Action :: ToggleMaximize ,
6782 Self :: ToggleDecorations => Action :: ToggleDecorations ,
68- Self :: FetchMode ( o) => Action :: FetchMode ( Box :: new ( move |s| f ( o ( s) ) ) ) ,
83+ Self :: RequestUserAttention ( attention_type) => {
84+ Action :: RequestUserAttention ( attention_type)
85+ }
6986 }
7087 }
7188}
@@ -86,9 +103,12 @@ impl<T> fmt::Debug for Action<T> {
86103 write ! ( f, "Action::Move {{ x: {}, y: {} }}" , x, y)
87104 }
88105 Self :: SetMode ( mode) => write ! ( f, "Action::SetMode({:?})" , mode) ,
106+ Self :: FetchMode ( _) => write ! ( f, "Action::FetchMode" ) ,
89107 Self :: ToggleMaximize => write ! ( f, "Action::ToggleMaximize" ) ,
90108 Self :: ToggleDecorations => write ! ( f, "Action::ToggleDecorations" ) ,
91- Self :: FetchMode ( _) => write ! ( f, "Action::FetchMode" ) ,
109+ Self :: RequestUserAttention ( _) => {
110+ write ! ( f, "Action::RequestUserAttention" )
111+ }
92112 }
93113 }
94114}
0 commit comments