summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2018-09-18 11:06:13 +0200
committerPierre Ossman <ossman@cendio.se>2018-09-18 11:08:02 +0200
commit679535ec29deec544b24f8b214a18f517e29c625 (patch)
tree8333821efdfb2901af813a3de8311555f9a41e8a
parent9881899e7b0c333a1e1ec6d082b91c05b623407d (diff)
downloadnovnc-679535ec29deec544b24f8b214a18f517e29c625.tar.gz
Fix cursor encoding handling from earlier merge
Old code snuck in when merging the split of decoders to separate classes. Restore the proper handling of cursors.
-rw-r--r--core/rfb.js28
1 files changed, 22 insertions, 6 deletions
diff --git a/core/rfb.js b/core/rfb.js
index 832acd8..d1fcd2b 100644
--- a/core/rfb.js
+++ b/core/rfb.js
@@ -1525,22 +1525,38 @@ export default class RFB extends EventTargetMixin {
}
_handleCursor() {
- const x = this._FBU.x; // hotspot-x
- const y = this._FBU.y; // hotspot-y
+ const hotx = this._FBU.x; // hotspot-x
+ const hoty = this._FBU.y; // hotspot-y
const w = this._FBU.width;
const h = this._FBU.height;
const pixelslength = w * h * 4;
- const masklength = Math.floor((w + 7) / 8) * h;
+ const masklength = Math.ceil(w / 8) * h;
let bytes = pixelslength + masklength;
if (this._sock.rQwait("cursor encoding", bytes)) {
return false;
}
- this._cursor.change(this._sock.rQshiftBytes(pixelslength),
- this._sock.rQshiftBytes(masklength),
- x, y, w, h);
+ // Decode from BGRX pixels + bit mask to RGBA
+ const pixels = this._sock.rQshiftBytes(pixelslength);
+ const mask = this._sock.rQshiftBytes(masklength);
+ let rgba = new Uint8Array(w * h * 4);
+
+ let pix_idx = 0;
+ for (let y = 0; y < h; y++) {
+ for (let x = 0; x < w; x++) {
+ let mask_idx = y * Math.ceil(w / 8) + Math.floor(x / 8);
+ let alpha = (mask[mask_idx] << (x % 8)) & 0x80 ? 255 : 0;
+ rgba[pix_idx ] = pixels[pix_idx + 2];
+ rgba[pix_idx + 1] = pixels[pix_idx + 1];
+ rgba[pix_idx + 2] = pixels[pix_idx];
+ rgba[pix_idx + 3] = alpha;
+ pix_idx += 4;
+ }
+ }
+
+ this._updateCursor(rgba, hotx, hoty, w, h);
return true;
}