Skip to content

Commit

Permalink
Change Window::physical_cursor_position to use the physical size of…
Browse files Browse the repository at this point in the history
… the window (bevyengine#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: bevyengine#9656

## Solution

Use the physical size of the window.
  • Loading branch information
ickshonpe authored and Ray Redondo committed Jan 9, 2024
1 parent 2426e4d commit 329580e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion crates/bevy_window/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 329580e

Please sign in to comment.