From 6d0a5a267b5b4c45a97f3e60db7d28785c5ec1ee Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Tue, 18 Sep 2018 15:41:25 +0200 Subject: [PATCH] Fix bad color of cursor with x0vncserver We cannot assume endian-ness for the cursor we get from XFixes. Adjust the algorithm to properly follow the specification. --- unix/x0vncserver/XDesktop.cxx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/unix/x0vncserver/XDesktop.cxx b/unix/x0vncserver/XDesktop.cxx index c7961f2a..5f67f299 100644 --- a/unix/x0vncserver/XDesktop.cxx +++ b/unix/x0vncserver/XDesktop.cxx @@ -708,16 +708,15 @@ bool XDesktop::setCursor() for (int x = 0; x < cim->width; x++) { rdr::U8 alpha; rdr::U32 pixel = *pixels++; - rdr::U8 *in = (rdr::U8 *) &pixel; - alpha = in[3]; + alpha = (pixel >> 24) & 0xff; if (alpha == 0) alpha = 1; // Avoid division by zero - *out++ = (unsigned)*in++ * 255/alpha; - *out++ = (unsigned)*in++ * 255/alpha; - *out++ = (unsigned)*in++ * 255/alpha; - *out++ = *in++; + *out++ = ((pixel >> 16) & 0xff) * 255/alpha; + *out++ = ((pixel >> 8) & 0xff) * 255/alpha; + *out++ = ((pixel >> 0) & 0xff) * 255/alpha; + *out++ = ((pixel >> 24) & 0xff); } } -- 2.39.5