Bug 452438 - Black line between the titlebar and window content with < 100% scaling, depending on window position on screen
Summary: Black line between the titlebar and window content with < 100% scaling, depen...
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: compositing (other bugs)
Version First Reported In: master
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-04-09 15:35 UTC by ryu.ketsueki
Modified: 2024-12-13 15:39 UTC (History)
2 users (show)

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


Attachments
A demonstration of what is happening (394.49 KB, image/png)
2022-04-09 15:35 UTC, ryu.ketsueki
Details

Note You need to log in before you can comment on or make changes to this bug.
Description ryu.ketsueki 2022-04-09 15:35:28 UTC
Created attachment 148073 [details]
A demonstration of what is happening

SUMMARY
This is something that happens on the Wayland session with some windows, like LibreOffice and Wine applications. It also only happens if the scaling is not 100%. In my case, it's 75% because of the low display resolution. Moving the window on screen will change if the black line will appear or not, as well as the thickness of the line, so it would appear that there is something with the scaling that doesn't fully align the content of the window inside the window itself.

STEPS TO REPRODUCE
1. Set Wayland scaling to 75%
2. Open any non KDE window, even other Qt windows
3. Move them around vertically

OBSERVED RESULT
A black line appears under the titlebar, with even the thickness varying depending on the position

EXPECTED RESULT
No such black line to appear

SOFTWARE/OS VERSIONS
Operating System: openSUSE Tumbleweed 20220406
KDE Plasma Version: 5.24.80
KDE Frameworks Version: 5.93.0
Qt Version: 5.15.2
Kernel Version: 5.17.1-1-default (64-bit)
Graphics Platform: Wayland
Processors: 4 × Intel® Core™ i3-7020U CPU @ 2.30GHz
Memory: 11.5 GiB of RAM
Graphics Processor: Mesa Intel® HD Graphics 620
Manufacturer: LENOVO
Product Name: 81FE
System Version: Lenovo ideapad 330-15IKB
Comment 1 Bug Janitor Service 2024-06-20 16:51:24 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/5950
Comment 2 Zamundaaa 2024-12-13 15:39:41 UTC
Git commit 8fa7eedf74259280ad8ebdd0159066728c604fcb by Xaver Hugl.
Committed on 13/12/2024 at 15:13.
Pushed by zamundaaa into branch 'master'.

window: snap sizes to the pixel grid and double buffer decoration state

This ensures that the decoration (as well as other KWin code) gets a logical size that fits
perfectly on the pixel grid. In other words, multiplying it with the scale factor results in
an integer, so there are no gaps or overlaps when using the floating point value in geometry
calculations or painting code.

For example, before, if you had a screen with 200% scale, and a window on it that's 49u wide
with 1px wide decoration borders, the border size in integer logical units would be
    round(1px / 200%) = 1u
and the resulting size
    1u + 49u + 1u = 51u => 51 * 200% = 102px
but the actual pixel size is
    1px + 49u * 200% + 1px = 100px

with this change, the floating point numbers are taken into account, the decoration border is
    1px / 200% = 0.5u
wide and thus the logical window size is
    0.5u + 49u + 0.5u = 50u => 100px
which matches the actual pixel size perfectly.

Similar issues were observable with the window size at non-integer scale factors, which also
get fixed by this commit.

Co-authored-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
Related: bug 483338, bug 492052

M  +23   -0    src/core/pixelgrid.h
M  +14   -1    src/decorations/decoratedwindow.cpp
M  +2    -0    src/decorations/decoratedwindow.h
M  +1    -0    src/decorations/decorationbridge.cpp
M  +16   -5    src/inputpanelv1window.cpp
M  +2    -1    src/inputpanelv1window.h
M  +11   -1    src/internalwindow.cpp
M  +2    -0    src/kcms/decoration/declarative-plugin/previewbutton.cpp
M  +10   -0    src/kcms/decoration/declarative-plugin/previewclient.cpp
M  +2    -0    src/kcms/decoration/declarative-plugin/previewclient.h
M  +2    -0    src/kcms/decoration/declarative-plugin/previewitem.cpp
M  +17   -3    src/layershellv1window.cpp
M  +3    -1    src/layershellv1window.h
M  +1    -1    src/plugins/kdecorations/aurorae/src/aurorae.cpp
M  +6    -21   src/scene/decorationitem.cpp
M  +1    -2    src/scene/decorationitem.h
M  +2    -1    src/waylandwindow.cpp
M  +26   -12   src/window.cpp
M  +10   -5    src/window.h
M  +16   -5    src/x11window.cpp
M  +1    -0    src/x11window.h
M  +51   -22   src/xdgshellwindow.cpp
M  +11   -2    src/xdgshellwindow.h

https://invent.kde.org/plasma/kwin/-/commit/8fa7eedf74259280ad8ebdd0159066728c604fcb