Skip to content

Commit

Permalink
Fix scale_factor_override with cursor position.
Browse files Browse the repository at this point in the history
Sometimes the wrong scale factor was used (not accounting for
overrides).

Fixes bevyengine#2501
  • Loading branch information
ahmedcharles authored and mockersf committed Oct 7, 2021
1 parent 2974293 commit 1c32862
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions crates/bevy_winit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,10 +303,10 @@ pub fn winit_runner_with(mut app: App, mut event_loop: EventLoop<()>) {
let mut cursor_moved_events =
world.get_resource_mut::<Events<CursorMoved>>().unwrap();
let winit_window = winit_windows.get_window(window_id).unwrap();
let position = position.to_logical(winit_window.scale_factor());
let position = position.to_logical(window.scale_factor());
let inner_size = winit_window
.inner_size()
.to_logical::<f32>(winit_window.scale_factor());
.to_logical::<f32>(window.scale_factor());

// move origin to bottom left
let y_position = inner_size.height - position.y;
Expand Down Expand Up @@ -363,8 +363,7 @@ pub fn winit_runner_with(mut app: App, mut event_loop: EventLoop<()>) {
let mut touch_input_events =
world.get_resource_mut::<Events<TouchInput>>().unwrap();

let winit_window = winit_windows.get_window(window_id).unwrap();
let mut location = touch.location.to_logical(winit_window.scale_factor());
let mut location = touch.location.to_logical(window.scale_factor());

// On a mobile window, the start is from the top while on PC/Linux/OSX from
// bottom
Expand Down

0 comments on commit 1c32862

Please sign in to comment.