Bug 459373

Summary: Maximized XWayland apps leave pixel gaps when using a fractional scaling factor
Product: [Plasma] kwin Reporter: Iyán Méndez Veiga <me>
Component: wayland-genericAssignee: KWin default assignee <kwin-bugs-null>
Status: CONFIRMED ---    
Severity: normal CC: agurenko, albma, alx5000, anael, andre.vmatos, andrea.ippo, apricus, asturm, bednarczyk.pawel, bixilon, bizyaev, castleup, codemon66, dofficialgman, drokergeek, estrozix, fanzhuyifan, fzjgd8ga, gudvinr+kde, iamgrief, k2squared, kde, kde, kde, kde, kustodian, leafee98, liubomirwm, miranda, nate, postix, qufiwefefwoyn, qydwhotmail, sam, stephenackerman16, thelegendaryffoxd, tombrown9501, tuksgig, whyhow3.141, wshadough, xaver.hugl, yakutsoft, zawertun
Priority: NOR Keywords: regression
Version: 5.27.8   
Target Milestone: ---   
Platform: Other   
OS: Other   
See Also: https://bugs.kde.org/show_bug.cgi?id=459328
https://bugs.kde.org/show_bug.cgi?id=461032
https://bugs.kde.org/show_bug.cgi?id=472832
https://bugs.kde.org/show_bug.cgi?id=464842
https://bugs.kde.org/show_bug.cgi?id=464281
https://bugs.kde.org/show_bug.cgi?id=480171
https://bugs.kde.org/show_bug.cgi?id=481857
Latest Commit: Version Fixed In:
Attachments: Still an issue on 5.26.4
Still an issue on kwin-git a93ccbd7e74
Still an issue
Spotify

Description Iyán Méndez Veiga 2022-09-19 08:08:13 UTC
SUMMARY
After updating to Plasma 5.26, when I maximize xwayland apps (e.g. VLC, PyCharm, etc.), a column of 1 or 2 pixels are left to the right showing the background. In some situations it can be unnoticeable, but others can be very distracting.


STEPS TO REPRODUCE
1. In order to make it more obvious, choose a bright wallpaper (a solid white wallpaper is perfect)
2. Open a xwayland app (e.g. VLC) and maximize, either with the keyboard or with the window button
3. Observe a column of few pixels on the right not covered by the app

OBSERVED RESULT
xwayland apps don't use exactly the full screen when maximized. I cannot take a screenshot to show this, because Spectacle seems to ignore that extra column of pixels.

EXPECTED RESULT
Maximized apps, both xwayland and native wayland ones, should cover all screen when maximized.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux
KDE Plasma Version: 5.25.90
KDE Frameworks Version: 5.98.0
Qt Version: 5.15.6
Kernel Version: 5.19.9-arch1-1 (64-bit)
Graphics Platform: Wayland
Processors: 8 × 11th Gen Intel® Core™ i5-1135G7 @ 2.40GHz
Memory: 15.4 GiB of RAM
Graphics Processor: Mesa Intel® Xe Graphics
Manufacturer: LENOVO
Product Name: 20XYCTO1WW
System Version: ThinkPad X1 Yoga Gen 6
Comment 1 A. R. Kristiansen 2022-09-19 21:39:35 UTC
This happens to me as well on my HiDPI laptop, it is very noticeable in Blender (with xwayland) as it leaves a 2 pixel gap between the right side and along the bottom of the window, when it is maximized.
It is also noticeable in VLC.

In Blender, most of the app looks very crisp and nice thanks to using its own scaling, but near the right side and bottom, elements are slightly blurry. I wonder if it's because of this gap?

SOFTWARE/OS VERSIONS
Operating System: Arch Linux
KDE Plasma Version: 5.25.90
KDE Frameworks Version: 5.98.0
Qt Version: 5.15.6
Kernel Version: 5.19.9-zen1-1-zen
Graphics Platform: Wayland

