Skip to content

X11: Use SDL_PremultiplyAlpha when creating XcursorImage - #16537

Merged
slouken merged 2 commits into
libsdl-org:mainfrom
bjorn:fix-x11-cursor-alpha
Oct 17, 2026
Merged

slouken merged 2 commits into
libsdl-org:mainfrom
bjorn:fix-x11-cursor-alpha

Conversation

@bjorn

@bjorn bjorn commented Oct 16, 2026

Copy link
Copy Markdown
Contributor
  • I confirm that I am the author of this code and release it to the SDL project under the zlib license. This contribution does not contain code from other sources, including code generated by a Large Language Model ("AI").

The following mouse cursor image used in the Mana client looks partly broken on X11 and XWayland:

image

Somehow it was only really noticeably wrong for that pick-up hand in the top-right, so for a long time I assumed something was wrong with the image. I've asked Devin (with SWE-2 LLM) to investigate the issue for me, but it found the issue in SDL rather than in the image. Since it noticed this project's AI policy, it has explained the problem and the potential fix to me rather than applying it himself. That's why this time I can check the above box, since I have applied the necessary fix "by hand" and also followed it up with my own small refactor to unduplicate the code.

Description

The X11 backend actually expects pre-multiplied alpha, but a plain memcpy was used to copy the SDL_Surface data over, even though the SDL_Surface was not pre-multiplied.

The same issue has been fixed previously for other backends in b528d48 and 71e9df9.

Existing Issue(s)

I haven't found an existing issue for this.

bjorn added 2 commits October 16, 2026 17:21
Like the wayland and the KMSDRM backends already do since b528d48 and
71e9df9 respectively.

Problem observed as wrong looking partially transparent cursor on both
X11 and XWayland, while it looked correct with SDL_VIDEO_DRIVER=wayland.
@slouken
slouken merged commit 50539f2 into libsdl-org:main Oct 17, 2026
10 checks passed
@slouken slouken added this to the 3.4.20 milestone Oct 17, 2026
slouken pushed a commit that referenced this pull request Oct 17, 2026
Like the wayland and the KMSDRM backends already do since b528d48 and
71e9df9 respectively.

Problem observed as wrong looking partially transparent cursor on both
X11 and XWayland, while it looked correct with SDL_VIDEO_DRIVER=wayland.

(cherry picked from commit 50539f2)
@slouken

slouken commented Oct 17, 2026

Copy link
Copy Markdown
Collaborator

Merged, thanks!

@bjorn
bjorn deleted the fix-x11-cursor-alpha branch October 17, 2026 19:58
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.

2 participants