feat(sender): 串流窗口支持点击与拖拽控制

- video_window 增加 InputHandler 回调,WM_LBUTTONDOWN/MOUSEMOVE/LBUTTONUP/CAPTURECHANGED
  映射为 0/2/1/3,移动事件按 60Hz 限流
- Paint 记录帧尺寸与实际绘制矩形,ClientToFrame 换算到画面像素并过滤黑边
- video_texture 通过方法通道转发 pointer 事件到 Dart,析构时清空回调
- bridge.dart 新增 onVideoPointer,main.dart 以 msg_type=0 触摸帧下发(压力 1000/0)
This commit is contained in:
tongtong committed 2026-11-27 15:06:46 +08:00
1 parent 03a5853da7
commit a102d10089
5 files changed
+166 -2

No files matched your search

+18
View File
@@ -86,6 +86,8 @@ class _HomePageState extends State<HomePage> {
_bridge = SenderBridge(nativeCore: _nativeCore);
// 独立窗口被用户关闭 → 停止投屏。
_bridge.onVideoWindowClosed = _onStreamWindowClosed;
// 串流窗口里的鼠标点击/拖拽 → 触摸控制帧。
_bridge.onVideoPointer = _onVideoPointer;
_diagnosticLog.start();
_diagnosticLog.write('app initialized; nativeError=${_nativeError ?? '-'}');
_bridge.watchPhase().listen((phase) {
@@ -265,6 +267,22 @@ class _HomePageState extends State<HomePage> {
}
}
/// 串流窗口里的鼠标事件 → 触摸控制帧。
///
/// 坐标是画面像素(与编码分辨率一致),被控端会按「画面尺寸 → 真实屏幕尺寸」
/// 换算后再注入,因此主控端不需要知道手机的真实分辨率。
void _onVideoPointer(int action, int x, int y) {
if (!_phase.isConnected) return;
_sendControl('touch', {
'action': action,
'pointerId': 1,
'x': x,
'y': y,
// 按下/拖动保持满压力,抬起与取消归零。
'pressure': (action == 0 || action == 2) ? 1000 : 0,
});
}
void _snack(String message) {
if (!mounted) return;
ScaffoldMessenger.of(context)