macOS: Persist "Secure Keyboard Entry" across restarts to match the behavior of Terminal.app

Fixes #4471
This commit is contained in:
Kovid Goyal
2022-01-08 14:13:14 +05:30
parent ac0c10c170
commit 356897a32d
2 changed files with 9 additions and 1 deletions

View File

@@ -1586,6 +1586,8 @@ void _glfwPlatformUpdateIMEState(_GLFWwindow *w, const GLFWIMEUpdateEvent *ev) {
if (self != nil) {
glfw_window = initWindow;
self.tabbingMode = NSWindowTabbingModeDisallowed;
SecureKeyboardEntryController *k = [SecureKeyboardEntryController sharedInstance];
if (!k.isDesired && [[NSUserDefaults standardUserDefaults] boolForKey:@"SecureKeyboardEntry"]) [k toggle];
}
return self;
}
@@ -1612,7 +1614,9 @@ void _glfwPlatformUpdateIMEState(_GLFWwindow *w, const GLFWIMEUpdateEvent *ev) {
- (void)toggleSecureInput:(id)sender {
(void)sender;
[[SecureKeyboardEntryController sharedInstance] toggle];
SecureKeyboardEntryController *k = [SecureKeyboardEntryController sharedInstance];
[k toggle];
[[NSUserDefaults standardUserDefaults] setBool:k.isDesired forKey:@"SecureKeyboardEntry"];
}
- (BOOL)canBecomeKeyWindow