Skip to content

Fix cursor color swap from wrong XCursor pixel format#49

Merged
malbiruk merged 2 commits intomalbiruk:mainfrom
nico4348:fix/cursor-rb-channel-swap
Apr 20, 2026
Merged

Fix cursor color swap from wrong XCursor pixel format#49
malbiruk merged 2 commits intomalbiruk:mainfrom
nico4348:fix/cursor-rb-channel-swap

Conversation

@nico4348
Copy link
Copy Markdown
Contributor

Changes

In load_xcursor, tag the MemoryRenderBuffer with Fourcc::Argb8888 instead of Abgr8888. Also add a CAVEATS note on the xcursor::pixels_rgba misnomer so the trap doesn't come back.

Purpose

The xcursor crate's pixels_rgba field is misleadingly named — bytes are actually in [B, G, R, A] memory order (XCursor file layout: uint32 ARGB little-endian). Pairing that with Fourcc::Abgr8888 makes smithay upload the texture as GL (RGBA, UNSIGNED_BYTE), swapping R and B on screen. niri pairs pixels_rgba with Fourcc::Argb8888 in src/cursor.rs:255-257; adopt the same.

Reproduced on two machines with different GPUs/drivers. Verified after the fix against yellow/red/lavender themes — all render correctly.

Fixes #48

The xcursor crate's `Image::pixels_rgba` field is misleadingly named:
bytes come straight from the XCursor file, which stores pixels as uint32
ARGB little-endian — i.e. [B, G, R, A] in memory. The matching DRM fourcc
for that byte order is Argb8888 (smithay maps it to GL BGRA_EXT), not
Abgr8888 (which maps to GL RGBA and causes R/B to swap on screen).

niri uses the correct pairing at src/cursor.rs:255-257. Adopt the same.
The field name suggests RGBA but the bytes are in [B, G, R, A] memory
order (XCursor file layout). Record the trap so future contributors
don't reintroduce the Fourcc mismatch that caused cursor R/B swap.
@malbiruk malbiruk merged commit f0fec13 into malbiruk:main Apr 20, 2026
1 of 2 checks passed
@nico4348 nico4348 deleted the fix/cursor-rb-channel-swap branch April 20, 2026 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mouse cursor colors are off

2 participants