From 356897a32d3991d14962ad8a0f3a6a5218152f8e Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 8 Jan 2022 14:13:14 +0530 Subject: [PATCH] macOS: Persist "Secure Keyboard Entry" across restarts to match the behavior of Terminal.app Fixes #4471 --- docs/changelog.rst | 4 ++++ glfw/cocoa_window.m | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 02383f151..2773b581f 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -79,6 +79,10 @@ Detailed list of changes - macOS: Allow opening text files, images and directories with kitty when launched using "Open with" in Finder (:iss:`4460`) +- macOS: Persist "Secure Keyboard Entry" across restarts to match the behavior + of Terminal.app (:iss:`4471`) + + 0.24.1 [2022-01-06] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/glfw/cocoa_window.m b/glfw/cocoa_window.m index f9a27e60c..44ef1692e 100644 --- a/glfw/cocoa_window.m +++ b/glfw/cocoa_window.m @@ -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