Reland "Use property isKeyWindow for key window condition check"

Commit: 20ea6a57 | 2025-11-21 17:15:24+00:00

← Back to List

Reland "Use property isKeyWindow for key window condition check"

Moderate
Commit Hash: 20ea6a5784da7b5d9d21a3a7083ea1932643635c
Commit Time: 2025-11-21 17:15:24+00:00
Impact Level: Moderate
Generated By: webview2-upstream-sentry
Upstream Review: View Upstream Review 🔗

📋 Summary

This commit relands a previously reverted fix that changes the key window status check in the windowDidResignKey method from [NSApp keyWindow] == [self window] to [self window].isKeyWindow. This fix addresses a focus state synchronization issue in multi-window applications: when a user clicks a notification, at the moment the window receives the windowDidResignKey notification, [NSApp keyWindow] may still temporarily point to that window, causing an incorrect early return and leaving WebContents and Blink layers thinking they still have focus, making JavaScript document.hasFocus() incorrectly return true. Using the window.isKeyWindow property correctly detects when the window has actually resigned key status, as this property is updated before windowDidResignKey is called. This fix was previously reverted for breaking