@@ -2829,10 +2829,10 @@ fn handle_user_message<T: UserEvent>(
2829
2829
bounds. height = size. height ;
2830
2830
2831
2831
if let Some ( b) = & webview. bounds {
2832
- let window_size = window. inner_size ( ) ;
2832
+ let window_size = window. inner_size ( ) . to_logical :: < f32 > ( window . scale_factor ( ) ) ;
2833
2833
let mut bounds = b. lock ( ) . unwrap ( ) ;
2834
- bounds. width_rate = size. width as f32 / window_size. width as f32 ;
2835
- bounds. height_rate = size. height as f32 / window_size. height as f32 ;
2834
+ bounds. width_rate = size. width as f32 / window_size. width ;
2835
+ bounds. height_rate = size. height as f32 / window_size. height ;
2836
2836
}
2837
2837
2838
2838
webview. set_bounds ( bounds) ;
@@ -2844,10 +2844,11 @@ fn handle_user_message<T: UserEvent>(
2844
2844
bounds. y = position. y ;
2845
2845
2846
2846
if let Some ( b) = & webview. bounds {
2847
- let window_size = window. inner_size ( ) ;
2847
+ let window_size = window. inner_size ( ) . to_logical :: < f32 > ( window . scale_factor ( ) ) ;
2848
2848
let mut bounds = b. lock ( ) . unwrap ( ) ;
2849
- bounds. width_rate = position. x as f32 / window_size. width as f32 ;
2850
- bounds. height_rate = position. y as f32 / window_size. height as f32 ;
2849
+
2850
+ bounds. x_rate = position. x as f32 / window_size. width ;
2851
+ bounds. y_rate = position. y as f32 / window_size. height ;
2851
2852
}
2852
2853
2853
2854
webview. set_bounds ( bounds) ;
@@ -2913,7 +2914,6 @@ fn handle_user_message<T: UserEvent>(
2913
2914
f ( webview. handle ( ) )
2914
2915
}
2915
2916
}
2916
-
2917
2917
#[ cfg( any( debug_assertions, feature = "devtools" ) ) ]
2918
2918
WebviewMessage :: OpenDevTools => {
2919
2919
webview. open_devtools ( ) ;
@@ -2940,6 +2940,7 @@ fn handle_user_message<T: UserEvent>(
2940
2940
Ok ( webview) => {
2941
2941
windows. 0 . borrow_mut ( ) . get_mut ( & window_id) . map ( |w| {
2942
2942
w. webviews . push ( webview) ;
2943
+ w. has_children . store ( true , Ordering :: Relaxed ) ;
2943
2944
w
2944
2945
} ) ;
2945
2946
}
@@ -3181,20 +3182,21 @@ fn handle_event_loop<T: UserEvent>(
3181
3182
}
3182
3183
}
3183
3184
TaoWindowEvent :: Resized ( size) => {
3184
- if let Some ( webviews) = windows
3185
+ if let Some ( ( Some ( window ) , webviews) ) = windows
3185
3186
. 0
3186
3187
. borrow ( )
3187
3188
. get ( & window_id)
3188
- . map ( |w| w . webviews . clone ( ) )
3189
+ . map ( |w| ( w . inner . clone ( ) , w . webviews . clone ( ) ) )
3189
3190
{
3191
+ let size = size. to_logical :: < f32 > ( window. scale_factor ( ) ) ;
3190
3192
for webview in webviews {
3191
3193
if let Some ( bounds) = & webview. bounds {
3192
3194
let b = bounds. lock ( ) . unwrap ( ) ;
3193
3195
webview. set_bounds ( wry:: Rect {
3194
- x : ( size. width as f32 * b. x_rate ) as i32 ,
3195
- y : ( size. height as f32 * b. y_rate ) as i32 ,
3196
- width : ( size. width as f32 * b. width_rate ) as u32 ,
3197
- height : ( size. height as f32 * b. height_rate ) as u32 ,
3196
+ x : ( size. width * b. x_rate ) as i32 ,
3197
+ y : ( size. height * b. y_rate ) as i32 ,
3198
+ width : ( size. width * b. width_rate ) as u32 ,
3199
+ height : ( size. height * b. height_rate ) as u32 ,
3198
3200
} ) ;
3199
3201
}
3200
3202
}
@@ -3594,7 +3596,8 @@ fn create_webview<T: UserEvent>(
3594
3596
3595
3597
if let Some ( navigation_handler) = pending. navigation_handler {
3596
3598
webview_builder = webview_builder. with_navigation_handler ( move |url| {
3597
- Url :: parse ( & url)
3599
+ url
3600
+ . parse ( )
3598
3601
. map ( |url| navigation_handler ( & url) )
3599
3602
. unwrap_or ( true )
3600
3603
} ) ;
@@ -3610,14 +3613,14 @@ fn create_webview<T: UserEvent>(
3610
3613
height : size. height ,
3611
3614
} ) ;
3612
3615
3613
- let window_size = window. inner_size ( ) ;
3616
+ let window_size = window. inner_size ( ) . to_logical :: < f32 > ( window . scale_factor ( ) ) ;
3614
3617
3615
3618
if webview_attributes. auto_resize {
3616
3619
Some ( WebviewBounds {
3617
- x_rate : ( position. x as f32 ) / window_size. width as f32 ,
3618
- y_rate : ( position. y as f32 ) / window_size. height as f32 ,
3619
- width_rate : ( size. width as f32 ) / window_size. width as f32 ,
3620
- height_rate : ( size. height as f32 ) / window_size. height as f32 ,
3620
+ x_rate : ( position. x as f32 ) / window_size. width ,
3621
+ y_rate : ( position. y as f32 ) / window_size. height ,
3622
+ width_rate : ( size. width as f32 ) / window_size. width ,
3623
+ height_rate : ( size. height as f32 ) / window_size. height ,
3621
3624
} )
3622
3625
} else {
3623
3626
None
@@ -3647,7 +3650,7 @@ fn create_webview<T: UserEvent>(
3647
3650
3648
3651
if let Some ( page_load_handler) = pending. on_page_load_handler {
3649
3652
webview_builder = webview_builder. with_on_page_load_handler ( move |event, url| {
3650
- let _ = Url :: parse ( & url ) . map ( |url| {
3653
+ let _ = url . parse ( ) . map ( |url| {
3651
3654
page_load_handler (
3652
3655
url,
3653
3656
match event {
0 commit comments