--- old/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m 2018-11-22 13:51:48.000000000 +0530 +++ new/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m 2018-11-22 13:51:47.000000000 +0530 @@ -186,6 +186,7 @@ @synthesize preFullScreenLevel; @synthesize standardFrame; @synthesize isMinimizing; +@synthesize keyNotificationRecd; - (void) updateMinMaxSize:(BOOL)resizable { if (resizable) { @@ -319,6 +320,7 @@ if (self.nsWindow == nil) return nil; // no hope either [self.nsWindow release]; // the property retains the object already + self.keyNotificationRecd = NO; self.isEnabled = YES; self.isMinimizing = NO; self.javaPlatformWindow = platformWindow; @@ -747,9 +749,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], self.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(self.keyNotificationRecd != true && [self.nsWindow isKeyWindow]) { + [self doWindowDidBecomeKey]; + } + self.keyNotificationRecd = false; + if (![self.nsWindow isKeyWindow]) { [self activateWindowMenuBar]; } @@ -769,6 +778,12 @@ #ifdef DEBUG NSLog(@"became key: %d %@ %@", [self.nsWindow isMainWindow], [self.nsWindow title], [self menuBarForWindow]); #endif + [self doWindowDidBecomeKey]; + self.keyNotificationRecd = true; +} + +- (void) doWindowDidBecomeKey { +AWT_ASSERT_APPKIT_THREAD; AWTWindow *opposite = [AWTWindow lastKeyWindow]; if (![self.nsWindow isMainWindow]) {