From 68fb7e3360610dc2960768ec0692a2ed2bcd4aab Mon Sep 17 00:00:00 2001 From: alcroito Date: Fri, 27 Nov 2026 19:44:48 +0100 Subject: [PATCH] macOS: Return focus to the requesting app after Touch ID unlock After a browser request unlocked the database with Touch ID, focus stayed on KeePassXC instead of returning to the app that made the request. The last active application is tracked from NSWorkspaceDidDeactivateApplicationNotification. The Touch ID prompt is shown by the coreautha agent, so when it closed it replaced the requesting app, and raiseLastActiveWindow() then activated coreautha, which has no window. Only track regular applications, which skips background agents like coreautha and UserNotificationCenter. Fixes: #14168 --- src/gui/osutils/macutils/AppKitImpl.mm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/osutils/macutils/AppKitImpl.mm b/src/gui/osutils/macutils/AppKitImpl.mm index 43b3f3723..c8eb0a488 100644 --- a/src/gui/osutils/macutils/AppKitImpl.mm +++ b/src/gui/osutils/macutils/AppKitImpl.mm @@ -56,7 +56,8 @@ NSDictionary* userInfo = notification.userInfo; NSRunningApplication* app = [userInfo objectForKey:NSWorkspaceApplicationKey]; - if (app.processIdentifier != [self ownProcessId]) { + // Skip background agents such as the Touch ID prompt (coreautha), which have no window to return to + if (app.processIdentifier != [self ownProcessId] && app.activationPolicy == NSApplicationActivationPolicyRegular) { self.lastActiveApplication = app; } }