fixed auto-type from minimized state

This commit is contained in:
antelle 2021-04-27 14:49:13 +02:00
parent 4477c3fc2c
commit e09040b0fb
No known key found for this signature in database
GPG Key ID: 63C9777AAB7C563C
1 changed files with 19 additions and 1 deletions

View File

@ -41,6 +41,7 @@ class AppModel {
memoryPasswordStorage = {};
fileUnlockPromise = null;
hardwareDecryptInProgress = false;
mainWindowBlurTimer = null;
constructor() {
Events.on('refresh', this.refresh.bind(this));
@ -52,6 +53,8 @@ class AppModel {
Events.on('unset-keyfile', this.unsetKeyFile.bind(this));
Events.on('usb-devices-changed', this.usbDevicesChanged.bind(this));
Events.on('main-window-blur', this.mainWindowBlur.bind(this));
Events.on('main-window-focus', this.mainWindowFocus.bind(this));
Events.on('main-window-will-close', this.mainWindowWillClose.bind(this));
Events.on('hardware-decrypt-started', this.hardwareDecryptStarted.bind(this));
Events.on('hardware-decrypt-finished', this.hardwareDecryptFinished.bind(this));
@ -1481,10 +1484,25 @@ class AppModel {
mainWindowBlur() {
if (!this.hardwareDecryptInProgress) {
this.rejectPendingFileUnlockPromise('Main window blur');
this.mainWindowBlurTimer = setTimeout(() => {
// macOS emits focus-blur-focus event in a row when triggering auto-type from minimized state
delete this.mainWindowBlurTimer;
this.rejectPendingFileUnlockPromise('Main window blur');
}, Timeouts.AutoTypeWindowFocusAfterBlur);
}
}
mainWindowFocus() {
if (this.mainWindowBlurTimer) {
clearTimeout(this.mainWindowBlurTimer);
this.mainWindowBlurTimer = null;
}
}
mainWindowWillClose() {
this.rejectPendingFileUnlockPromise('Main window will close');
}
hardwareDecryptStarted() {
this.hardwareDecryptInProgress = true;
}