Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Window scale_factor_override() doesn't affect cursor position #2501

Closed
AidanBlair opened this issue Jul 19, 2021 · 2 comments
Closed

Window scale_factor_override() doesn't affect cursor position #2501

AidanBlair opened this issue Jul 19, 2021 · 2 comments
Labels
A-Windowing Platform-agnostic interface layer to run your app in C-Bug An unexpected or incorrect behavior D-Trivial Nice and easy! A great choice to get started with Bevy S-Ready-For-Implementation This issue is ready for an implementation PR. Go for it!

Comments

@AidanBlair
Copy link

Bevy version

0.5

Operating system & version

Windows 10

What you did

Because my screen has a high DPI and scales applications to 125%, I created a window with scale_factor_override: Some(1.0). I also added a button in the middle of the window.

What you expected to happen

The window will display at 100% scale (rather than 125%) and the cursor's position will update accordingly.

What actually happened

While the window did display correctly at 100% scale, the cursor position seems to still behave as if it was scaled to 125%. To click on the button, I had to click above and to the right of the button, and when I printed out the cursor position the top right corner's position was (480, 360) rather than the actual size of the window, (640, 480).

@AidanBlair AidanBlair added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Jul 19, 2021
@AidanBlair
Copy link
Author

AidanBlair commented Jul 20, 2021

I've attached an example program (I couldn't upload a .rs file so I copied it to a .txt file). If you don't have a font installed you can tell when the button is selected by the colour changing. Also, I have it printing out the cursor's location, to show that it doesn't match up with the actual size of the window.

scaling_example.txt

@alice-i-cecile alice-i-cecile added A-Windowing Platform-agnostic interface layer to run your app in and removed S-Needs-Triage This issue needs to be labelled labels Jul 26, 2021
@alice-i-cecile
Copy link
Member

Doing a bit of digging, this issue seems like it might have promising breadcrumbs from winit, our upstream dependency for windowing: rust-windowing/winit#1491

Now, let's track how cursor position is set...

update_cursor_position_from_backend seems to be the function in question. Let's see where that's called: here, in the bevy_winit module.

We have access to the scale factor information in that function already; it looks like it's just a matter of adding a multiplication step just above L315 (and adding some tests).

@alice-i-cecile alice-i-cecile added D-Trivial Nice and easy! A great choice to get started with Bevy S-Ready-For-Implementation This issue is ready for an implementation PR. Go for it! labels Jul 26, 2021
mockersf pushed a commit to mockersf/bevy that referenced this issue Oct 7, 2021
Sometimes the wrong scale factor was used (not accounting for
overrides).

Fixes bevyengine#2501
@bors bors bot closed this as completed in d65fbd7 Oct 16, 2021
sharkdp pushed a commit to sharkdp/bevy that referenced this issue Nov 8, 2021
# Objective

- Fixes bevyengine#2501 
- Builds up on bevyengine#2639 taking bevyengine#2639 (comment) into account

## Solution

- keep the physical cursor position in `Window`, and expose it.
- still convert to logical position in event, and when getting `cursor_position`


Co-authored-by: Ahmed Charles <acharles@outlook.com>
sharkdp pushed a commit to sharkdp/bevy that referenced this issue Dec 12, 2021
# Objective

- Fixes bevyengine#2501 
- Builds up on bevyengine#2639 taking bevyengine#2639 (comment) into account

## Solution

- keep the physical cursor position in `Window`, and expose it.
- still convert to logical position in event, and when getting `cursor_position`


Co-authored-by: Ahmed Charles <acharles@outlook.com>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-Windowing Platform-agnostic interface layer to run your app in C-Bug An unexpected or incorrect behavior D-Trivial Nice and easy! A great choice to get started with Bevy S-Ready-For-Implementation This issue is ready for an implementation PR. Go for it!
Projects
None yet
2 participants