mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-23 22:01:31 +11:00
Fix Window::set_inner_size()
This commit is contained in:
parent
29d3729ac8
commit
e220a75556
|
@ -54,7 +54,8 @@ And please only add new entries to the top of this list, right below the `# Unre
|
||||||
- On Wayland, drop `WINIT_WAYLAND_CSD_THEME` variable.
|
- On Wayland, drop `WINIT_WAYLAND_CSD_THEME` variable.
|
||||||
- Implement `PartialOrd` and `Ord` on types in the `dpi` module.
|
- Implement `PartialOrd` and `Ord` on types in the `dpi` module.
|
||||||
- **Breaking:** Bump MSRV from `1.60` to `1.64`.
|
- **Breaking:** Bump MSRV from `1.60` to `1.64`.
|
||||||
- **Breaking:** On Web, the canvas output bitmap size is no longer adjusted.
|
- **Breaking:** On Web, `Window::(set_)inner_size()` will return/change the visual canvas size
|
||||||
|
instead of the internal canvas size.
|
||||||
- On Web: fix `Window::request_redraw` not waking the event loop when called from outside the loop.
|
- 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 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
|
- On Web, fix `Window:::set_fullscreen` doing nothing when called outside the event loop but during
|
||||||
|
|
|
@ -73,17 +73,11 @@ pub fn scale_factor(window: &web_sys::Window) -> f64 {
|
||||||
|
|
||||||
pub fn set_canvas_size(canvas: &Canvas, new_size: Size) {
|
pub fn set_canvas_size(canvas: &Canvas, new_size: Size) {
|
||||||
let scale_factor = scale_factor(canvas.window());
|
let scale_factor = scale_factor(canvas.window());
|
||||||
|
let new_size = new_size.to_physical(scale_factor);
|
||||||
|
|
||||||
let physical_size = new_size.to_physical(scale_factor);
|
canvas.size().set(new_size);
|
||||||
canvas.size().set(physical_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 logical_size = new_size.to_logical::<f64>(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) {
|
pub fn set_canvas_style_property(raw: &HtmlCanvasElement, property: &str, value: &str) {
|
||||||
|
|
Loading…
Reference in a new issue