Skip to content

Commit

Permalink
Merge remote-tracking branch 'fix-8942/main' into fix-pr-8942
Browse files Browse the repository at this point in the history
  • Loading branch information
tygyh committed Dec 7, 2023
2 parents 03b6106 + c551edd commit 76f53b4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
14 changes: 8 additions & 6 deletions crates/bevy_winit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
});
}
Expand Down Expand Up @@ -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));
Expand All @@ -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() {
Expand All @@ -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::<u32>(forced_factor);
.to_physical::<u32>(forced_factor as f64);
} else if approx::relative_ne!(new_factor, prior_factor) {
event_writers.window_scale_factor_changed.send(
WindowScaleFactorChanged {
Expand All @@ -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 as u32;
let new_logical_height = new_inner_size.height / new_factor as u32;
if approx::relative_ne!(window.width(), new_logical_width)
|| approx::relative_ne!(window.height(), new_logical_height)
{
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_winit/src/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_winit/src/winit_windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<f64>(sf))
winit_window_builder.with_inner_size(logical_size.to_physical::<f64>(sf.into()))
} else {
winit_window_builder.with_inner_size(logical_size)
}
Expand Down

0 comments on commit 76f53b4

Please sign in to comment.