< prev index next >

src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m

Print this page

        

@@ -185,10 +185,13 @@
 @synthesize ownerWindow;
 @synthesize preFullScreenLevel;
 @synthesize standardFrame;
 @synthesize isMinimizing;
 
+// Key notification received status
+static bool keyNotificationRecd = false;
+
 - (void) updateMinMaxSize:(BOOL)resizable {
     if (resizable) {
         [self.nsWindow setMinSize:self.javaMinSize];
         [self.nsWindow setMaxSize:self.javaMaxSize];
     } else {

@@ -740,13 +743,20 @@
 
 - (void) windowDidBecomeMain: (NSNotification *) notification {
 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];
     }
 
     JNIEnv *env = [ThreadUtilities getJNIEnv];

@@ -762,10 +772,16 @@
 AWT_ASSERT_APPKIT_THREAD;
     [AWTToolkit eventCountPlusPlus];
 #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]) {
         [self activateWindowMenuBar];
     }
< prev index next >