Laptop: Lenovo IdeaPad 5 Pro 16ACH6
Processor and Graphics: AMD Ryzen 5 5600H with Vega 7 graphics
Product Name: 82L5
System Version: ThinkPad X1 Yoga Gen 6
Screen resolution: 2560x1600
PPI: 188.68
Scaling in Plasma settings: 150%
Comment 2 Iyán Méndez Veiga 2022-09-21 08:10:30 UTC
I also note that same happens in the bottom as confirmed by Aurora.
Comment 3 Bug Janitor Service 2022-09-28 09:00:06 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/3008
Comment 4 Iyán Méndez Veiga 2022-10-13 10:43:32 UTC
Why was the fix not merge to 5.26?
Comment 5 Nate Graham 2022-10-14 17:51:55 UTC
It hasn't been merged anywhere yet; the change is still under review.
Comment 6 Zamundaaa 2022-10-14 23:40:21 UTC
*** Bug 458481 has been marked as a duplicate of this bug. ***
Comment 7 Zamundaaa 2022-10-23 21:29:41 UTC
Git commit ceae7175006c9b56acc63d40bcaa93986ed28572 by Xaver Hugl.
Committed on 23/10/2022 at 20:06.
Pushed by zamundaaa into branch 'master'.

output: don't round geometry as often

M  +5    -0    src/core/output.cpp
M  +5    -0    src/core/output.h
M  +4    -4    src/wayland/xdgoutput_v1_interface.cpp
M  +4    -4    src/workspace.cpp

https://invent.kde.org/plasma/kwin/commit/ceae7175006c9b56acc63d40bcaa93986ed28572
Comment 8 Zamundaaa 2022-10-23 22:45:44 UTC
Git commit dadf93f87ae338d9b3765507d3fd1b3e8c9fa440 by Xaver Hugl.
Committed on 23/10/2022 at 22:36.
Pushed by zamundaaa into branch 'Plasma/5.26'.

output: don't round geometry as often
(cherry picked from commit ceae7175006c9b56acc63d40bcaa93986ed28572)

M  +5    -0    src/core/output.cpp
M  +5    -0    src/core/output.h
M  +11   -11   src/wayland/xdgoutput_v1_interface.cpp
M  +4    -4    src/wayland/xdgoutput_v1_interface.h
M  +2    -2    src/waylandoutput.cpp
M  +4    -4    src/workspace.cpp

