@@ -4000,13 +4000,9 @@ fn handle_user_message<T: UserEvent>(
40004000 }
40014001 }
40024002 Message :: CreateWindow ( window_id, handler) => match handler ( event_loop) {
4003- // wait for borrow_mut to be available - on Windows we might poll for the window to be inserted
4004- Ok ( webview) => loop {
4005- if let Ok ( mut windows) = windows. 0 . try_borrow_mut ( ) {
4006- windows. insert ( window_id, webview) ;
4007- break ;
4008- }
4009- } ,
4003+ Ok ( webview) => {
4004+ windows. 0 . borrow_mut ( ) . insert ( window_id, webview) ;
4005+ }
40104006 Err ( e) => {
40114007 log:: error!( "{e}" ) ;
40124008 }
@@ -4789,63 +4785,56 @@ You may have it installed on another user account, but it is not available for t
47894785 #[ cfg( desktop) ]
47904786 let context = context. clone ( ) ;
47914787 webview_builder = webview_builder. with_new_window_req_handler ( move |url, features| {
4792- url
4793- . parse ( )
4794- . map ( |url| {
4795- let response = new_window_handler (
4796- url,
4797- tauri_runtime:: webview:: NewWindowFeatures :: new (
4798- features. size ,
4799- features. position ,
4800- tauri_runtime:: webview:: NewWindowOpener {
4801- #[ cfg( desktop) ]
4802- webview : features. opener . webview ,
4803- #[ cfg( windows) ]
4804- environment : features. opener . environment ,
4805- #[ cfg( target_os = "macos" ) ]
4806- target_configuration : features. opener . target_configuration ,
4807- } ,
4808- ) ,
4809- ) ;
4810- match response {
4811- tauri_runtime:: webview:: NewWindowResponse :: Allow => wry:: NewWindowResponse :: Allow ,
4788+ let Ok ( url) = url. parse ( ) else {
4789+ return wry:: NewWindowResponse :: Deny ;
4790+ } ;
4791+ let response = new_window_handler (
4792+ url,
4793+ tauri_runtime:: webview:: NewWindowFeatures :: new (
4794+ features. size ,
4795+ features. position ,
4796+ tauri_runtime:: webview:: NewWindowOpener {
48124797 #[ cfg( desktop) ]
4813- tauri_runtime:: webview:: NewWindowResponse :: Create { window_id } => {
4814- let windows = & context. main_thread . windows . 0 ;
4815- let webview = loop {
4816- if let Some ( webview) = windows. try_borrow ( ) . ok ( ) . and_then ( |windows| {
4817- windows
4818- . get ( & window_id)
4819- . map ( |window| window. webviews . first ( ) . unwrap ( ) . clone ( ) )
4820- } ) {
4821- break webview;
4822- } else {
4823- // on Windows the window is created async so we should wait for it to be available
4824- std:: thread:: sleep ( std:: time:: Duration :: from_millis ( 50 ) ) ;
4825- continue ;
4826- } ;
4827- } ;
4828-
4829- #[ cfg( desktop) ]
4830- wry:: NewWindowResponse :: Create {
4831- #[ cfg( target_os = "macos" ) ]
4832- webview : wry:: WebViewExtMacOS :: webview ( & * webview) . as_super ( ) . into ( ) ,
4833- #[ cfg( any(
4834- target_os = "linux" ,
4835- target_os = "dragonfly" ,
4836- target_os = "freebsd" ,
4837- target_os = "netbsd" ,
4838- target_os = "openbsd" ,
4839- ) ) ]
4840- webview : webview. webview ( ) ,
4841- #[ cfg( windows) ]
4842- webview : webview. webview ( ) ,
4843- }
4844- }
4845- tauri_runtime:: webview:: NewWindowResponse :: Deny => wry:: NewWindowResponse :: Deny ,
4798+ webview : features. opener . webview ,
4799+ #[ cfg( windows) ]
4800+ environment : features. opener . environment ,
4801+ #[ cfg( target_os = "macos" ) ]
4802+ target_configuration : features. opener . target_configuration ,
4803+ } ,
4804+ ) ,
4805+ ) ;
4806+ match response {
4807+ tauri_runtime:: webview:: NewWindowResponse :: Allow => wry:: NewWindowResponse :: Allow ,
4808+ #[ cfg( desktop) ]
4809+ tauri_runtime:: webview:: NewWindowResponse :: Create { window_id } => {
4810+ let windows = & context. main_thread . windows . 0 ;
4811+ let webview = windows
4812+ . borrow ( )
4813+ . get ( & window_id)
4814+ . unwrap ( )
4815+ . webviews
4816+ . first ( )
4817+ . unwrap ( )
4818+ . clone ( ) ;
4819+
4820+ #[ cfg( desktop) ]
4821+ wry:: NewWindowResponse :: Create {
4822+ #[ cfg( target_os = "macos" ) ]
4823+ webview : wry:: WebViewExtMacOS :: webview ( & * webview) . as_super ( ) . into ( ) ,
4824+ #[ cfg( any(
4825+ target_os = "linux" ,
4826+ target_os = "dragonfly" ,
4827+ target_os = "freebsd" ,
4828+ target_os = "netbsd" ,
4829+ target_os = "openbsd" ,
4830+ ) ) ]
4831+ webview : webview. webview ( ) ,
4832+ #[ cfg( windows) ]
4833+ webview : webview. webview ( ) ,
48464834 }
4847- } )
4848- . unwrap_or ( wry:: NewWindowResponse :: Deny )
4835+ }
4836+ tauri_runtime:: webview:: NewWindowResponse :: Deny => wry:: NewWindowResponse :: Deny ,
4837+ }
48494838 } ) ;
48504839 }
48514840
0 commit comments