From 9797ed86f0091e9dc2d3c2f1e1bab6c626cf5c3b Mon Sep 17 00:00:00 2001 From: dAxpeDDa Date: Wed, 7 Jun 2023 21:59:01 +0200 Subject: [PATCH] Fix unable to ignore scale factor resize suggestion --- CHANGELOG.md | 1 + src/platform_impl/web/event_loop/runner.rs | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 037d5c2e..9eea1dc0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -78,6 +78,7 @@ And please only add new entries to the top of this list, right below the `# Unre instead of using the output bitmap size. - On Web, scale factor and dark mode detection are now more robust. - On Web, fix the bfcache by not using the `beforeunload` event. +- On Web, fix scale factor resize suggestion always overwriting the canvas size. # 0.28.6 diff --git a/src/platform_impl/web/event_loop/runner.rs b/src/platform_impl/web/event_loop/runner.rs index f14b212e..f6340830 100644 --- a/src/platform_impl/web/event_loop/runner.rs +++ b/src/platform_impl/web/event_loop/runner.rs @@ -349,14 +349,16 @@ impl Shared { ); // Then we resize the canvas to the new size and send a `Resized` event: - backend::set_canvas_size(&canvas, crate::dpi::Size::Physical(new_size)); - self.handle_single_event_sync( - Event::WindowEvent { - window_id: id, - event: crate::event::WindowEvent::Resized(new_size), - }, - &mut control, - ); + if current_size != new_size { + backend::set_canvas_size(&canvas, crate::dpi::Size::Physical(new_size)); + self.handle_single_event_sync( + Event::WindowEvent { + window_id: id, + event: crate::event::WindowEvent::Resized(new_size), + }, + &mut control, + ); + } } // Process the destroy-pending windows again.