Skip to content

Fix/rdp native cursor ownership - #420

Open
paofu-cium wants to merge 2 commits into
feigeCode:devfrom
paofu-cium:fix/rdp-native-cursor-ownership
Open

paofu-cium wants to merge 2 commits into
feigeCode:devfrom
paofu-cium:fix/rdp-native-cursor-ownership

Conversation

@paofu-cium

Copy link
Copy Markdown
Contributor

native cursor ownership

Windows 原生 RDP(mstscax)会话里,会话指针由 ActiveX 控件自己绘制并自己
设置光标,navop 既不绘制远端光标也不接管该路径的鼠标输入。但
RemoteCursorState 仍按 protocol == Rdp 认为自己在管理 OS 光标,而
pointer_hovered 在该路径永远为 false(on_hover / on_mouse_move 只对 canvas
路径注册),于是 should_hide_native_cursor() 恒假,sync_native_cursor() 走
restore 分支。

promote_latest() 每帧无条件调用 sync_native_cursor(),因此原生会话下 navop
每帧都执行 SetCursor(IDC_ARROW),与 ActiveX 设置的光标互相覆盖:远端窗口
边框上控件刚把光标换成双向调整箭头,下一帧就被 navop 改回普通箭头,表现为
"鼠标箭头和双向箭头来回变化",光标热点随之漂移,远端窗口边框几乎无法瞄准,
很难真正拖动调整大小。

修改:给 RemoteCursorState 增加 native_cursor_owned,由 render 每帧按
!uses_windows_native_presentation() 同步;未持有所有权时,
sync_native_cursor / rehide_native_cursor_after_pointer_move /
release_all_images 全部不再触碰 OS 光标。交还所有权时只撤销 navop 自己
施加过的隐藏,避免向原生会话多打一次 SetCursor。

同时给 native_cursor 增加 #[cfg(test)] 调用计数,让"谁持有 OS 光标"变成可
断言的行为而不是仅靠注释。

验证:
- cargo test -p remote_desktop_view --lib:264 passed / 0 failed,含新增
  native_presentation_does_not_touch_the_os_cursor 与
  handing_the_os_cursor_back_only_undoes_a_hide_navap_applied 两条回归用例
- 本机为 Windows 10 家庭版(fDenyTSConnections=1,无入站 RDP 服务),无法
  搭建真实 RDP 会话做端到端复现,真机验证仍待有远端主机的环境确认

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant