src/macosx/native/sun/awt/AWTWindow.m

Print this page




 522 //AWT_ASSERT_APPKIT_THREAD;
 523     JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
 524     jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
 525     if (platformWindow != NULL) {
 526         jobject oppositeWindow = [opposite.javaPlatformWindow jObjectWithEnv:env];
 527 
 528         static JNF_MEMBER_CACHE(jm_deliverWindowFocusEvent, jc_CPlatformWindow, "deliverWindowFocusEvent", "(ZLsun/lwawt/macosx/CPlatformWindow;)V");
 529         JNFCallVoidMethod(env, platformWindow, jm_deliverWindowFocusEvent, (jboolean)focused, oppositeWindow);
 530         (*env)->DeleteLocalRef(env, platformWindow);
 531         (*env)->DeleteLocalRef(env, oppositeWindow);
 532     }
 533 }
 534 
 535 
 536 - (void) windowDidBecomeKey: (NSNotification *) notification {
 537 AWT_ASSERT_APPKIT_THREAD;
 538     [AWTToolkit eventCountPlusPlus];
 539     AWTWindow *opposite = [AWTWindow lastKeyWindow];
 540     if (!IS(self.styleBits, IS_DIALOG)) {
 541         [CMenuBar activate:self.javaMenuBar modallyDisabled:NO];
 542     } else if (IS(self.styleBits, IS_MODAL)) {
 543         [CMenuBar activate:opposite->javaMenuBar modallyDisabled:YES];        
 544     }
 545     [AWTWindow setLastKeyWindow:nil];
 546 
 547     [self _deliverWindowFocusEvent:YES oppositeWindow: opposite];
 548 }
 549 
 550 - (void) windowDidResignKey: (NSNotification *) notification {
 551     // TODO: check why sometimes at start is invoked *not* on AppKit main thread.
 552 AWT_ASSERT_APPKIT_THREAD;
 553     [AWTToolkit eventCountPlusPlus];
 554     [self.javaMenuBar deactivate];
 555 
 556     // the new key window
 557     NSWindow *keyWindow = [NSApp keyWindow];
 558     AWTWindow *opposite = nil;
 559     if ([AWTWindow isAWTWindow: keyWindow]) {
 560         opposite = (AWTWindow *)[keyWindow delegate];
 561         [AWTWindow setLastKeyWindow: self];
 562     } else {




 522 //AWT_ASSERT_APPKIT_THREAD;
 523     JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
 524     jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
 525     if (platformWindow != NULL) {
 526         jobject oppositeWindow = [opposite.javaPlatformWindow jObjectWithEnv:env];
 527 
 528         static JNF_MEMBER_CACHE(jm_deliverWindowFocusEvent, jc_CPlatformWindow, "deliverWindowFocusEvent", "(ZLsun/lwawt/macosx/CPlatformWindow;)V");
 529         JNFCallVoidMethod(env, platformWindow, jm_deliverWindowFocusEvent, (jboolean)focused, oppositeWindow);
 530         (*env)->DeleteLocalRef(env, platformWindow);
 531         (*env)->DeleteLocalRef(env, oppositeWindow);
 532     }
 533 }
 534 
 535 
 536 - (void) windowDidBecomeKey: (NSNotification *) notification {
 537 AWT_ASSERT_APPKIT_THREAD;
 538     [AWTToolkit eventCountPlusPlus];
 539     AWTWindow *opposite = [AWTWindow lastKeyWindow];
 540     if (!IS(self.styleBits, IS_DIALOG)) {
 541         [CMenuBar activate:self.javaMenuBar modallyDisabled:NO];
 542     } else if ((opposite != NULL) && IS(self.styleBits, IS_MODAL)) {
 543         [CMenuBar activate:opposite->javaMenuBar modallyDisabled:YES];        
 544     }
 545     [AWTWindow setLastKeyWindow:nil];
 546 
 547     [self _deliverWindowFocusEvent:YES oppositeWindow: opposite];
 548 }
 549 
 550 - (void) windowDidResignKey: (NSNotification *) notification {
 551     // TODO: check why sometimes at start is invoked *not* on AppKit main thread.
 552 AWT_ASSERT_APPKIT_THREAD;
 553     [AWTToolkit eventCountPlusPlus];
 554     [self.javaMenuBar deactivate];
 555 
 556     // the new key window
 557     NSWindow *keyWindow = [NSApp keyWindow];
 558     AWTWindow *opposite = nil;
 559     if ([AWTWindow isAWTWindow: keyWindow]) {
 560         opposite = (AWTWindow *)[keyWindow delegate];
 561         [AWTWindow setLastKeyWindow: self];
 562     } else {