On Wed, 16 Sep 2026 17:22:04 GMT, Phil Race <[email protected]> wrote:

> Why would it do this by design ? And then you say you want to preserve that 
> design, but then this whole fix is about undoing that.

AWT on macos says 
https://github.com/openjdk/jdk/blob/431b10ae927d306c062cdc262094e65f7b381159/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java#L1223-L1231
and
simple Window is defined as any top-level that is neither a Frame nor a Dialog
https://github.com/openjdk/jdk/blob/431b10ae927d306c062cdc262094e65f7b381159/src/java.desktop/macosx/classes/sun/lwawt/LWWindowPeer.java#L1304-L1306
so updateFocusableWindowState() then clears the native SHOULD_BECOME_KEY and 
SHOULD_BECOME_MAIN 
https://github.com/openjdk/jdk/blob/431b10ae927d306c062cdc262094e65f7b381159/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java#L924-L926
so a simple Window cannot become a NSApp.keyWindow

If Window is opened from Frame/Dialog, then for a simple Window, AWT requests 
native activation 
https://github.com/openjdk/jdk/blob/431b10ae927d306c062cdc262094e65f7b381159/src/java.desktop/macosx/classes/sun/lwawt/LWWindowPeer.java#L1220-L1224
on its owning Frame/Dialog, then calls `changeFocusedWindow(true, opposite)` to 
synthesize the Java-level focus change.

The bug happens in reverse direction, when a Frame/Dialog closed
 - AppKit reactivated the owning native Dialog/Frame, because the simple Window 
cannot become key.
 - Before the fix, notifyActivation(true, ...) directly called 
changeFocusedWindow(true, ...) on that native owner.
 - AWT therefore gave Java focus to the Dialog/Frame losing the prior simple 
Window focus history

So the simple Window could receive synthetic Java focus before the patch, but 
AWT had no mechanism to restore that focus after an intervening native 
Frame/Dialog was hidden or disposed

-------------

PR Comment: https://git.openjdk.org/jdk/pull/32831#issuecomment-5709082649

Reply via email to