fix: 点击太灵敏 — opaque app nudgeAX sleep 期间检测松手
`.press + 350ms` 进入激活分支时,AX-opaque app 会 nudgeAX(pid) + usleep(250ms)。阻塞期间用户可能已松手, 原代码 sleep 后继续推进到 .recording,导致"点击就出来"。 修法:usleep 后再查 buttonState,已松开 → .dead + cancel, break 出 .press 分支,不再升级成录音。 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
1 parent
b380eaf252
commit
6b88844d1b
1 file changed
+7
@@ -812,6 +812,13 @@ Thread.detachNewThread {
|
||||
var role = focusedTextRole(pid: pid)
|
||||
if role == nil {
|
||||
nudgeAX(pid); usleep(250_000)
|
||||
// 250ms 阻塞期间用户可能已松手;再查 buttonState,
|
||||
// 已松开 → 立刻 .dead,不把"已结束的点击"升级成录音
|
||||
if !CGEventSource.buttonState(.combinedSessionState, button: .left) {
|
||||
state.v = .dead
|
||||
DispatchQueue.global().async { Engine.current.cancel() }
|
||||
break // 跳出 switch 的 .press 分支,回到 polling 顶
|
||||
}
|
||||
role = focusedTextRole(pid: pid)
|
||||
}
|
||||
func startRec() {
|
||||
|
||||
Reference in new issue
Block a user