-
Notifications
You must be signed in to change notification settings - Fork 943
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inconsistent usage of LogicalPosition vs PhysicalPosition #1406
Comments
I'm also having problems with hidpi scaling and mouse position in RLTK (the default Glutin + Winit back-end). Take the following snippet of code from the event loop: WindowEvent::CursorMoved { position: pos, .. } => {
let sf = wc.window().scale_factor();
println!("Scale factor: {:?}, Pos:{:?}, Dimensions: {:?}", sf, pos, wc.window().inner_size());
} On Windows 10, with scaling set to 100%, when you move the mouse cursor to the bottom right it outputs:
The On Windows 10, with scaling set to 200%, moving to the bottom right outputs:
The On Ubuntu (VM), Wayland with scaling set to 100%, moving to the bottom right outputs:
Again - that works. Ranges are correctly in the 0..640/0..400 range. On Ubuntu (VM), Wayland with scaling set to 200%, moving to the bottom right outputs:
So with a scale factor on Wayland, the I'd rather not work-around this by detecting Linux and calculate the position differently. For reference, the parent RLTK issue is: amethyst/bracket-lib#40 |
@thebracket Could you retest your Wayland thing with the latest winit? There're was a bug about this a while ago that should be fixed on master. |
I just updated to One possibly related thing I noticed: if you set your scaling to 125% in Ubuntu/Wayland, |
Wayland doesn't have a fractional scaling, so you can get only integers from Your Wayland issue was solved in #1385 , so you should use winit from master. |
Thanks. I guess I'm waiting on other packages (glutin) to update, then. |
you can bump winit without bumping glutin IIRC, so you should just use https://doc.rust-lang.org/cargo/reference/manifest.html |
Thanks, I just found that. :-) |
Using the latest HEAD, I'm still having all kinds of problems on Wayland. It's pretty consistent on X11 and Windows 10. To be sure I'm doing it right, I'm overriding the [patch.crates-io]
winit = { git = "https://github.com/rust-windowing/winit" }
If I had to hazard a guess, the inner/outer size is probably the culprit on Wayland. It doesn't make any sense for them to be exactly the same (on a window with default decorations), and neither is correct! On X11, I see an inner size of 640x400 and an outer size of 640x437. Windows 10 gives me an inner of 640x400 and an outer of 640x439. |
Are you testing on GNOME Wayland with window decorations? |
Yes. Ubuntu in a VM, normal 100% scaling (scaling to 200% is also wrong). Pretty much out-of-the-box defaults, picking "Ubuntu on Wayland" at login. "Ubuntu" (normal via X11) and dwm work great. |
this 30 more for |
Could test with creating winit window without decorations? |
Turning off window decorations yields the correct sizes and mouse positioning works. I kinda suspect that the Wayland decoration initialization is going the wrong way with the decorations resize. The outer size grew by 30 pixels, but the inner size remained 640x400 as requested (I took a screenshot and measured in an art program; the displayed window is 640x400 but the size functions reply with 370). |
@thebracket next time, try not to hijack a completely different issue. |
@dhardy - Sorry. I misread the bug report and it looked like a similar physical vs. logical issue. |
This removes the `LogicalPosition` from the `PixelDelta`, since all other APIs have been switched to use `PhysicalPosition` instead too. It also seems like `LineDelta` was using both logical and physical sizes, depending on platform, and so it was changed to explicitly take a `PhysicalPosition` parameter to force a uniform return value. Fixes rust-windowing#1406.
This removes the `LogicalPosition` from the `PixelDelta`, since all other APIs have been switched to use `PhysicalPosition` instead too. Fixes #1406.
This removes the `LogicalPosition` from the `PixelDelta`, since all other APIs have been switched to use `PhysicalPosition` instead too. Fixes rust-windowing#1406.
This removes the `LogicalPosition` from the `PixelDelta`, since all other APIs have been switched to use `PhysicalPosition` instead too. Fixes #1406.
This removes the `LogicalPosition` from the `PixelDelta`, since all other APIs have been switched to use `PhysicalPosition` instead. Fixes #1406.
I notice that sometime between version 0.20.0-alpha5 and 0.20.0, some parts of the event loop started reporting physical positions instead of logical ones:
CursorMoved::position
andTouch::location
(with differing types; this seems okay). Conversely,MouseScrollDelta::PixelDelta
still uses aLogicalPostiion
(didn't check whether there are others).I'm actually fine with this either way; converting is easy and the types catch any errors; it just seems like an oversight being inconsistent.
Additionally, my lib mostly uses physical positions internally (to avoid fractional positions / or limited GUI scaling), and using a physical position here would reduce the number of places the lib needs to track the DPI factor.
The text was updated successfully, but these errors were encountered: