浏览文件
remote-cursor.mjs
23 行 · 663 B历史下载| 1 | // noVNC hides the local cursor until the server supplies a visible shape. |
| 2 | // Headless macOS guests may never do so, so keep a native arrow as a fallback. |
| 3 | export function installLocalCursorFallback(cursor, enabled) { |
| 4 | if (!enabled) return; |
| 5 | |
| 6 | const change = cursor.change.bind(cursor); |
| 7 | const clear = cursor.clear.bind(cursor); |
| 8 | const fallback = () => { |
| 9 | clear(); |
| 10 | cursor._target.style.cursor = "default"; |
| 11 | }; |
| 12 | |
| 13 | cursor.clear = fallback; |
| 14 | cursor.change = (rgba, hotx, hoty, w, h) => { |
| 15 | for (let i = 3; i < rgba.length; i += 4) { |
| 16 | if (rgba[i] !== 0) { |
| 17 | change(rgba, hotx, hoty, w, h); |
| 18 | return; |
| 19 | } |
| 20 | } |
| 21 | fallback(); |
| 22 | }; |
| 23 | } |