https://invent.kde.org/plasma/kwin/commit/dadf93f87ae338d9b3765507d3fd1b3e8c9fa440
Comment 9 Iyán Méndez Veiga 2022-10-25 14:44:09 UTC
The merged patch is only a partial solution for this bug. There are still combinations of screen resolutions and scale factors where one can get a border. Should we keep this open not to forget or should I open a new bug?
Comment 10 Joshua T 2022-10-25 14:46:08 UTC
(In reply to Iyán Méndez Veiga from comment #9)
> The merged patch is only a partial solution for this bug. There are still
> combinations of screen resolutions and scale factors where one can get a
> border. Should we keep this open not to forget or should I open a new bug?

Maybe so, that makes sense. I have still experienced a small gap on the bottom of Xwayland windows.
Comment 11 Iyán Méndez Veiga 2022-11-18 09:36:15 UTC
I just noticed today that this is again as bad as when I first reported this bug. Was something reverted in 5.26.3?
Comment 12 Zamundaaa 2022-11-18 15:38:28 UTC
Yes, part of had to be reverted due to the Xorg session breaking really badly
Comment 13 Bug Janitor Service 2022-11-18 21:53:43 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/3215
Comment 14 Aleix Pol 2022-11-21 19:09:52 UTC
Git commit df77fcd9e01d8cd2a31f785acde214f2146c04e2 by Aleix Pol Gonzalez, on behalf of Aleix Pol.
Committed on 21/11/2022 at 14:16.
Pushed by apol into branch 'master'.

x11window: Calculate the native floor from the begining of the output

If this function is useful to make sure we are properly aligned with the
output's pixels, we should start with the output's 0, otherwise we'll be
carrying over the rounding errors increasingly as our workspace grows.

M  +10   -0    src/core/output.cpp
M  +10   -0    src/core/output.h
M  +9    -4    src/utils/xcbutils.cpp
M  +0    -1    src/utils/xcbutils.h

https://invent.kde.org/plasma/kwin/commit/df77fcd9e01d8cd2a31f785acde214f2146c04e2
Comment 15 André M 2022-11-29 18:38:28 UTC Comment hidden (spam)
Comment 16 Joshua T 2022-11-29 20:11:36 UTC Comment hidden (spam)
Comment 17 Iyán Méndez Veiga 2022-11-29 21:19:39 UTC Comment hidden (spam)
Comment 18 Nate Graham 2022-11-29 21:21:23 UTC Comment hidden (spam)
Comment 19 Iyán Méndez Veiga 2022-11-29 21:50:22 UTC
Nate: I know the patch was not merged for 5.26.4, but I just compiled kwin 5.26.4 with that additional patch (I guess André M did the same), and it doesn't fix the issue. As far as I know, that commit was the only one mentioned this bug in master.
Comment 20 André M 2022-11-29 23:47:44 UTC
Created attachment 154154 [details]
Still an issue on kwin-git a93ccbd7e74

Ok, compiled kwin-git, kdecoration-git and kwayland-git as of today, and the issue is still present, but has improved; if you compare with the previous screenshot with VLC, the bottom pixel is gone, and when in fullscreen, Xwayland apps also don't show the bug; BUT when Xwayland app is maximized, on the right side the wallpaper still can be seen; while it's maximized, editing the left panel's width makes it disappear, but as soon as unmaximizing and remaximizing the app, the bleeding shows up again.
Comment 21 Nate Graham 2022-11-30 17:04:47 UTC
Ok, thanks for testing so extensively!
Comment 22 Iyán Méndez Veiga 2023-01-19 22:17:50 UTC
I still observe this issue with Plasma 5.26.90 and KDE Frameworks 5.102.0.
Comment 23 Nate Graham 2023-01-20 22:18:31 UTC
*** Bug 462906 has been marked as a duplicate of this bug. ***
Comment 24 André M 2023-01-25 20:32:50 UTC
The situation seems to have improved on Plasma 5.26.90 (5.27 beta):
While moving a *xwayland window* between 2 monitors (main 2560x1600 150% with left, top panels; right 2560x1440 135% no panels), when they go to the other monitor while already maximized, they occupy the correct area on the other monitor, leaving no gaps; when unmaximizing and re-maximizing in place, the right border still leaves a couple of pixels off, showing the wallpaper or window below, as before. Either way, bottom gap is gone.
Comment 25 Hexagon 2023-02-22 18:12:29 UTC
Hi guys. I would highly recommend to add this issue to the "15 minute bug initiative" https://tinyurl.com/plasma-15-minute-bugs.
I am using Plasma (Wayland) with these pixel bugs now for several months and it is not fixed at all, contrary to some comments here. Only on some configurations of monitor placement, resolutions and (important!) scaling the border disappears. But one should not have to worry to set the scaling smaller or bigger than wanted, just to prevent this ugly visual problem, which makes Plasma look buggy from the very first minute of usage where you configure your screens. Also it is a major selling point of Wayland, that now scaling works correctly, important for newer Hi-DPI monitors. This would contradict, at least for KDE Plasma.

Unfortunately I am not a C++ developer myself to provide a fix myself, but I can provide testing data. Here are my findings:
-  I am testing with the program glxgears which provides a black background and runs in Xwayland. Then I set my desktop background to full white. That way one can see the pixel rows better.
- I am using a triple monitor setup with (from left to right): A: 2560x1440@150%, B: 3840x2160@200%, C: 2560x1440@150%
- I am using the newest release plasma-wayland-session 5.27.1-1 on Arch
- By chaning the scaling of the monitors A, B and C I can produce three different states on all of them:
1) No borders at all (perfect)
2) Vertical pixel row on the right spanning up even to the header bar of the window with the size of 1 pixel
3) Number 2 + Horizontal pixel row on the bottom with the size of 1 or 2 pixels

