From b5785ba785f3c1278344bcc545a954f0b5464d28 Mon Sep 17 00:00:00 2001 From: dAxpeDDa Date: Thu, 8 Jun 2023 08:40:26 +0200 Subject: [PATCH] Revert "Fix `Window::set_inner_size()`" This reverts commit e220a755568e71b5a85c57f76452f6f5378441a1. --- CHANGELOG.md | 3 +-- src/platform_impl/web/web_sys/mod.rs | 14 ++++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9eea1dc0..cf3fe89d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,8 +54,7 @@ And please only add new entries to the top of this list, right below the `# Unre - On Wayland, drop `WINIT_WAYLAND_CSD_THEME` variable. - Implement `PartialOrd` and `Ord` on types in the `dpi` module. - **Breaking:** Bump MSRV from `1.60` to `1.64`. -- **Breaking:** On Web, `Window::(set_)inner_size()` will return/change the visual canvas size - instead of the internal canvas size. +- **Breaking:** On Web, the canvas output bitmap size is no longer adjusted. - On Web: fix `Window::request_redraw` not waking the event loop when called from outside the loop. - On Web: fix position of touch events to be relative to the canvas. - On Web, fix `Window:::set_fullscreen` doing nothing when called outside the event loop but during diff --git a/src/platform_impl/web/web_sys/mod.rs b/src/platform_impl/web/web_sys/mod.rs index 69a6783a..611fcd78 100644 --- a/src/platform_impl/web/web_sys/mod.rs +++ b/src/platform_impl/web/web_sys/mod.rs @@ -73,11 +73,17 @@ pub fn scale_factor(window: &web_sys::Window) -> f64 { pub fn set_canvas_size(canvas: &Canvas, new_size: Size) { let scale_factor = scale_factor(canvas.window()); - let new_size = new_size.to_physical(scale_factor); - canvas.size().set(new_size); - set_canvas_style_property(canvas.raw(), "width", &format!("{}px", new_size.width)); - set_canvas_style_property(canvas.raw(), "height", &format!("{}px", new_size.height)); + let physical_size = new_size.to_physical(scale_factor); + canvas.size().set(physical_size); + + let logical_size = new_size.to_logical::(scale_factor); + set_canvas_style_property(canvas.raw(), "width", &format!("{}px", logical_size.width)); + set_canvas_style_property( + canvas.raw(), + "height", + &format!("{}px", logical_size.height), + ); } pub fn set_canvas_style_property(raw: &HtmlCanvasElement, property: &str, value: &str) {