Bug 492052 - Lower-right corner borders (window outline) are buggy in Wayland session
Summary: Lower-right corner borders (window outline) are buggy in Wayland session
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: decorations (other bugs)
Version First Reported In: 6.1.4
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-08-22 22:45 UTC by jys1670
Modified: 2024-12-13 15:39 UTC (History)
3 users (show)

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


Attachments
non-uniform window borders (89.83 KB, image/jpeg)
2024-08-22 22:45 UTC, jys1670
Details

Note You need to log in before you can comment on or make changes to this bug.
Description jys1670 2024-08-22 22:45:49 UTC
Created attachment 172864 [details]
non-uniform window borders

This feels like https://bugs.kde.org/show_bug.cgi?id=453745 (in Plasma 5)
To make the problem more noticeable, go to Window Decorations > Edit theme (Breeze in my case) > Shadows and Outline > Outline intensity > pick "Maximum"
After that, take a look at the lower-right corner borders of any application with Global scale != 100% (I tested with 175%). I've attached a screenshot with visible defects just in case (some parts are manually resized, ignore blurriness, look at borders).

SOFTWARE/OS VERSIONS
Operating System: NixOS 24.11
KDE Plasma Version: 6.1.4
KDE Frameworks Version: 6.5.0
Qt Version: 6.7.2
Kernel Version: 6.6.46-xanmod1 (64-bit)
Graphics Platform: Wayland
Comment 1 jys1670 2024-08-25 11:22:18 UTC
This might resolve the issue https://invent.kde.org/plasma/kwin/-/merge_requests/5950
If you drag the window left/right, it's possible to notice that the border is actually rendered, but at the wrong position? Similar to these tiny gaps problems.
Comment 2 Zamundaaa 2024-09-03 21:42:43 UTC
Yes, it should fix this
Comment 3 Zamundaaa 2024-12-13 15:39:49 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 452438

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