diff --git a/core/display.js b/core/display.js index 8143b831..1d780c80 100644 --- a/core/display.js +++ b/core/display.js @@ -657,44 +657,44 @@ export default class Display { this.onflush(); } } + + static changeCursor(target, pixels, mask, hotx, hoty, w, h) { + if ((w === 0) || (h === 0)) { + target.style.cursor = 'none'; + return; + } + + const cur = []; + for (let y = 0; y < h; y++) { + for (let x = 0; x < w; x++) { + let idx = y * Math.ceil(w / 8) + Math.floor(x / 8); + const alpha = (mask[idx] << (x % 8)) & 0x80 ? 255 : 0; + idx = ((w * y) + x) * 4; + cur.push(pixels[idx + 2]); // red + cur.push(pixels[idx + 1]); // green + cur.push(pixels[idx]); // blue + cur.push(alpha); // alpha + } + } + + const canvas = document.createElement('canvas'); + const ctx = canvas.getContext('2d'); + + canvas.width = w; + canvas.height = h; + + let img; + if (SUPPORTS_IMAGEDATA_CONSTRUCTOR) { + img = new ImageData(new Uint8ClampedArray(cur), w, h); + } else { + img = ctx.createImageData(w, h); + img.data.set(new Uint8ClampedArray(cur)); + } + ctx.clearRect(0, 0, w, h); + ctx.putImageData(img, 0, 0); + + const url = canvas.toDataURL(); + target.style.cursor = 'url(' + url + ')' + hotx + ' ' + hoty + ', default'; + } } -// Class Methods -Display.changeCursor = (target, pixels, mask, hotx, hoty, w, h) => { - if ((w === 0) || (h === 0)) { - target.style.cursor = 'none'; - return; - } - - const cur = []; - for (let y = 0; y < h; y++) { - for (let x = 0; x < w; x++) { - let idx = y * Math.ceil(w / 8) + Math.floor(x / 8); - const alpha = (mask[idx] << (x % 8)) & 0x80 ? 255 : 0; - idx = ((w * y) + x) * 4; - cur.push(pixels[idx + 2]); // red - cur.push(pixels[idx + 1]); // green - cur.push(pixels[idx]); // blue - cur.push(alpha); // alpha - } - } - - const canvas = document.createElement('canvas'); - const ctx = canvas.getContext('2d'); - - canvas.width = w; - canvas.height = h; - - let img; - if (SUPPORTS_IMAGEDATA_CONSTRUCTOR) { - img = new ImageData(new Uint8ClampedArray(cur), w, h); - } else { - img = ctx.createImageData(w, h); - img.data.set(new Uint8ClampedArray(cur)); - } - ctx.clearRect(0, 0, w, h); - ctx.putImageData(img, 0, 0); - - const url = canvas.toDataURL(); - target.style.cursor = 'url(' + url + ')' + hotx + ' ' + hoty + ', default'; -}; diff --git a/core/rfb.js b/core/rfb.js index 21b5da17..ab24f8db 100644 --- a/core/rfb.js +++ b/core/rfb.js @@ -1592,6 +1592,14 @@ export default class RFB extends EventTargetMixin { Log.Info("Sending XVP operation " + op + " (version " + ver + ")"); RFB.messages.xvpOp(this._sock, ver, op); } + + static genDES(password, challenge) { + const passwd = []; + for (let i = 0; i < password.length; i++) { + passwd.push(password.charCodeAt(i)); + } + return (new DES(passwd)).encrypt(challenge); + }; } // Class Methods @@ -1892,14 +1900,6 @@ RFB.messages = { } }; -RFB.genDES = (password, challenge) => { - const passwd = []; - for (let i = 0; i < password.length; i++) { - passwd.push(password.charCodeAt(i)); - } - return (new DES(passwd)).encrypt(challenge); -}; - RFB.encodingHandlers = { RAW() { if (this._FBU.lines === 0) {