From c551eddfae491f263113b7c184c5c6a79b4958b9 Mon Sep 17 00:00:00 2001 From: Tygyh Date: Thu, 7 Dec 2023 19:41:43 +0100 Subject: [PATCH] Add required casts --- crates/bevy_winit/src/lib.rs | 14 ++++++++------ crates/bevy_winit/src/system.rs | 2 +- crates/bevy_winit/src/winit_windows.rs | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/crates/bevy_winit/src/lib.rs b/crates/bevy_winit/src/lib.rs index 83281133e35dec..e52c2661f95914 100644 --- a/crates/bevy_winit/src/lib.rs +++ b/crates/bevy_winit/src/lib.rs @@ -545,7 +545,7 @@ pub fn winit_runner(mut app: App) { window.set_physical_cursor_position(Some(physical_position)); event_writers.cursor_moved.send(CursorMoved { window: window_entity, - position: (physical_position / window.resolution.scale_factor()) + position: (physical_position / window.resolution.scale_factor() as f64) .as_vec2(), }); } @@ -596,7 +596,9 @@ pub fn winit_runner(mut app: App) { } }, WindowEvent::Touch(touch) => { - let location = touch.location.to_logical(window.resolution.scale_factor()); + let location = touch + .location + .to_logical(window.resolution.scale_factor() as f64); event_writers .touch_input .send(converters::convert_touch_input(touch, location)); @@ -619,7 +621,7 @@ pub fn winit_runner(mut app: App) { ); let prior_factor = window.resolution.scale_factor(); - window.resolution.set_scale_factor(scale_factor); + window.resolution.set_scale_factor(scale_factor as f32); let new_factor = window.resolution.scale_factor(); if let Some(forced_factor) = window.resolution.scale_factor_override() { @@ -628,7 +630,7 @@ pub fn winit_runner(mut app: App) { // incorporates any resize constraints. *new_inner_size = winit::dpi::LogicalSize::new(window.width(), window.height()) - .to_physical::(forced_factor); + .to_physical::(forced_factor as f64); } else if approx::relative_ne!(new_factor, prior_factor) { event_writers.window_scale_factor_changed.send( WindowScaleFactorChanged { @@ -638,8 +640,8 @@ pub fn winit_runner(mut app: App) { ); } - let new_logical_width = (new_inner_size.width as f64 / new_factor) as f32; - let new_logical_height = (new_inner_size.height as f64 / new_factor) as f32; + let new_logical_width = new_inner_size.width / new_factor; + let new_logical_height = new_inner_size.height / new_factor; if approx::relative_ne!(window.width(), new_logical_width) || approx::relative_ne!(window.height(), new_logical_height) { diff --git a/crates/bevy_winit/src/system.rs b/crates/bevy_winit/src/system.rs index 896466f3c70734..c3f3c49a36fbc0 100644 --- a/crates/bevy_winit/src/system.rs +++ b/crates/bevy_winit/src/system.rs @@ -73,7 +73,7 @@ pub(crate) fn create_windows<'a>( window .resolution - .set_scale_factor(winit_window.scale_factor()); + .set_scale_factor(winit_window.scale_factor() as f32); commands .entity(entity) .insert(RawHandleWrapper { diff --git a/crates/bevy_winit/src/winit_windows.rs b/crates/bevy_winit/src/winit_windows.rs index 501a438669c43e..2d891d1bd5f85b 100644 --- a/crates/bevy_winit/src/winit_windows.rs +++ b/crates/bevy_winit/src/winit_windows.rs @@ -82,7 +82,7 @@ impl WinitWindows { let logical_size = LogicalSize::new(window.width(), window.height()); if let Some(sf) = window.resolution.scale_factor_override() { - winit_window_builder.with_inner_size(logical_size.to_physical::(sf)) + winit_window_builder.with_inner_size(logical_size.to_physical::(sf)) } else { winit_window_builder.with_inner_size(logical_size) }