Thanks for your work in this. I hope we can get a real fix soon to make the pixel border a thing of the past, regardless of monitor placement, resolutions and scaling settings. If you need more information don't hesitate to ask.
Comment 26 Nate Graham 2023-02-22 18:17:43 UTC
The 15-minute bug initiative currently doesn't include Wayland-only bugs due to Wayland not being the default session type in Plasma itself.

Hopefully it will get fixed soon, yeah.
Comment 27 Nate Graham 2023-02-24 01:17:15 UTC
Not fixed by the fix for Bug 465850, in case anyone was wondering.
Comment 28 hexchain 2023-03-06 06:04:56 UTC
I have a panel on the left screen edge. When an XWayland window is already maximized, changing the panel width or changing the scale factor a little bit (e.g. 175 to 170 or 180 and vice versa) makes gaps disappear. But they come back after re-maximizing the window.
Comment 29 Hexagon 2023-03-24 18:34:10 UTC
The problem exists now for over 6 months and it does not seem to have improved. Unfortunately I do not have enough insight to provide a fix myself. Could anyone involved in KWin please take a look at this problem? I think it influences the whole Plasma experience on Wayland as nearly anyone uses some kind of legacy application with xWayland and Hi-DPI monitors with scaling get more and more common. Who knows, maybe it is just a "off by one error" somewhere in the forwarding of the coordinates from the Xorg application to the Wayland wrapper window in KWin. Or the coordinates returned when the maximizeWindow() function is called returns wrong values, explaining why the border sometimes disappears until one maximizes the window again. Whatever it is, please try to find a solution. Thanks to all involved.
Comment 30 David Edmundson 2023-03-25 12:55:20 UTC
*** Bug 467658 has been marked as a duplicate of this bug. ***
Comment 31 Nate Graham 2023-04-06 15:23:21 UTC
*** Bug 468131 has been marked as a duplicate of this bug. ***
Comment 32 Iyán Méndez Veiga 2023-04-27 09:04:57 UTC
A weird behavior (probably related) that maybe helps debug this. When running Inkscape with Xyayland (with native wayland it crashes continuously for me at the moment), if one maximizes the window and start working with the app (just by moving the mouse around, for example), the window starts to get resized, reducing the height. I will attach a video later today since this is hard to explain with words.
Comment 33 Nate Graham 2023-05-02 15:54:53 UTC
*** Bug 469122 has been marked as a duplicate of this bug. ***
Comment 34 Bug Janitor Service 2023-05-10 10:30:06 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/4088
Comment 35 Zamundaaa 2023-05-10 11:06:42 UTC
Git commit a48c98f5aba71fab8bc1e1d5dd18668833631920 by Xaver Hugl.
Committed on 10/05/2023 at 10:52.
Pushed by zamundaaa into branch 'master'.

xcbutils: fix nativeFloor

The floor was not done in the X-native coordinate space but with double
scaling

M  +1    -1    src/utils/xcbutils.cpp

https://invent.kde.org/plasma/kwin/commit/a48c98f5aba71fab8bc1e1d5dd18668833631920
Comment 36 Iyán Méndez Veiga 2023-05-10 11:17:21 UTC
THANK YOU Xaver!!! I confirm the patch works for me.
Comment 37 Iyán Méndez Veiga 2023-05-10 11:18:33 UTC
Too bad it didn't make it to 5.27.5. Hopefully, some distros will pick the one line patch.
Comment 38 Iyán Méndez Veiga 2023-05-10 11:41:07 UTC
As a side comment, I've seen several similar issues in the last months (I think since Plasma 5.25). Maybe is it possible to include some unit tests for the different scaling cases? Probably it fits the "Automate And Systematize Internal Processes" goal, no? The thing is that these issues are hard to debug, but very noticeable by affected users. Maybe for Plasma 6.0?
Comment 39 Vlad Zahorodnii 2023-05-10 11:55:15 UTC
Git commit 2237391e979b2423462bb5eaf1fdf4c0876f7476 by Vlad Zahorodnii, on behalf of Xaver Hugl.
Committed on 10/05/2023 at 11:11.
Pushed by vladz into branch 'Plasma/5.27'.

