Repository navigation
fix: improve screen edge mouse pointer accuracy - #2568
Conversation
ecdd282 to
71df0cd
Compare
71df0cd to
2e16ca3
Compare
2e16ca3 to
dc52683
Compare
Drakulix
left a comment
There was a problem hiding this comment.
Looks good apart from two small nitpicks.
|
This has a regression in that you can't grab the scrollbar of a maximized window at the right screen edge, with the resize indicator showing up (which was the reason I originally added the -1, since the cursor goes off-screen) :( The same is true for the bottom edge. |
dc52683 to
992eefa
Compare
I have a separate PR for that issue, pop-os/iced#367 . |
|
Not iced related. This is with all apps (e.g. Firefox). |
|
I see, added a separate commit for it as it is a separate issue: rounding was used in calculations which could result in it rounding up and putting the relative position on edge while it actually being below. |
|
I added one more commit to address possible issues brought to life by the new pointer accuracy in tiling/mod.rs. The issue is still the same, I think that will be the last commit unless @git-f0x finds another issue. |
|
Actually relooking at it, I can probably fix most of those with just a to_i32_floor() without changing everything to f64 🤦 . Will rework it. |
1cc2385 to
5dd2fdd
Compare
5dd2fdd to
292442a
Compare
|
I did a full sweep where location and to_i32_round() was used and fixed them. |
|
I think the only very minor regression is that a 1 pixel line of the cursor isn't visible anymore when it's all the way at the right or bottom edges (like on other compositors). Might be related to the behavior in maximized Firefox when the cursor is all the way to the right and clicking the scrollbar with the stationary cursor to go to a point, the scrollbar proceeds to shrink after the click, instead of staying fully revealed like before. It gets revealed again if the cursor is moved (including pushing further into the edge). But that's very minor, and this fixes bigger issues. |
This fixes scrolling by moving to the edge in games when using scaling.
For testing purposes I encountered the initial issue in XCOM 2 and The Guild - Europa 1410 Demo in 3840*2160 at 175% scale but I think a lot of games were affected.
The current implementation removed 1 from the logical size as the upper margin of the clamp, which could easily remove several physical pixels and the mouse pointer would never reach the edges which resulted in games not scrolling down and right properly.
We now use 2 extra steps, first we use a margin of (last logical pixel + edge) / 2.
Then we limit the size to the floating value of the logical size. This is necessary as the values we get from Wayland are rounded and we can easily overflow into the upper bound otherwise.
I made a simple rust test:
Test code
Results
So we go from 16/55 tests passed to 53/55, the 2 failures are at very high scaling(275%) and are the result of the rounding of the geometry_size where the shortfall can be >= 1 pixels at those scales. I have no easy solution for this.