Bug 481125 - Screen resolution gains additional 1px on wayland with fractional scaling
Summary: Screen resolution gains additional 1px on wayland with fractional scaling
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: wayland-generic (show other bugs)
Version: 5.27.8
Platform: Kubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-02-09 15:37 UTC by Denis Shiga
Modified: 2024-02-15 13:58 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 6.0
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Denis Shiga 2024-02-09 15:37:54 UTC
SUMMARY
Screen resolution gains additional 1px on wayland with fractional scaling.

STEPS TO REPRODUCE
1. Log in with wayland session, 100% scaling. Verify that your screen resolution matches what's in Settings with `xrandr` (in my case 2560 x 1440)
2. Set 150% scaling. Again, verify your resolution to be identical with what's in settings with `xrandr` (still 2560 x 1440 for me)
3. Restart the machine or the session

OBSERVED RESULT
Settings will still show original resolution (2560 x 1440 in my case) while in fact it gained +1px horizontally which can be verified with `xrandr` that shows 2561 x 1440.

EXPECTED RESULT
Resolution should stay the same regardless of scaling.

SOFTWARE/OS VERSIONS
Distro: Kubuntu 23.10
KDE Plasma Version: 5.27.8
KDE Frameworks Version: 5.110.0
Qt Version: 5.15.10
Session: Wayland

ADDITIONAL INFORMATION
I also tried this with my second screen which is 2560 x 1600 and it got +1px both horizontally and vertically after restart. This is also quiet pronounced with gaming both natively and on proton - everything becomes blurry and the game sees this "extended" resolution along with the original one. Selecting either of those results in blur btw. Running the game when xrandr reports proper resolution results in crisp, pixel-perfect experience.
There's a temporary solution - switch to 100% scale and then back to 150% and DON'T restart. It'll keep original resolution and it works fine.
I also tried this with different fractional scaling like 120%, 140%, 170% and the result is the same. Unsurprisingly, scaling factors like 200% and 300% work fine.
I'm not sure but this issue may be as well related to these:
https://bugs.kde.org/show_bug.cgi?id=459373
https://bugs.kde.org/show_bug.cgi?id=475612
https://bugs.kde.org/show_bug.cgi?id=480171
Comment 1 Nate Graham 2024-02-15 02:44:50 UTC
The root cause is the same as Bug 480171, which has been investigated there and found to be a limitation in the upstream wayland protocol. It turns out unfortunately to be a somewhat complicated issue. Anyway, marking as a duplicate.

*** This bug has been marked as a duplicate of bug 480171 ***
Comment 2 Zamundaaa 2024-02-15 03:51:58 UTC
I don't think this is a duplicate. While the same sort of coordinate system conversion is the most likely root cause, Xwayland scaling doesn't go through fractional-scale-v1, so this can be fixed.
Comment 3 Nate Graham 2024-02-15 03:52:52 UTC
Bug 480171 isn't the one about XWayland.
Comment 4 Denis Shiga 2024-02-15 07:15:47 UTC
Interesting thing to note is that everything is perfectly fine if you go and change scaling from 100% to anything in a live session.  
It's upon session start where additional 1px appears - it seems like when it tries to recalc screen size from local configs it has slightly different algo rather that calculating screen size from env vars during session run.
Comment 5 Zamundaaa 2024-02-15 13:58:29 UTC
I can reproduce this bug in 5.27, but not in Plasma 6. So this is already fixed :)