xcbutils: fix nativeFloor

The floor was not done in the X-native coordinate space but with double
scaling


(cherry picked from commit a48c98f5aba71fab8bc1e1d5dd18668833631920)

M  +1    -1    src/utils/xcbutils.cpp

https://invent.kde.org/plasma/kwin/commit/2237391e979b2423462bb5eaf1fdf4c0876f7476
Comment 40 Iyán Méndez Veiga 2023-05-10 16:20:20 UTC
Sorry to finish the "it's fixed" party, but after double checking on my laptop, I still get a 1px gap down (but not on the right). Is it possible that there is another similar issue affecting the vertical size?
Comment 41 Zamundaaa 2023-05-10 16:29:31 UTC
Yes, there is at least one known additional issue, which will (usually) only be between the panel and the window. Please create a separate bug report for that, with the resolution + scale + if it happens with Wayland native windows too
Comment 42 Iyán Méndez Veiga 2023-05-10 16:39:21 UTC
(In reply to Zamundaaa from comment #41)
> Yes, there is at least one known additional issue, which will (usually) only
> be between the panel and the window. Please create a separate bug report for
> that, with the resolution + scale + if it happens with Wayland native
> windows too

Yes, exactly, it's only between the panel and the window, but ONLY XWayland apps, not Wayland native windows. Should I open a new issue or can we keep this one open?
Comment 43 André M 2023-05-10 17:53:25 UTC
Created attachment 158837 [details]
Still an issue

I think this is not fixed, got the issue with this patch applied on top of 5.27.5, with the pixel NOT between the window and panel (attached screenshot). 2560x1600@145% window (there's a 2560x1440@135% screen to the right, but it shouldn't matter, right?), VLC flatpak on Xwayland.
Comment 44 André M 2023-05-10 22:34:09 UTC
Just to remark: if the Xwayland window is in maximized state, and *moved* to another screen (e.g. through Meta+Shift+Left/Right or Present Desktops effect), when it lands on the other screen, it doesn't have the gap. Unmaximizing and remaximizing makes the gap show off. So it looks like the Maximized Geometry calc when moving screens is correct, and the restore/remaximize one is wrong.
Comment 45 Hexagon 2023-05-22 11:47:40 UTC
I just noticed another behavior. When maximizing a Xwayland application and then closing and reopening it, it is not maximized anymore and has a 5 pixel border on the right. This happens f.e. with Spotify (Electron).
Comment 46 moshpirit 2023-07-01 22:51:53 UTC
This is still happening to me when using:

•  LibreOffice: https://i.imgur.com/kI3ytcF.png
• Gwenview: https://i.imgur.com/uA62KvI.png
• Dolphin: https://i.imgur.com/gOStT09.png
• System settings: https://i.imgur.com/b1vTYVM.png (this screenshot shows the resolution of my screen, just in case this helps)
• Other software like Kdenlive, KDevelop, Kate...

Doesn't happen on Firefox or GIMP.

This happens both when I maximize the windows, and they get opened maximized already.

This is all on X11.  None of this happens on Wayland.
I'm using Arch Linux, with Plasma 5.27.6. Intel graphics (Alder Lake-P Integrated Graphics Controller) on a Lenovo Yoga slim 7i pro (with high DPI).
Comment 47 Zamundaaa 2023-07-02 18:35:13 UTC
*** Bug 471832 has been marked as a duplicate of this bug. ***
Comment 48 Lyubomir 2023-07-08 21:57:39 UTC
Created attachment 160207 [details]
Spotify

Still happens with Spotify on 5.27.6.
Comment 49 aquaponieee 2023-07-11 07:35:07 UTC
i can confirm the bug is still present
some observations i have found:
- snapping the window to a corner or edge does not result in gaps
- resizing the window to take up the whole screen does not show gaps
- only maximizing the window results in the gaps
- resizing the panel to any value while the window is maximized removes the gaps
Comment 50 Fushan Wen 2023-09-11 16:22:34 UTC
Can anyone reproduce the bug in 5.27.8? A fix landed in Breeze to fix the 1px gap on X11, but I am not sure if it's the same bug.

https://invent.kde.org/plasma/breeze/-/merge_requests/352
Comment 51 A. R. Kristiansen 2023-09-12 14:48:23 UTC
Didn't have time to check X11, but I just updated on my laptop and rebooted, can still observe on 5.27.8
Comment 52 Fushan Wen 2023-09-12 14:49:12 UTC
Thanks
Comment 53 Iyán Méndez Veiga 2023-09-12 20:11:35 UTC
No, no difference for me neither with Plasma 5.27.8.
Comment 54 Nate Graham 2023-09-25 17:46:00 UTC
*** Bug 474843 has been marked as a duplicate of this bug. ***
Comment 55 Andrea Ippolito 2023-12-10 22:20:49 UTC
5.27.10, still reproducible
Comment 56 Nate Graham 2024-01-23 19:46:10 UTC
Still reproducible for me in Plasma 6, too.
Comment 57 Kenneth 2024-02-04 00:04:00 UTC
Reproducible when using only wayland native apps on Plasma 6 RC2 with Qt 6.7.0 (archlinux). Weirdly what fixes it right away is swiping 3 fingers right (with no virtual desktop change since there isn't one on the left).
Comment 58 Nate Graham 2024-02-05 20:06:10 UTC
That sounds like something else, maybe Bug 480171.
Comment 59 Nate Graham 2024-02-14 19:47:59 UTC
*** Bug 481097 has been marked as a duplicate of this bug. ***
Comment 60 André M 2024-02-15 19:39:31 UTC
I also see this happening in Plasma 6rc2, not only with XWayland, but also native Wayland apps.
I added some logs to xdgshellwindow.cpp, and it seems the events emit QRectFs in translated coordinates, e.g.: if you have 1200p screen with 1.45x scale, it'll send a client height of 827.5862p. Eventually, this won't add up and the gaps will show.
How feasible it'd be to keep physical/real dimensions everywhere (since those are always integers), and have the scale be sent to the clients just as a hint to render larger elements? i.e. move scale to the "edges" of the software
Comment 61 Zamundaaa 2024-02-15 20:57:45 UTC
For native Wayland apps see bug 480171; its cause is the Wayland protocol for fractional scaling being inherently broken.
Comment 62 Vlad Zahorodnii 2024-03-01 15:02:03 UTC
Git commit 2491fb1b2b02db5352bc02050298e7522d4dfaa5 by Vlad Zahorodnii.
Committed on 01/03/2024 at 14:50.
Pushed by vladz into branch 'master'.

Ignore size hints when maximizing X11 windows

This is to help to fix maximized xwayland windows not covering the whole
work area. Size hints are obeyed only when restoring the window.

According to the net wm spec, the window manager should not obey size
hints when maximizing a window and some other window managers already ignore
them when maximizing windows.

M  +15   -92   src/x11window.cpp

https://invent.kde.org/plasma/kwin/-/commit/2491fb1b2b02db5352bc02050298e7522d4dfaa5
Comment 63 Nate Graham 2024-03-05 23:41:01 UTC
*** Bug 482368 has been marked as a duplicate of this bug. ***
Comment 64 fanzhuyifan 2024-03-29 15:14:22 UTC
*** Bug 484700 has been marked as a duplicate of this bug. ***