openless
openless copied to clipboard
[bug][windows] 多屏胶囊可能跑出屏/压任务栏:#470 的四边 clamp 被 1ea467a 回退成死码
现象
多显示器 / 负坐标 / 异常 DPI 布局下,Windows 录音胶囊可能被定位到屏幕外或压在任务栏上。
根因(已读源码 + git 溯源确认)
#470 曾用 commit fab9651(+ 4824080 防溢出收口)加入「四边 clamp + 工作区(rcWork,避开任务栏)定位」:clamp_to_monitor 四边夹住整窗,ForegroundMonitor 带 work_* 字段。
但 Android 移植 commit 1ea467a 将其回退:
ForegroundMonitor丢失work_left/top/right/bottom字段(不再读rcWork);position_capsule_bottom_center退回只夹上边:let clamped_y = y.max(mon.top)+set_position(x, clamped_y)(x 完全不夹、下/右不夹、不避任务栏);clamp_to_monitor沦为死代码(仅 test import 引用,本体仍在lib.rs:1823),其专用单测被删。
影响
clamp_to_monitor 本要防的「胶囊跑出屏 / 压任务栏」失效——正是 #470 诊断想排查的 C 子嫌疑(胶囊定位到屏幕外)。
修法(恢复 fab9651,单一职责)
ForegroundMonitor重新加回work_*字段,foreground_window_monitor从mi.rcWork填充;position_capsule_bottom_center改回用clamp_to_monitor四边夹工作区(取不到 rcWork 退回整屏);- 恢复
clamp_to_monitor的 3 个纯函数单测。
验证
cargo test --lib clamp_to_monitor(纯函数,三平台跑)3 passed:on-screen 不动 / 右下溢出收回 / 右缘内溢收回。Windows 结构 + rcWork 由 CI 编译验证;需 Windows 真机确认多屏下胶囊不再出屏/压任务栏。
来源:2026-06-16 全仓多 Agent 审计(#470 专项)。关联 #470。