Fix cursor color swap from wrong XCursor pixel format#49
Merged
malbiruk merged 2 commits intomalbiruk:mainfrom Apr 20, 2026
Merged
Fix cursor color swap from wrong XCursor pixel format#49malbiruk merged 2 commits intomalbiruk:mainfrom
malbiruk merged 2 commits intomalbiruk:mainfrom
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
In
load_xcursor, tag theMemoryRenderBufferwithFourcc::Argb8888instead ofAbgr8888. Also add a CAVEATS note on thexcursor::pixels_rgbamisnomer so the trap doesn't come back.Purpose
The
xcursorcrate'spixels_rgbafield is misleadingly named — bytes are actually in[B, G, R, A]memory order (XCursor file layout: uint32 ARGB little-endian). Pairing that withFourcc::Abgr8888makes smithay upload the texture as GL(RGBA, UNSIGNED_BYTE), swapping R and B on screen. niri pairspixels_rgbawithFourcc::Argb8888insrc/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