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
This commit is contained in:
alcroito authored and Jonathan White committed 2026-11-28 22:02:05 -05:00
1 parent cd42236540
commit 68fb7e3360
1 file changed
+2 -1
+2 -1
View File
@@ -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;
}
}