x11: Premultiply alpha of custom cursor pixel

As with Wayland, X11 expects cursor pixels to have the alpha
premultiplied, so lets convert the non-premultiplied pixels to
premultiplied pixels.

Fixes issue 353.
This commit is contained in:
Jonas Ådahl 2016-02-17 13:53:57 +08:00
parent db3eb121df
commit 0556601a29

View File

@ -705,10 +705,12 @@ Cursor _glfwCreateCursorX11(const GLFWimage* image, int xhot, int yhot)
for (i = 0; i < image->width * image->height; i++, target++, source += 4) for (i = 0; i < image->width * image->height; i++, target++, source += 4)
{ {
*target = (source[3] << 24) | unsigned char alpha = source[3];
(source[0] << 16) |
(source[1] << 8) | *target = (alpha << 24) |
source[2]; (_glfwMultiplyAlpha(alpha, source[0]) << 16) |
(_glfwMultiplyAlpha(alpha, source[1]) << 8) |
_glfwMultiplyAlpha(alpha, source[2]);
} }
cursor = XcursorImageLoadCursor(_glfw.x11.display, native); cursor = XcursorImageLoadCursor(_glfw.x11.display, native);