@@ -14,6 +14,7 @@ use tauri_runtime::{
1414 DetachedWindow , PendingWindow , WindowEvent ,
1515 } ,
1616 Dispatch , Error , Icon , Params , Result , RunEvent , RunIteration , Runtime , RuntimeHandle ,
17+ UserAttentionType ,
1718} ;
1819
1920#[ cfg( feature = "menu" ) ]
@@ -39,7 +40,10 @@ use wry::{
3940 event:: { Event , WindowEvent as WryWindowEvent } ,
4041 event_loop:: { ControlFlow , EventLoop , EventLoopProxy , EventLoopWindowTarget } ,
4142 monitor:: MonitorHandle ,
42- window:: { Fullscreen , Icon as WindowIcon , Window , WindowBuilder as WryWindowBuilder , WindowId } ,
43+ window:: {
44+ Fullscreen , Icon as WindowIcon , UserAttentionType as WryUserAttentionType , Window ,
45+ WindowBuilder as WryWindowBuilder , WindowId ,
46+ } ,
4347 } ,
4448 webview:: {
4549 FileDropEvent as WryFileDropEvent , RpcRequest as WryRpcRequest , RpcResponse , WebContext ,
@@ -245,6 +249,19 @@ impl From<Position> for PositionWrapper {
245249 }
246250}
247251
252+ #[ derive( Debug , Clone ) ]
253+ struct UserAttentionTypeWrapper ( WryUserAttentionType ) ;
254+
255+ impl From < UserAttentionType > for UserAttentionTypeWrapper {
256+ fn from ( request_type : UserAttentionType ) -> UserAttentionTypeWrapper {
257+ let o = match request_type {
258+ UserAttentionType :: Critical => WryUserAttentionType :: Critical ,
259+ UserAttentionType :: Informational => WryUserAttentionType :: Informational ,
260+ } ;
261+ Self ( o)
262+ }
263+ }
264+
248265#[ derive( Debug , Clone , Default ) ]
249266pub struct WindowBuilderWrapper {
250267 inner : WryWindowBuilder ,
@@ -467,6 +484,7 @@ enum WindowMessage {
467484 Hwnd ( Sender < Hwnd > ) ,
468485 // Setters
469486 Center ( Sender < Result < ( ) > > ) ,
487+ RequestUserAttention ( Option < UserAttentionTypeWrapper > ) ,
470488 SetResizable ( bool ) ,
471489 SetTitle ( String ) ,
472490 Maximize ,
@@ -680,6 +698,17 @@ impl Dispatch for WryDispatcher {
680698 . map_err ( |_| Error :: FailedToSendMessage )
681699 }
682700
701+ fn request_user_attention ( & self , request_type : Option < UserAttentionType > ) -> Result < ( ) > {
702+ self
703+ . context
704+ . proxy
705+ . send_event ( Message :: Window (
706+ self . window_id ,
707+ WindowMessage :: RequestUserAttention ( request_type. map ( Into :: into) ) ,
708+ ) )
709+ . map_err ( |_| Error :: FailedToSendMessage )
710+ }
711+
683712 // Creates a window by dispatching a message to the event loop.
684713 // Note that this must be called from a separate thread, otherwise the channel will introduce a deadlock.
685714 fn create_window < P : Params < Runtime = Self :: Runtime > > (
@@ -1341,6 +1370,9 @@ fn handle_event_loop(
13411370 WindowMessage :: Center ( tx) => {
13421371 tx. send ( center_window ( window) ) . unwrap ( ) ;
13431372 }
1373+ WindowMessage :: RequestUserAttention ( request_type) => {
1374+ window. request_user_attention ( request_type. map ( |r| r. 0 ) ) ;
1375+ }
13441376 WindowMessage :: SetResizable ( resizable) => window. set_resizable ( resizable) ,
13451377 WindowMessage :: SetTitle ( title) => window. set_title ( & title) ,
13461378 WindowMessage :: Maximize => window. set_maximized ( true ) ,
0 commit comments