From 3aa171a66463f32f1d17cead8864b4c66696b082 Mon Sep 17 00:00:00 2001 From: Thomas Rittson <31796059+eliykat@users.noreply.github.com> Date: Mon, 5 Jul 2021 08:06:24 +1000 Subject: [PATCH] [macOS] Don't enable secure input when app is not in focus (#970) * Don't engage macOS secure input if not focused * Refactor to use focusInputOnPageLoad * Fix style and linting * Refactor to remove focusOnPageLoad * Update jslib --- jslib | 2 +- src/app/accounts/lock.component.html | 4 ++-- src/app/accounts/lock.component.ts | 18 ++++++++++++++++++ src/app/accounts/login.component.ts | 18 +++++++++++++++++- src/main/messaging.main.ts | 11 +++++++++++ 5 files changed, 49 insertions(+), 4 deletions(-) diff --git a/jslib b/jslib index f568c872..6f6b5a55 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit f568c872898c86b3cf8b5a99f8b5b377cb5b49e7 +Subproject commit 6f6b5a5503b7aeb7bbd174e3f96a33ce1c9a8037 diff --git a/src/app/accounts/lock.component.html b/src/app/accounts/lock.component.html index 8296ba3a..e4c48cfb 100644 --- a/src/app/accounts/lock.component.html +++ b/src/app/accounts/lock.component.html @@ -8,12 +8,12 @@
+ [(ngModel)]="pin" required>
+ class="monospaced" [(ngModel)]="masterPassword" required>
{ @@ -58,10 +62,22 @@ export class LoginComponent extends BaseLoginComponent implements OnDestroy { case 'windowHidden': this.onWindowHidden(); break; + case 'windowIsFocused': + if (this.deferFocus === null) { + this.deferFocus = !message.windowIsFocused; + if (!this.deferFocus) { + this.focusInput(); + } + } else if (this.deferFocus && message.windowIsFocused) { + this.focusInput(); + this.deferFocus = false; + } + break; default: } }); }); + this.messagingService.send('getWindowIsFocused'); } ngOnDestroy() { diff --git a/src/main/messaging.main.ts b/src/main/messaging.main.ts index 98c3ba9e..cfae0842 100644 --- a/src/main/messaging.main.ts +++ b/src/main/messaging.main.ts @@ -60,6 +60,9 @@ export class MessagingMain { case 'setFocus': this.setFocus(); break; + case 'getWindowIsFocused': + this.windowIsFocused(); + break; case 'enableBrowserIntegration': this.main.nativeMessagingMain.generateManifests(); this.main.nativeMessagingMain.listen(); @@ -139,4 +142,12 @@ Terminal=false`; this.main.trayMain.restoreFromTray(); this.main.windowMain.win.focusOnWebView(); } + + private windowIsFocused() { + const windowIsFocused = this.main.windowMain.win.isFocused(); + this.main.windowMain.win.webContents.send('messagingService', { + command: 'windowIsFocused', + windowIsFocused: windowIsFocused, + }); + } }