diff options
author | Pierre Ossman <ossman@cendio.se> | 2018-09-18 15:41:25 +0200 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2018-09-18 15:41:25 +0200 |
commit | 6d0a5a267b5b4c45a97f3e60db7d28785c5ec1ee (patch) | |
tree | d8e0df9bfe2c32d0df5968582c8bc6425dc10d5e /unix | |
parent | 04510322c51c8ddaf8b7c1ea684f918274539c6e (diff) | |
download | tigervnc-6d0a5a267b5b4c45a97f3e60db7d28785c5ec1ee.tar.gz tigervnc-6d0a5a267b5b4c45a97f3e60db7d28785c5ec1ee.zip |
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.
Diffstat (limited to 'unix')
-rw-r--r-- | unix/x0vncserver/XDesktop.cxx | 11 |
1 files 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); } } |