diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2020-02-05 21:59:31 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2020-02-05 21:59:31 +0900 |
commit | c2b1aca9a1db96c52386b478a7e25472410226d4 (patch) | |
tree | 3897655d50f852dd850a9b27734e0000062d1621 /src/content | |
parent | 23c59c9747f83d70df6fc630b1ce99639029dbe7 (diff) |
Clear keys on window blur
Diffstat (limited to 'src/content')
-rw-r--r-- | src/content/Application.ts | 7 | ||||
-rw-r--r-- | src/content/controllers/KeymapController.ts | 4 | ||||
-rw-r--r-- | src/content/usecases/KeymapUseCase.ts | 4 |
3 files changed, 15 insertions, 0 deletions
diff --git a/src/content/Application.ts b/src/content/Application.ts index cfa01fd..fbfeb6d 100644 --- a/src/content/Application.ts +++ b/src/content/Application.ts @@ -40,6 +40,7 @@ export default class Application { run() { this.routeCommonComponents(); + this.routeFocusEvents(); if (window.self === window.top) { this.routeMasterComponents(); } @@ -118,4 +119,10 @@ export default class Application { this.settingController.initSettings(); } + + private routeFocusEvents() { + window.addEventListener('blur', () => { + this.keymapController.onBlurWindow(); + }); + } } diff --git a/src/content/controllers/KeymapController.ts b/src/content/controllers/KeymapController.ts index f9c2545..639b4a1 100644 --- a/src/content/controllers/KeymapController.ts +++ b/src/content/controllers/KeymapController.ts @@ -99,4 +99,8 @@ export default class KeymapController { } return true; } + + onBlurWindow() { + this.keymapUseCase.cancel(); + } } diff --git a/src/content/usecases/KeymapUseCase.ts b/src/content/usecases/KeymapUseCase.ts index 7aa7e92..e02bc48 100644 --- a/src/content/usecases/KeymapUseCase.ts +++ b/src/content/usecases/KeymapUseCase.ts @@ -70,6 +70,10 @@ export default class KeymapUseCase { return null; } + cancel() { + this.repository.clear(); + } + private keymapEntityMap(): [KeySequence, operations.Operation][] { const keymaps = this.settingRepository.get().keymaps.combine(reservedKeymaps); let entries = keymaps.entries().map( |