()
| 2977 | } |
| 2978 | |
| 2979 | _handleCursor() { |
| 2980 | const hotx = this._FBU.x; // hotspot-x |
| 2981 | const hoty = this._FBU.y; // hotspot-y |
| 2982 | const w = this._FBU.width; |
| 2983 | const h = this._FBU.height; |
| 2984 | |
| 2985 | const pixelslength = w * h * 4; |
| 2986 | const masklength = Math.ceil(w / 8) * h; |
| 2987 | |
| 2988 | let bytes = pixelslength + masklength; |
| 2989 | if (this._sock.rQwait("cursor encoding", bytes)) { |
| 2990 | return false; |
| 2991 | } |
| 2992 | |
| 2993 | // Decode from BGRX pixels + bit mask to RGBA |
| 2994 | const pixels = this._sock.rQshiftBytes(pixelslength); |
| 2995 | const mask = this._sock.rQshiftBytes(masklength); |
| 2996 | let rgba = new Uint8Array(w * h * 4); |
| 2997 | |
| 2998 | let pixIdx = 0; |
| 2999 | for (let y = 0; y < h; y++) { |
| 3000 | for (let x = 0; x < w; x++) { |
| 3001 | let maskIdx = y * Math.ceil(w / 8) + Math.floor(x / 8); |
| 3002 | let alpha = (mask[maskIdx] << (x % 8)) & 0x80 ? 255 : 0; |
| 3003 | rgba[pixIdx ] = pixels[pixIdx + 2]; |
| 3004 | rgba[pixIdx + 1] = pixels[pixIdx + 1]; |
| 3005 | rgba[pixIdx + 2] = pixels[pixIdx]; |
| 3006 | rgba[pixIdx + 3] = alpha; |
| 3007 | pixIdx += 4; |
| 3008 | } |
| 3009 | } |
| 3010 | |
| 3011 | this._updateCursor(rgba, hotx, hoty, w, h); |
| 3012 | |
| 3013 | return true; |
| 3014 | } |
| 3015 | |
| 3016 | _handleDesktopName() { |
| 3017 | if (this._sock.rQwait("DesktopName", 4)) { |
no test coverage detected