Bug 477455 - Software cursor repaints are glitchy with fractional scaling sometimes
Summary: Software cursor repaints are glitchy with fractional scaling sometimes
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: wayland-generic (show other bugs)
Version: 5.27.9
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords: qt6, wayland
Depends on:
Blocks:
 
Reported: 2023-11-24 09:49 UTC by Asahi Lina
Modified: 2023-12-19 15:21 UTC (History)
3 users (show)

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


Attachments
Screenshot of the issue (443.70 KB, image/jpeg)
2023-11-24 09:49 UTC, Asahi Lina
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Asahi Lina 2023-11-24 09:49:12 UTC
Created attachment 163421 [details]
Screenshot of the issue

SUMMARY

When using fractional scaling with software cursors, sometimes cursor repaints leave behind one-pixel-wide regions of damage.

The easiest way to reproduce this is on window decorations after killing plasmashell, but I think this is the same bug as other glitches that happen elsewhere (like when enabling the Blur effect and hovering over the Plasma taskbar). I think in many cases something else triggers a full screen repaint (or a larger repaint in general) and hides the bug.

STEPS TO REPRODUCE
1. Use software cursors (KWIN_FORCE_SW_CURSOR=1 or a platform with no HW cursors)
2. Configure a non-integer display scale
2. killall plasmashell
3. Hover over window decorations

OBSERVED RESULT
See attached screenshot (on the System Settings decorations). I took that with Spectacle video mode since normal screenshot mode always seemed to force a repaint and cleared out the damage, so please ignore the lower general quality. I think the duplicate cursor is a Spectacle thing (it's probably overlaying its own cursor on top of the software cursor that is already part of the framebuffer, which is probably another bug somewhere...).

EXPECTED RESULT
Correct rendering

SOFTWARE/OS VERSIONS
Operating System: Fedora Linux Asahi Remix 39
KDE Plasma Version: 5.27.9
KDE Frameworks Version: 5.111.0
Qt Version: 5.15.11
Kernel Version: 6.6.0-asahi-00861-g9b58b16aa50d (64-bit)
Graphics Platform: Wayland
Processors: 12
Memory: 54.5 GiB of RAM
Graphics Processor: Apple M2 Max
Product Name: Apple MacBook Pro (16-inch, M2 Max, 2023)

ADDITIONAL INFORMATION
Comment 1 Bug Janitor Service 2023-12-14 13:40:25 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/4793
Comment 2 Vlad Zahorodnii 2023-12-19 09:36:07 UTC
Git commit 2e78ae2b6dc2a05061e0e729595d22dbd97eb52d by Vlad Zahorodnii.
Committed on 19/12/2023 at 10:00.
Pushed by vladz into branch 'master'.

core: Fix pixel grid snapping in RenderViewport

Our painting code is assumed to work as following: scale the geometry,
snap it to the pixel grid, apply the render transform, e.g. flip the
geometry vertically.

However, with QMatrix4x4 in RenderViewport, we have a slightly different
order: scale the geometry, apply the render transform, snap to the pixel
grid. It results in mapToRenderTarget() not properly mapping logical
geometry to the device geometry, which later manifests as glitches.

M  +1    -0    src/CMakeLists.txt
A  +38   -0    src/core/pixelgrid.h     [License: GPL(v2.0+)]
M  +20   -0    src/core/rendertarget.cpp
M  +2    -0    src/core/rendertarget.h
M  +26   -39   src/core/renderviewport.cpp
M  +2    -2    src/core/renderviewport.h
M  +2    -8    src/plugins/startupfeedback/startupfeedback.cpp
M  +4    -10   src/scene/itemrenderer_opengl.cpp

https://invent.kde.org/plasma/kwin/-/commit/2e78ae2b6dc2a05061e0e729595d22dbd97eb52d