|
@@ -2829,10 +2829,10 @@ fn handle_user_message<T: UserEvent>(
|
|
bounds.height = size.height;
|
|
bounds.height = size.height;
|
|
|
|
|
|
if let Some(b) = &webview.bounds {
|
|
if let Some(b) = &webview.bounds {
|
|
- let window_size = window.inner_size();
|
|
|
|
|
|
+ let window_size = window.inner_size().to_logical::<f32>(window.scale_factor());
|
|
let mut bounds = b.lock().unwrap();
|
|
let mut bounds = b.lock().unwrap();
|
|
- bounds.width_rate = size.width as f32 / window_size.width as f32;
|
|
|
|
- bounds.height_rate = size.height as f32 / window_size.height as f32;
|
|
|
|
|
|
+ bounds.width_rate = size.width as f32 / window_size.width;
|
|
|
|
+ bounds.height_rate = size.height as f32 / window_size.height;
|
|
}
|
|
}
|
|
|
|
|
|
webview.set_bounds(bounds);
|
|
webview.set_bounds(bounds);
|
|
@@ -2844,10 +2844,11 @@ fn handle_user_message<T: UserEvent>(
|
|
bounds.y = position.y;
|
|
bounds.y = position.y;
|
|
|
|
|
|
if let Some(b) = &webview.bounds {
|
|
if let Some(b) = &webview.bounds {
|
|
- let window_size = window.inner_size();
|
|
|
|
|
|
+ let window_size = window.inner_size().to_logical::<f32>(window.scale_factor());
|
|
let mut bounds = b.lock().unwrap();
|
|
let mut bounds = b.lock().unwrap();
|
|
- bounds.width_rate = position.x as f32 / window_size.width as f32;
|
|
|
|
- bounds.height_rate = position.y as f32 / window_size.height as f32;
|
|
|
|
|
|
+
|
|
|
|
+ bounds.x_rate = position.x as f32 / window_size.width;
|
|
|
|
+ bounds.y_rate = position.y as f32 / window_size.height;
|
|
}
|
|
}
|
|
|
|
|
|
webview.set_bounds(bounds);
|
|
webview.set_bounds(bounds);
|
|
@@ -2913,7 +2914,6 @@ fn handle_user_message<T: UserEvent>(
|
|
f(webview.handle())
|
|
f(webview.handle())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
#[cfg(any(debug_assertions, feature = "devtools"))]
|
|
#[cfg(any(debug_assertions, feature = "devtools"))]
|
|
WebviewMessage::OpenDevTools => {
|
|
WebviewMessage::OpenDevTools => {
|
|
webview.open_devtools();
|
|
webview.open_devtools();
|
|
@@ -2940,6 +2940,7 @@ fn handle_user_message<T: UserEvent>(
|
|
Ok(webview) => {
|
|
Ok(webview) => {
|
|
windows.0.borrow_mut().get_mut(&window_id).map(|w| {
|
|
windows.0.borrow_mut().get_mut(&window_id).map(|w| {
|
|
w.webviews.push(webview);
|
|
w.webviews.push(webview);
|
|
|
|
+ w.has_children.store(true, Ordering::Relaxed);
|
|
w
|
|
w
|
|
});
|
|
});
|
|
}
|
|
}
|
|
@@ -3181,20 +3182,21 @@ fn handle_event_loop<T: UserEvent>(
|
|
}
|
|
}
|
|
}
|
|
}
|
|
TaoWindowEvent::Resized(size) => {
|
|
TaoWindowEvent::Resized(size) => {
|
|
- if let Some(webviews) = windows
|
|
|
|
|
|
+ if let Some((Some(window), webviews)) = windows
|
|
.0
|
|
.0
|
|
.borrow()
|
|
.borrow()
|
|
.get(&window_id)
|
|
.get(&window_id)
|
|
- .map(|w| w.webviews.clone())
|
|
|
|
|
|
+ .map(|w| (w.inner.clone(), w.webviews.clone()))
|
|
{
|
|
{
|
|
|
|
+ let size = size.to_logical::<f32>(window.scale_factor());
|
|
for webview in webviews {
|
|
for webview in webviews {
|
|
if let Some(bounds) = &webview.bounds {
|
|
if let Some(bounds) = &webview.bounds {
|
|
let b = bounds.lock().unwrap();
|
|
let b = bounds.lock().unwrap();
|
|
webview.set_bounds(wry::Rect {
|
|
webview.set_bounds(wry::Rect {
|
|
- x: (size.width as f32 * b.x_rate) as i32,
|
|
|
|
- y: (size.height as f32 * b.y_rate) as i32,
|
|
|
|
- width: (size.width as f32 * b.width_rate) as u32,
|
|
|
|
- height: (size.height as f32 * b.height_rate) as u32,
|
|
|
|
|
|
+ x: (size.width * b.x_rate) as i32,
|
|
|
|
+ y: (size.height * b.y_rate) as i32,
|
|
|
|
+ width: (size.width * b.width_rate) as u32,
|
|
|
|
+ height: (size.height * b.height_rate) as u32,
|
|
});
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -3594,7 +3596,8 @@ fn create_webview<T: UserEvent>(
|
|
|
|
|
|
if let Some(navigation_handler) = pending.navigation_handler {
|
|
if let Some(navigation_handler) = pending.navigation_handler {
|
|
webview_builder = webview_builder.with_navigation_handler(move |url| {
|
|
webview_builder = webview_builder.with_navigation_handler(move |url| {
|
|
- Url::parse(&url)
|
|
|
|
|
|
+ url
|
|
|
|
+ .parse()
|
|
.map(|url| navigation_handler(&url))
|
|
.map(|url| navigation_handler(&url))
|
|
.unwrap_or(true)
|
|
.unwrap_or(true)
|
|
});
|
|
});
|
|
@@ -3610,14 +3613,14 @@ fn create_webview<T: UserEvent>(
|
|
height: size.height,
|
|
height: size.height,
|
|
});
|
|
});
|
|
|
|
|
|
- let window_size = window.inner_size();
|
|
|
|
|
|
+ let window_size = window.inner_size().to_logical::<f32>(window.scale_factor());
|
|
|
|
|
|
if webview_attributes.auto_resize {
|
|
if webview_attributes.auto_resize {
|
|
Some(WebviewBounds {
|
|
Some(WebviewBounds {
|
|
- x_rate: (position.x as f32) / window_size.width as f32,
|
|
|
|
- y_rate: (position.y as f32) / window_size.height as f32,
|
|
|
|
- width_rate: (size.width as f32) / window_size.width as f32,
|
|
|
|
- height_rate: (size.height as f32) / window_size.height as f32,
|
|
|
|
|
|
+ x_rate: (position.x as f32) / window_size.width,
|
|
|
|
+ y_rate: (position.y as f32) / window_size.height,
|
|
|
|
+ width_rate: (size.width as f32) / window_size.width,
|
|
|
|
+ height_rate: (size.height as f32) / window_size.height,
|
|
})
|
|
})
|
|
} else {
|
|
} else {
|
|
None
|
|
None
|
|
@@ -3647,7 +3650,7 @@ fn create_webview<T: UserEvent>(
|
|
|
|
|
|
if let Some(page_load_handler) = pending.on_page_load_handler {
|
|
if let Some(page_load_handler) = pending.on_page_load_handler {
|
|
webview_builder = webview_builder.with_on_page_load_handler(move |event, url| {
|
|
webview_builder = webview_builder.with_on_page_load_handler(move |event, url| {
|
|
- let _ = Url::parse(&url).map(|url| {
|
|
|
|
|
|
+ let _ = url.parse().map(|url| {
|
|
page_load_handler(
|
|
page_load_handler(
|
|
url,
|
|
url,
|
|
match event {
|
|
match event {
|