修复 Windows 桌面画面缺少鼠标指针 (#46)
Windows Desktop 没有收到远端指针形状时指针不可见。为 Windows Desktop 传递规范化的 平台信息并启用本地箭头回退,浏览器画面同样使用回退。远端提供指针形状时仍优先显示。 Desktop 的回退选项独立于 cageBrowserDisplay,不顺带启用浏览器输入协议。 Fixes #42
Windows Desktop 没有收到远端指针形状时指针不可见。为 Windows Desktop 传递规范化的 平台信息并启用本地箭头回退,浏览器画面同样使用回退。远端提供指针形状时仍优先显示。 Desktop 的回退选项独立于 cageBrowserDisplay,不顺带启用浏览器输入协议。 Fixes #42
| @@ -0,0 +1,27 @@ | ||
| 1 | 新增:import { test } from 'node:test'; | |
| 2 | 新增:import assert from 'node:assert/strict'; | |
| 3 | 新增:import { readFile } from 'node:fs/promises'; | |
| 4 | 新增:import vm from 'node:vm'; | |
| 5 | 新增: | |
| 6 | 新增:test('empty cursor uses opt-in fallback and real cursor shapes still win', async () => { | |
| 7 | 新增: const source = (await readFile(new URL('../vendor/novnc/core/util/cursor.js', import.meta.url), 'utf8')) | |
| 8 | 新增: .replace(/^import .*;$/m, 'const supportsCursorURIs = true, isTouchDevice = false;') | |
| 9 | 新增: .replace('export default class Cursor', 'globalThis.Cursor = class Cursor'); | |
| 10 | 新增: const context = vm.createContext({ | |
| 11 | 新增: document: { createElement: () => ({ style: {}, width: 0, height: 0, | |
| 12 | 新增: getContext: () => ({ clearRect() {}, putImageData() {} }), | |
| 13 | 新增: toDataURL: () => 'data:image/png;base64,test' }) }, | |
| 14 | 新增: ImageData: class {}, Uint8ClampedArray, | |
| 15 | 新增: }); | |
| 16 | 新增: vm.runInContext(source, context); | |
| 17 | 新增: for (const fallback of ['default', 'none']) { | |
| 18 | 新增: const target = { style: {} }; | |
| 19 | 新增: const cursor = new context.Cursor(fallback); | |
| 20 | 新增: cursor.attach(target); | |
| 21 | 新增: assert.equal(target.style.cursor, fallback); | |
| 22 | 新增: cursor.change(new Uint8Array([0, 0, 0, 255]), 0, 0, 1, 1); | |
| 23 | 新增: assert.match(target.style.cursor, /^url\(/); | |
| 24 | 新增: cursor.change(new Uint8Array(), 0, 0, 0, 0); | |
| 25 | 新增: assert.equal(target.style.cursor, fallback); | |
| 26 | 新增: } | |
| 27 | 新增:}); | |
| @@ -222,6 +222,7 @@ export function ClaudeDesktop({ | ||
| 222 | 222 | zoom={zoom} |
| 223 | 223 | visible={visible} |
| 224 | 224 | keyboard={status.keyboard} |
| 225 | 新增: guestPlatform={status.guest_system?.startsWith("windows") ? "windows" : status.guest_system} | |
| 225 | 226 | onStatus={onStatus} |
| 226 | 227 | onFallback={onFallback} |
| 227 | 228 | /> |
| @@ -88,7 +88,7 @@ export const RemoteView = forwardRef(function RemoteView( | ||
| 88 | 88 | client = new RFB( |
| 89 | 89 | container, |
| 90 | 90 | runtimeSocketURL(`${desktopPrefix}/vnc`), |
| 91 | 删除: { credentials: { password }, cageBrowserDisplay: !desktop }, | |
| 91 | 新增: { credentials: { password }, cageBrowserDisplay: !desktop, cageCursorFallback: desktop && guestPlatform === "windows" }, | |
| 92 | 92 | ); |
| 93 | 93 | rfb.current = client; |
| 94 | 94 | client.scaleViewport = true; |
| @@ -233,7 +233,7 @@ export default class RFB extends EventTargetMixin { | ||
| 233 | 233 | this._screen.appendChild(this._canvas); |
| 234 | 234 | |
| 235 | 235 | // Cursor |
| 236 | 删除: this._cursor = new Cursor(); | |
| 236 | 新增: this._cursor = new Cursor(options.cageBrowserDisplay || options.cageCursorFallback ? 'default' : 'none'); | |
| 237 | 237 | |
| 238 | 238 | // XXX: TightVNC 2.8.11 sends no cursor at all until Windows changes |
| 239 | 239 | // it. Result: no cursor at all until a window border or an edit field |
| @@ -9,8 +9,9 @@ import { supportsCursorURIs, isTouchDevice } from './browser.js'; | ||
| 9 | 9 | const useFallback = !supportsCursorURIs || isTouchDevice; |
| 10 | 10 | |
| 11 | 11 | export default class Cursor { |
| 12 | 删除: constructor() { | |
| 12 | 新增: constructor(fallback = 'none') { | |
| 13 | 13 | this._target = null; |
| 14 | 新增: this._fallback = fallback === 'default' ? 'default' : 'none'; | |
| 14 | 15 | |
| 15 | 16 | this._canvas = document.createElement('canvas'); |
| 16 | 17 | |
| @@ -106,7 +107,7 @@ export default class Cursor { | ||
| 106 | 107 | } |
| 107 | 108 | |
| 108 | 109 | clear() { |
| 109 | 删除: this._target.style.cursor = 'none'; | |
| 110 | 新增: this._target.style.cursor = this._fallback; | |
| 110 | 111 | this._canvas.width = 0; |
| 111 | 112 | this._canvas.height = 0; |
| 112 | 113 | this._position.x = this._position.x + this._hotSpot.x; |