fix(keybinding): release held shortcuts and modifiers when the screen locks or the PC sleeps
The lock desktop swallows keyup, so a hold-to-talk recording never ended, the first shortcut after unlocking was dropped as auto-repeat, and Win from Win+L made the next suggestion accept wait out the full 1.5s modifier timeout. On powerMonitor lock-screen/suspend the chord machine now emits released for emitted triggers and clears its state, and modifier tracking forgets held keys.
This commit is contained in:
parent
8d003c8fca
commit
3e6cfd1ba8
6 changed files with 94 additions and 2 deletions
|
|
@ -195,6 +195,17 @@ describe('ChordStateMachine — press / release', () => {
|
|||
expect(events.map(label)).toEqual(['history-popup:pressed', 'history-popup:released'])
|
||||
})
|
||||
|
||||
it('releaseAll sends released for held triggers and accepts the next press after a lost keyup', () => {
|
||||
machine.setBindings([entry('history-popup', kb(0x56, { ctrl: true, shift: true }))])
|
||||
const key = keyOf(0x56, { ctrl: true, shift: true })
|
||||
|
||||
machine.keyDown(key)
|
||||
machine.releaseAll()
|
||||
machine.keyDown(key)
|
||||
|
||||
expect(events.map(label)).toEqual(['history-popup:pressed', 'history-popup:released', 'history-popup:pressed'])
|
||||
})
|
||||
|
||||
it('ignores keys that match no binding and releases nothing that was not pressed', () => {
|
||||
machine.setBindings([entry('history-popup', kb(0x56, { ctrl: true, shift: true }))])
|
||||
machine.keyDown(keyOf(0x41))
|
||||
|
|
|
|||
|
|
@ -276,6 +276,22 @@ export class ChordStateMachine {
|
|||
this._active.clear()
|
||||
}
|
||||
|
||||
/**
|
||||
* 떼는 이벤트가 오지 않을 순간(화면 잠금·절전)에 부른다. 이미 보낸 pressed 에는 released 를 보내
|
||||
* hold 녹음이 끝나게 하고, 보류 중인 트리거는 버린다. 그 뒤 reset 처럼 모두 비운다.
|
||||
* 안 비우면 잠금을 푼 뒤 첫 누름이 auto-repeat 로 버려진다.
|
||||
*/
|
||||
releaseAll(): void {
|
||||
for (const trigger of this._pending) {
|
||||
trigger.cancelTimer?.()
|
||||
trigger.cancelTimer = null
|
||||
trigger.status = 'cancelled'
|
||||
}
|
||||
this._pending.clear()
|
||||
for (const key of [...this._isDown]) this._release(key)
|
||||
this.reset()
|
||||
}
|
||||
|
||||
// ── 입력 ───────────────────────────────────────────────
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue