From 11567b31f947a00a56e788bf794ffac43ea23187 Mon Sep 17 00:00:00 2001 From: ickshonpe Date: Thu, 31 Aug 2023 20:02:33 +0100 Subject: [PATCH] Change `Window::physical_cursor_position` to use the physical size of the window (#9657) # Objective `Window::physical_cursor_position` checks to see if the cursor's position is inside the window but it constructs the bounding rect for the window using its logical size and then checks to see if it contains the cursor's physical position. When the physical size is smaller than the logical size, this leaves a dead zone where the cursor is over the window but its position is unreported. fixes: #9656 ## Solution Use the physical size of the window. --- crates/bevy_window/src/window.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/bevy_window/src/window.rs b/crates/bevy_window/src/window.rs index 10420f44c0..c4e06fbc56 100644 --- a/crates/bevy_window/src/window.rs +++ b/crates/bevy_window/src/window.rs @@ -330,7 +330,14 @@ impl Window { match self.internal.physical_cursor_position { Some(position) => { let position = position.as_vec2(); - if Rect::new(0., 0., self.width(), self.height()).contains(position) { + if Rect::new( + 0., + 0., + self.physical_width() as f32, + self.physical_height() as f32, + ) + .contains(position) + { Some(position) } else { None