Fix: Only Resize WebView Associated With Window (#3584)

When resizing a window, Dioxus previously accidentally resized every
single webview to the dimensions of the window that just got resized.
This fixes it so only the webview that is associated with the window is
resized.
This commit is contained in:
Christopher Serr authored and GitHub committed 2025-01-17 12:00:38 -08:00
1 parent a729968ee4
commit eaf9f80abd
2 files changed
+5 -5

No files matched your search

+4 -4
View File
@@ -226,14 +226,14 @@ impl App {
} }
} }
pub fn resize_window(&self, size: PhysicalSize<u32>) { pub fn resize_window(&self, id: WindowId, size: PhysicalSize<u32>) {
// TODO: the app layer should avoid directly manipulating the webview webview instance internals. // TODO: the app layer should avoid directly manipulating the webview webview instance internals.
// Window creation and modification is the responsibility of the webview instance so it makes sense to // Window creation and modification is the responsibility of the webview instance so it makes sense to
// encapsulate that there. // encapsulate that there.
self.webviews.values().for_each(|webview_instance| { if let Some(webview) = self.webviews.get(&id) {
use wry::Rect; use wry::Rect;
webview_instance webview
.desktop_context .desktop_context
.webview .webview
.set_bounds(Rect { .set_bounds(Rect {
@@ -244,7 +244,7 @@ impl App {
)), )),
}) })
.unwrap(); .unwrap();
}); }
} }
pub fn handle_start_cause_init(&mut self) { pub fn handle_start_cause_init(&mut self) {
+1 -1
View File
@@ -32,7 +32,7 @@ pub fn launch_virtual_dom_blocking(virtual_dom: VirtualDom, mut desktop_config:
} => match event { } => match event {
WindowEvent::CloseRequested => app.handle_close_requested(window_id), WindowEvent::CloseRequested => app.handle_close_requested(window_id),
WindowEvent::Destroyed { .. } => app.window_destroyed(window_id), WindowEvent::Destroyed { .. } => app.window_destroyed(window_id),
WindowEvent::Resized(new_size) => app.resize_window(new_size), WindowEvent::Resized(new_size) => app.resize_window(window_id, new_size),
_ => {} _ => {}
}, },