--- old/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m 2018-11-11 18:06:16.000000000 +0530 +++ new/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m 2018-11-11 18:06:15.000000000 +0530 @@ -187,6 +187,9 @@ @synthesize standardFrame; @synthesize isMinimizing; +// Key notification received status +static bool keyNotificationRecd = false; + - (void) updateMinMaxSize:(BOOL)resizable { if (resizable) { [self.nsWindow setMinSize:self.javaMinSize]; @@ -742,9 +745,16 @@ AWT_ASSERT_APPKIT_THREAD; [AWTToolkit eventCountPlusPlus]; #ifdef DEBUG - NSLog(@"became main: %d %@ %@", [self.nsWindow isKeyWindow], [self.nsWindow title], [self menuBarForWindow]); + NSLog(@"became main: %d %@ %@ %d", [self.nsWindow isKeyWindow], [self.nsWindow title], [self menuBarForWindow], keyNotificationRecd); #endif + // if for some reason, no KEY notification is received but this main window is also a key window + // then we need to execute the KEY notification functionality. + if(keyNotificationRecd != true && [self.nsWindow isKeyWindow]) { + [self doWindowDidBecomeKey]; + } + keyNotificationRecd = false; + if (![self.nsWindow isKeyWindow]) { [self activateWindowMenuBar]; } @@ -764,6 +774,12 @@ #ifdef DEBUG NSLog(@"became key: %d %@ %@", [self.nsWindow isMainWindow], [self.nsWindow title], [self menuBarForWindow]); #endif + [self doWindowDidBecomeKey]; + keyNotificationRecd = true; +} + +- (void) doWindowDidBecomeKey { +AWT_ASSERT_APPKIT_THREAD; AWTWindow *opposite = [AWTWindow lastKeyWindow]; if (![self.nsWindow isMainWindow]) {