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

@@ -24,6 +24,9 @@ class VideoWindow {
int* height)>;
// 用户主动关闭窗口(点关闭按钮 / 按 ESC)时回调。
using CloseHandler = std::function<void()>;
// 画面内鼠标操作回调,坐标已换算成画面像素(0..frame_width-1)。
// action:0=按下 1=抬起 2=移动 3=取消,语义与协议 TouchEvent.action 一致。
using InputHandler = std::function<void(int action, int x, int y)>;
VideoWindow();
~VideoWindow();
@@ -42,6 +45,9 @@ class VideoWindow {
// 设置/清除用户关闭回调;传 nullptr 清除。
void SetCloseHandler(CloseHandler handler);
// 设置/清除画面鼠标回调;传 nullptr 清除。
void SetInputHandler(InputHandler handler);
bool IsOpen() const { return open_.load(); }
private:
@@ -53,17 +59,30 @@ class VideoWindow {
void ApplyAspectToWindow(double aspect);
// 把窗口矩形修正为符合当前宽高比(WM_SIZING 用)。
void AdjustSizingRect(RECT* rect, WPARAM edge) const;
// 客户区坐标 -> 画面像素;返回 false 表示点在黑边上或还没有画面。
bool ClientToFrame(POINT point, int* x, int* y) const;
void DispatchPointerAt(int action, POINT point);
HWND hwnd_ = nullptr;
std::atomic<bool> open_{false};
std::atomic<bool> repaint_pending_{false};
FrameProvider provider_;
CloseHandler close_handler_;
InputHandler input_handler_;
// 当前视频宽高比(宽/高),0 表示还没有画面。只在窗口线程读写。
double aspect_ratio_ = 0.0;
// 已经应用过的宽高比,避免每帧都触发 SetWindowPos。
double applied_aspect_ = 0.0;
// 最近一帧的画面尺寸与它在客户区里的实际绘制矩形(含黑边)。只在窗口线程读写。
int frame_width_ = 0;
int frame_height_ = 0;
RECT image_rect_ = {};
// 左键按下期间才下发移动事件,悬停不注入。
bool dragging_ = false;
POINT last_point_ = {};
ULONGLONG last_move_tick_ = 0;
};
#endif // RUNNER_VIDEO_WINDOW_H_