Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f50077e

Browse files
committedJan 17, 2025·
Fix: Only Resize WebView Associated With Window
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.
1 parent a729968 commit f50077e

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed
 

‎packages/desktop/src/app.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -226,14 +226,14 @@ impl App {
226226
}
227227
}
228228

229-
pub fn resize_window(&self, size: PhysicalSize<u32>) {
229+
pub fn resize_window(&self, id: WindowId, size: PhysicalSize<u32>) {
230230
// TODO: the app layer should avoid directly manipulating the webview webview instance internals.
231231
// Window creation and modification is the responsibility of the webview instance so it makes sense to
232232
// encapsulate that there.
233-
self.webviews.values().for_each(|webview_instance| {
233+
if let Some(webview) = self.webviews.get(&id) {
234234
use wry::Rect;
235235

236-
webview_instance
236+
webview
237237
.desktop_context
238238
.webview
239239
.set_bounds(Rect {
@@ -244,7 +244,7 @@ impl App {
244244
)),
245245
})
246246
.unwrap();
247-
});
247+
}
248248
}
249249

250250
pub fn handle_start_cause_init(&mut self) {

‎packages/desktop/src/launch.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub fn launch_virtual_dom_blocking(virtual_dom: VirtualDom, mut desktop_config:
3232
} => match event {
3333
WindowEvent::CloseRequested => app.handle_close_requested(window_id),
3434
WindowEvent::Destroyed { .. } => app.window_destroyed(window_id),
35-
WindowEvent::Resized(new_size) => app.resize_window(new_size),
35+
WindowEvent::Resized(new_size) => app.resize_window(window_id, new_size),
3636
_ => {}
3737
},
3838

0 commit comments

Comments
 (0)
Please sign in to comment.