Skip to content

feat(input): lock cursor during fullscreen streaming - #87

Merged
qiin2333 merged 1 commit into
masterfrom
codex/lock-window-cursor
Jul 27, 2026
Merged

feat(input): lock cursor during fullscreen streaming#87
qiin2333 merged 1 commit into
masterfrom
codex/lock-window-cursor

Conversation

@qiin2333

@qiin2333 qiin2333 commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

改了啥呀

  • 接入 API 22+ 的 OH_WindowManager_LockCursor / OH_WindowManager_UnlockCursor,把会跑出全屏串流窗口的系统光标按住啦
  • 普通桌面模式保留光标跟随并限制窗口边界;游戏鼠标模式固定本地光标,直接转发 ArkUI rawDelta
  • 串流菜单、窗口失焦、退后台和串流结束时释放光标,恢复焦点或关闭菜单后重新锁定
  • 通过运行时符号解析兼容 compatibleSdkVersion 12,并声明 LOCK_WINDOW_CURSOR 权限;旧系统和不支持设备继续使用原鼠标路径

为啥要改

全屏串流连接实体鼠标时,系统光标仍可能碰到窗口外或边缘区域,沉浸模式和应用层回弹管不到这一层。现在由窗口管理器负责边界,输入处理器只负责把位移送去远端,职责终于不打架了,杂鱼边缘状态退散。

Refs #80

本 PR 只处理 Issue 中第一项鼠标锁定需求;三指触控手势不在本次范围,因此不会自动关闭整个 Issue。

验证

  • npm run check
  • node hvigorw.js assembleApp --mode project -p product=default -p buildMode=debug --no-daemon
  • API 24 模拟器绝对模式:followMovement=true,日志确认 mode=confined
  • API 24 模拟器游戏鼠标模式:followMovement=false,日志确认 mode=locked 并进入 ArkUI rawDelta 路径
  • Back 打开菜单会解锁,Back 关闭菜单会按原模式重新锁定
  • Home 退后台由系统自动释放,回到前台重新锁定成功

模拟器缺少 INPUT_MONITORING 权限时会正确回退 ArkUI + DisplaySync。模拟器的视频解码仍为黑屏,且 UITest 注入的是触摸事件,实体鼠标 rawDelta 的手感仍建议在真机补充确认。

Summary by CodeRabbit

  • 新功能

    • 支持全屏串流时锁定系统光标,提升鼠标相对移动体验。
    • 增加窗口焦点感知,窗口失焦或游戏菜单打开时自动暂停鼠标拦截,恢复后自动继续。
    • 游戏菜单关闭时统一恢复鼠标输入状态。
  • 改进

    • 优化相对鼠标移动数据处理,提升移动响应的准确性。
    • 增加光标锁定能力检测及自动释放机制,避免窗口切换或退出后残留锁定状态。
    • 补充光标锁定所需的系统权限配置。

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 5cf0254b-960f-4095-b7df-f56b17fb4df8

📥 Commits

Reviewing files that changed from the base of the PR and between bcde18b and efb1111.

📒 Files selected for processing (6)
  • entry/src/main/ets/pages/StreamPage.ets
  • entry/src/main/ets/service/input/InputInterceptorService.ets
  • entry/src/main/ets/service/streaming/StreamInputHandler.ets
  • entry/src/main/ets/service/streaming/StreamWindowManager.ets
  • entry/src/main/module.json5
  • nativelib/src/main/cpp/mouse_interceptor.cpp

📝 Walkthrough

Walkthrough

Changes

光标锁定与输入生命周期

Layer / File(s) Summary
原生光标锁定接口与权限
nativelib/src/main/cpp/mouse_interceptor.cpp, entry/src/main/module.json5
动态加载并导出光标锁定、解锁和能力查询接口,同时声明窗口光标锁定权限。
ArkTS 光标锁定状态管理
entry/src/main/ets/service/input/InputInterceptorService.ets
跟踪锁定窗口,在切换和停止拦截时执行光标释放。
串流输入与窗口事件接入
entry/src/main/ets/service/streaming/StreamInputHandler.ets, entry/src/main/ets/service/streaming/StreamWindowManager.ets
传递窗口参数,按全屏和相对模式选择光标锁定或 rawDelta 输入,并监听窗口焦点事件。
页面焦点与游戏菜单生命周期
entry/src/main/ets/pages/StreamPage.ets
窗口失焦或游戏菜单显示时暂停鼠标拦截,焦点恢复或菜单关闭时按状态恢复。

Estimated code review effort: 4 (Complex) | ~45 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了本次变更的核心:在全屏串流时启用鼠标光标锁定。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/lock-window-cursor

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@qiin2333
qiin2333 merged commit d1925e3 into master Jul 27, 2026
2 checks passed
@qiin2333
qiin2333 deleted the codex/lock-window-cursor branch July 27, 2026 07:43
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