< prev index next >

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

Print this page




 163 @end
 164 @implementation AWTWindow_Panel
 165 AWT_NS_WINDOW_IMPLEMENTATION
 166 @end
 167 // END of NSWindow/NSPanel descendants implementation
 168 // --------------------------------------------------------------
 169 
 170 
 171 @implementation AWTWindow
 172 
 173 @synthesize nsWindow;
 174 @synthesize javaPlatformWindow;
 175 @synthesize javaMenuBar;
 176 @synthesize javaMinSize;
 177 @synthesize javaMaxSize;
 178 @synthesize styleBits;
 179 @synthesize isEnabled;
 180 @synthesize ownerWindow;
 181 @synthesize preFullScreenLevel;
 182 @synthesize standardFrame;

 183 
 184 - (void) updateMinMaxSize:(BOOL)resizable {
 185     if (resizable) {
 186         [self.nsWindow setMinSize:self.javaMinSize];
 187         [self.nsWindow setMaxSize:self.javaMaxSize];
 188     } else {
 189         NSRect currentFrame = [self.nsWindow frame];
 190         [self.nsWindow setMinSize:currentFrame.size];
 191         [self.nsWindow setMaxSize:currentFrame.size];
 192     }
 193 }
 194 
 195 // creates a new NSWindow style mask based on the _STYLE_PROP_BITMASK bits
 196 + (NSUInteger) styleMaskForStyleBits:(jint)styleBits {
 197     NSUInteger type = 0;
 198     if (IS(styleBits, DECORATED)) {
 199         type |= NSTitledWindowMask;
 200         if (IS(styleBits, CLOSEABLE))   type |= NSClosableWindowMask;
 201         if (IS(styleBits, MINIMIZABLE)) type |= NSMiniaturizableWindowMask;
 202         if (IS(styleBits, RESIZABLE))   type |= NSResizableWindowMask;


 287         IS(bits, HIDES_ON_DEACTIVATE))
 288     {
 289         self.nsWindow = [[AWTWindow_Panel alloc] initWithDelegate:self
 290                             frameRect:contentRect
 291                             styleMask:styleMask
 292                           contentView:view];
 293     }
 294     else
 295     {
 296         // These windows will appear in the window list in the dock icon menu
 297         self.nsWindow = [[AWTWindow_Normal alloc] initWithDelegate:self
 298                             frameRect:contentRect
 299                             styleMask:styleMask
 300                           contentView:view];
 301     }
 302 
 303     if (self.nsWindow == nil) return nil; // no hope either
 304     [self.nsWindow release]; // the property retains the object already
 305 
 306     self.isEnabled = YES;

 307     self.javaPlatformWindow = platformWindow;
 308     self.styleBits = bits;
 309     self.ownerWindow = owner;
 310     [self setPropertiesForStyleBits:styleBits mask:MASK(_METHOD_PROP_BITMASK)];
 311 
 312     if (IS(self.styleBits, IS_POPUP)) {
 313         [self.nsWindow setCollectionBehavior:(1 << 8) /*NSWindowCollectionBehaviorFullScreenAuxiliary*/]; 
 314     }
 315 
 316     return self;
 317 }
 318 
 319 + (BOOL) isAWTWindow:(NSWindow *)window {
 320     return [window isKindOfClass: [AWTWindow_Panel class]] || [window isKindOfClass: [AWTWindow_Normal class]];
 321 }
 322 
 323 // returns id for the topmost window under mouse
 324 + (NSInteger) getTopmostWindowUnderMouseID {
 325     NSInteger result = -1;
 326     


 406 }
 407 
 408 + (NSNumber *) getNSWindowDisplayID_AppKitThread:(NSWindow *)window {
 409     AWT_ASSERT_APPKIT_THREAD;
 410     NSScreen *screen = [window screen];
 411     NSDictionary *deviceDescription = [screen deviceDescription];
 412     return [deviceDescription objectForKey:@"NSScreenNumber"];
 413 }
 414 
 415 - (void) dealloc {
 416 AWT_ASSERT_APPKIT_THREAD;
 417 
 418     JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
 419     [self.javaPlatformWindow setJObject:nil withEnv:env];
 420 
 421     self.nsWindow = nil;
 422     self.ownerWindow = nil;
 423     [super dealloc];
 424 }
 425 
























































 426 // NSWindow overrides
 427 - (BOOL) canBecomeKeyWindow {
 428 AWT_ASSERT_APPKIT_THREAD;
 429     return self.isEnabled && IS(self.styleBits, SHOULD_BECOME_KEY);
 430 }
 431 
 432 - (BOOL) canBecomeMainWindow {
 433 AWT_ASSERT_APPKIT_THREAD;
 434     if (!self.isEnabled) {
 435         // Native system can bring up the NSWindow to
 436         // the top even if the window is not main.
 437         // We should bring up the modal dialog manually
 438         [AWTToolkit eventCountPlusPlus];
 439 
 440         JNIEnv *env = [ThreadUtilities getJNIEnv];
 441         jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
 442         if (platformWindow != NULL) {
 443             static JNF_MEMBER_CACHE(jm_checkBlockingAndOrder, jc_CPlatformWindow,
 444                                     "checkBlockingAndOrder", "()Z");
 445             JNFCallBooleanMethod(env, platformWindow, jm_checkBlockingAndOrder);


 494 - (void)windowDidResize:(NSNotification *)notification {
 495 AWT_ASSERT_APPKIT_THREAD;
 496 
 497     [self _deliverMoveResizeEvent];
 498 }
 499 
 500 - (void)windowDidExpose:(NSNotification *)notification {
 501 AWT_ASSERT_APPKIT_THREAD;
 502 
 503     [AWTToolkit eventCountPlusPlus];
 504     // TODO: don't see this callback invoked anytime so we track
 505     // window exposing in _setVisible:(BOOL)
 506 }
 507 
 508 - (NSRect)windowWillUseStandardFrame:(NSWindow *)window
 509                         defaultFrame:(NSRect)newFrame {
 510 
 511     return [self standardFrame];
 512 }
 513 
























 514 - (void) _deliverIconify:(BOOL)iconify {
 515 AWT_ASSERT_APPKIT_THREAD;
 516 
 517     [AWTToolkit eventCountPlusPlus];
 518     JNIEnv *env = [ThreadUtilities getJNIEnv];
 519     jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
 520     if (platformWindow != NULL) {
 521         static JNF_MEMBER_CACHE(jm_deliverIconify, jc_CPlatformWindow, "deliverIconify", "(Z)V");
 522         JNFCallVoidMethod(env, platformWindow, jm_deliverIconify, iconify);
 523         (*env)->DeleteLocalRef(env, platformWindow);
 524     }
 525 }
 526 










 527 - (void)windowDidMiniaturize:(NSNotification *)notification {
 528 AWT_ASSERT_APPKIT_THREAD;
 529 
 530     [self _deliverIconify:JNI_TRUE];

 531 }
 532 
 533 - (void)windowDidDeminiaturize:(NSNotification *)notification {
 534 AWT_ASSERT_APPKIT_THREAD;
 535 
 536     [self _deliverIconify:JNI_FALSE];

 537 }
 538 
 539 - (void) _deliverWindowFocusEvent:(BOOL)focused oppositeWindow:(AWTWindow *)opposite {
 540 //AWT_ASSERT_APPKIT_THREAD;
 541     JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
 542     jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
 543     if (platformWindow != NULL) {
 544         jobject oppositeWindow = [opposite.javaPlatformWindow jObjectWithEnv:env];
 545 
 546         static JNF_MEMBER_CACHE(jm_deliverWindowFocusEvent, jc_CPlatformWindow, "deliverWindowFocusEvent", "(ZLsun/lwawt/macosx/CPlatformWindow;)V");
 547         JNFCallVoidMethod(env, platformWindow, jm_deliverWindowFocusEvent, (jboolean)focused, oppositeWindow);
 548         (*env)->DeleteLocalRef(env, platformWindow);
 549         (*env)->DeleteLocalRef(env, oppositeWindow);
 550     }
 551 }
 552 
 553 
 554 - (void) windowDidBecomeKey: (NSNotification *) notification {
 555 AWT_ASSERT_APPKIT_THREAD;
 556     [AWTToolkit eventCountPlusPlus];


 562         awtWindow = awtWindow.ownerWindow;
 563     }
 564 
 565     CMenuBar *menuBar = nil;
 566     BOOL isDisabled = NO;
 567     if ([awtWindow.nsWindow isVisible]){
 568         menuBar = awtWindow.javaMenuBar;
 569         isDisabled = !awtWindow.isEnabled;
 570     }
 571 
 572     if (menuBar == nil) {
 573         menuBar = [[ApplicationDelegate sharedDelegate] defaultMenuBar];
 574         isDisabled = NO;
 575     }
 576 
 577     [CMenuBar activate:menuBar modallyDisabled:isDisabled];
 578 
 579     [AWTWindow setLastKeyWindow:nil];
 580 
 581     [self _deliverWindowFocusEvent:YES oppositeWindow: opposite];

 582 }
 583 
 584 - (void) windowDidResignKey: (NSNotification *) notification {
 585     // TODO: check why sometimes at start is invoked *not* on AppKit main thread.
 586 AWT_ASSERT_APPKIT_THREAD;
 587     [AWTToolkit eventCountPlusPlus];
 588     [self.javaMenuBar deactivate];
 589 
 590     // In theory, this might cause flickering if the window gaining focus
 591     // has its own menu. However, I couldn't reproduce it on practice, so
 592     // perhaps this is a non issue.
 593     CMenuBar* defaultMenu = [[ApplicationDelegate sharedDelegate] defaultMenuBar];
 594     if (defaultMenu != nil) {
 595         [CMenuBar activate:defaultMenu modallyDisabled:NO];
 596     }
 597 
 598     // the new key window
 599     NSWindow *keyWindow = [NSApp keyWindow];
 600     AWTWindow *opposite = nil;
 601     if ([AWTWindow isAWTWindow: keyWindow]) {
 602         opposite = (AWTWindow *)[keyWindow delegate];
 603         [AWTWindow setLastKeyWindow: self];
 604     } else {
 605         [AWTWindow setLastKeyWindow: nil];
 606     }
 607 
 608     [self _deliverWindowFocusEvent:NO oppositeWindow: opposite];

 609 }
 610 
 611 - (void) windowDidBecomeMain: (NSNotification *) notification {
 612 AWT_ASSERT_APPKIT_THREAD;
 613     [AWTToolkit eventCountPlusPlus];
 614 
 615     JNIEnv *env = [ThreadUtilities getJNIEnv];
 616     jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
 617     if (platformWindow != NULL) {
 618         static JNF_MEMBER_CACHE(jm_windowDidBecomeMain, jc_CPlatformWindow, "windowDidBecomeMain", "()V");
 619         JNFCallVoidMethod(env, platformWindow, jm_windowDidBecomeMain);
 620         (*env)->DeleteLocalRef(env, platformWindow);
 621     }
 622 }
 623 
 624 - (BOOL)windowShouldClose:(id)sender {
 625 AWT_ASSERT_APPKIT_THREAD;
 626     [AWTToolkit eventCountPlusPlus];
 627     JNIEnv *env = [ThreadUtilities getJNIEnv];
 628     jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];




 163 @end
 164 @implementation AWTWindow_Panel
 165 AWT_NS_WINDOW_IMPLEMENTATION
 166 @end
 167 // END of NSWindow/NSPanel descendants implementation
 168 // --------------------------------------------------------------
 169 
 170 
 171 @implementation AWTWindow
 172 
 173 @synthesize nsWindow;
 174 @synthesize javaPlatformWindow;
 175 @synthesize javaMenuBar;
 176 @synthesize javaMinSize;
 177 @synthesize javaMaxSize;
 178 @synthesize styleBits;
 179 @synthesize isEnabled;
 180 @synthesize ownerWindow;
 181 @synthesize preFullScreenLevel;
 182 @synthesize standardFrame;
 183 @synthesize isMinimizing;
 184 
 185 - (void) updateMinMaxSize:(BOOL)resizable {
 186     if (resizable) {
 187         [self.nsWindow setMinSize:self.javaMinSize];
 188         [self.nsWindow setMaxSize:self.javaMaxSize];
 189     } else {
 190         NSRect currentFrame = [self.nsWindow frame];
 191         [self.nsWindow setMinSize:currentFrame.size];
 192         [self.nsWindow setMaxSize:currentFrame.size];
 193     }
 194 }
 195 
 196 // creates a new NSWindow style mask based on the _STYLE_PROP_BITMASK bits
 197 + (NSUInteger) styleMaskForStyleBits:(jint)styleBits {
 198     NSUInteger type = 0;
 199     if (IS(styleBits, DECORATED)) {
 200         type |= NSTitledWindowMask;
 201         if (IS(styleBits, CLOSEABLE))   type |= NSClosableWindowMask;
 202         if (IS(styleBits, MINIMIZABLE)) type |= NSMiniaturizableWindowMask;
 203         if (IS(styleBits, RESIZABLE))   type |= NSResizableWindowMask;


 288         IS(bits, HIDES_ON_DEACTIVATE))
 289     {
 290         self.nsWindow = [[AWTWindow_Panel alloc] initWithDelegate:self
 291                             frameRect:contentRect
 292                             styleMask:styleMask
 293                           contentView:view];
 294     }
 295     else
 296     {
 297         // These windows will appear in the window list in the dock icon menu
 298         self.nsWindow = [[AWTWindow_Normal alloc] initWithDelegate:self
 299                             frameRect:contentRect
 300                             styleMask:styleMask
 301                           contentView:view];
 302     }
 303 
 304     if (self.nsWindow == nil) return nil; // no hope either
 305     [self.nsWindow release]; // the property retains the object already
 306 
 307     self.isEnabled = YES;
 308     self.isMinimizing = NO;
 309     self.javaPlatformWindow = platformWindow;
 310     self.styleBits = bits;
 311     self.ownerWindow = owner;
 312     [self setPropertiesForStyleBits:styleBits mask:MASK(_METHOD_PROP_BITMASK)];
 313 
 314     if (IS(self.styleBits, IS_POPUP)) {
 315         [self.nsWindow setCollectionBehavior:(1 << 8) /*NSWindowCollectionBehaviorFullScreenAuxiliary*/]; 
 316     }
 317 
 318     return self;
 319 }
 320 
 321 + (BOOL) isAWTWindow:(NSWindow *)window {
 322     return [window isKindOfClass: [AWTWindow_Panel class]] || [window isKindOfClass: [AWTWindow_Normal class]];
 323 }
 324 
 325 // returns id for the topmost window under mouse
 326 + (NSInteger) getTopmostWindowUnderMouseID {
 327     NSInteger result = -1;
 328     


 408 }
 409 
 410 + (NSNumber *) getNSWindowDisplayID_AppKitThread:(NSWindow *)window {
 411     AWT_ASSERT_APPKIT_THREAD;
 412     NSScreen *screen = [window screen];
 413     NSDictionary *deviceDescription = [screen deviceDescription];
 414     return [deviceDescription objectForKey:@"NSScreenNumber"];
 415 }
 416 
 417 - (void) dealloc {
 418 AWT_ASSERT_APPKIT_THREAD;
 419 
 420     JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
 421     [self.javaPlatformWindow setJObject:nil withEnv:env];
 422 
 423     self.nsWindow = nil;
 424     self.ownerWindow = nil;
 425     [super dealloc];
 426 }
 427 
 428 // Tests wheather the corresponding Java paltform window is visible or not
 429 + (BOOL) isJavaPlatformWindowVisible:(NSWindow *)window {
 430     BOOL isVisible = NO;
 431     
 432     if ([AWTWindow isAWTWindow:window] && [window delegate] != nil) {
 433         AWTWindow *awtWindow = (AWTWindow *)[window delegate];
 434         [AWTToolkit eventCountPlusPlus];
 435         
 436         JNIEnv *env = [ThreadUtilities getJNIEnv];
 437         jobject platformWindow = [awtWindow.javaPlatformWindow jObjectWithEnv:env];
 438         if (platformWindow != NULL) {
 439             static JNF_MEMBER_CACHE(jm_isVisible, jc_CPlatformWindow, "isVisible", "()Z");
 440             isVisible = JNFCallBooleanMethod(env, platformWindow, jm_isVisible) == JNI_TRUE ? YES : NO;
 441             (*env)->DeleteLocalRef(env, platformWindow);
 442             
 443         }
 444     }
 445     return isVisible;
 446 }
 447 
 448 // Orders window's childs based on the current focus state
 449 - (void) orderChilds:(BOOL)focus {
 450 AWT_ASSERT_APPKIT_THREAD;
 451 
 452     if (self.isMinimizing) {
 453         // Do not perform any ordering, if iconify is in progress
 454         return;
 455     }
 456 
 457     NSEnumerator *windowEnumerator = [[NSApp windows]objectEnumerator];
 458     NSWindow *window;
 459     while ((window = [windowEnumerator nextObject]) != nil) {
 460         if ([AWTWindow isJavaPlatformWindowVisible:window]) {
 461             AWTWindow *awtWindow = (AWTWindow *)[window delegate];
 462             if (IS(awtWindow.styleBits, ALWAYS_ON_TOP)) {
 463                 // Do not order 'always on top' windows
 464                 continue;
 465             }
 466             while (awtWindow.ownerWindow != nil) {
 467                 if (awtWindow.ownerWindow == self) {
 468                     if (focus) {
 469                         // Place the child above the owner
 470                         [window setLevel:NSFloatingWindowLevel];
 471                     } else {
 472                         // Place the child to the owner's level and adjust ordering
 473                         [window setLevel:NSNormalWindowLevel];
 474                         [window orderWindow:NSWindowAbove relativeTo:[self.nsWindow windowNumber]];
 475                     }
 476                     break;
 477                 }
 478                 awtWindow = awtWindow.ownerWindow;
 479             }
 480         }
 481     }
 482 }
 483 
 484 // NSWindow overrides
 485 - (BOOL) canBecomeKeyWindow {
 486 AWT_ASSERT_APPKIT_THREAD;
 487     return self.isEnabled && IS(self.styleBits, SHOULD_BECOME_KEY);
 488 }
 489 
 490 - (BOOL) canBecomeMainWindow {
 491 AWT_ASSERT_APPKIT_THREAD;
 492     if (!self.isEnabled) {
 493         // Native system can bring up the NSWindow to
 494         // the top even if the window is not main.
 495         // We should bring up the modal dialog manually
 496         [AWTToolkit eventCountPlusPlus];
 497 
 498         JNIEnv *env = [ThreadUtilities getJNIEnv];
 499         jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
 500         if (platformWindow != NULL) {
 501             static JNF_MEMBER_CACHE(jm_checkBlockingAndOrder, jc_CPlatformWindow,
 502                                     "checkBlockingAndOrder", "()Z");
 503             JNFCallBooleanMethod(env, platformWindow, jm_checkBlockingAndOrder);


 552 - (void)windowDidResize:(NSNotification *)notification {
 553 AWT_ASSERT_APPKIT_THREAD;
 554 
 555     [self _deliverMoveResizeEvent];
 556 }
 557 
 558 - (void)windowDidExpose:(NSNotification *)notification {
 559 AWT_ASSERT_APPKIT_THREAD;
 560 
 561     [AWTToolkit eventCountPlusPlus];
 562     // TODO: don't see this callback invoked anytime so we track
 563     // window exposing in _setVisible:(BOOL)
 564 }
 565 
 566 - (NSRect)windowWillUseStandardFrame:(NSWindow *)window
 567                         defaultFrame:(NSRect)newFrame {
 568 
 569     return [self standardFrame];
 570 }
 571 
 572 // Hides/shows window's childs during iconify/de-iconify operation
 573 - (void) iconifyChilds:(BOOL)iconify {
 574 AWT_ASSERT_APPKIT_THREAD;
 575 
 576     NSEnumerator *windowEnumerator = [[NSApp windows]objectEnumerator];
 577     NSWindow *window;
 578     while ((window = [windowEnumerator nextObject]) != nil) {
 579         if ([AWTWindow isJavaPlatformWindowVisible:window]) {
 580             AWTWindow *awtWindow = (AWTWindow *)[window delegate];
 581             while (awtWindow.ownerWindow != nil) {
 582                 if (awtWindow.ownerWindow == self) {
 583                     if (iconify) {
 584                         [window orderOut:window];
 585                     } else {
 586                         [window orderFront:window];
 587                     }
 588                     break;
 589                 }
 590                 awtWindow = awtWindow.ownerWindow;
 591             }
 592         }
 593     }
 594 }
 595 
 596 - (void) _deliverIconify:(BOOL)iconify {
 597 AWT_ASSERT_APPKIT_THREAD;
 598 
 599     [AWTToolkit eventCountPlusPlus];
 600     JNIEnv *env = [ThreadUtilities getJNIEnv];
 601     jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
 602     if (platformWindow != NULL) {
 603         static JNF_MEMBER_CACHE(jm_deliverIconify, jc_CPlatformWindow, "deliverIconify", "(Z)V");
 604         JNFCallVoidMethod(env, platformWindow, jm_deliverIconify, iconify);
 605         (*env)->DeleteLocalRef(env, platformWindow);
 606     }
 607 }
 608 
 609 - (void)windowWillMiniaturize:(NSNotification *)notification {
 610 AWT_ASSERT_APPKIT_THREAD;
 611 
 612     self.isMinimizing = YES;
 613     // Excplicitly make myself a key window to avoid possible
 614     // negative visual effects during iconify operation
 615     [self.nsWindow makeKeyAndOrderFront:self.nsWindow];
 616     [self iconifyChilds:YES];
 617 }
 618 
 619 - (void)windowDidMiniaturize:(NSNotification *)notification {
 620 AWT_ASSERT_APPKIT_THREAD;
 621 
 622     [self _deliverIconify:JNI_TRUE];
 623     self.isMinimizing = NO;
 624 }
 625 
 626 - (void)windowDidDeminiaturize:(NSNotification *)notification {
 627 AWT_ASSERT_APPKIT_THREAD;
 628 
 629     [self _deliverIconify:JNI_FALSE];
 630     [self iconifyChilds:NO];
 631 }
 632 
 633 - (void) _deliverWindowFocusEvent:(BOOL)focused oppositeWindow:(AWTWindow *)opposite {
 634 //AWT_ASSERT_APPKIT_THREAD;
 635     JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
 636     jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
 637     if (platformWindow != NULL) {
 638         jobject oppositeWindow = [opposite.javaPlatformWindow jObjectWithEnv:env];
 639 
 640         static JNF_MEMBER_CACHE(jm_deliverWindowFocusEvent, jc_CPlatformWindow, "deliverWindowFocusEvent", "(ZLsun/lwawt/macosx/CPlatformWindow;)V");
 641         JNFCallVoidMethod(env, platformWindow, jm_deliverWindowFocusEvent, (jboolean)focused, oppositeWindow);
 642         (*env)->DeleteLocalRef(env, platformWindow);
 643         (*env)->DeleteLocalRef(env, oppositeWindow);
 644     }
 645 }
 646 
 647 
 648 - (void) windowDidBecomeKey: (NSNotification *) notification {
 649 AWT_ASSERT_APPKIT_THREAD;
 650     [AWTToolkit eventCountPlusPlus];


 656         awtWindow = awtWindow.ownerWindow;
 657     }
 658 
 659     CMenuBar *menuBar = nil;
 660     BOOL isDisabled = NO;
 661     if ([awtWindow.nsWindow isVisible]){
 662         menuBar = awtWindow.javaMenuBar;
 663         isDisabled = !awtWindow.isEnabled;
 664     }
 665 
 666     if (menuBar == nil) {
 667         menuBar = [[ApplicationDelegate sharedDelegate] defaultMenuBar];
 668         isDisabled = NO;
 669     }
 670 
 671     [CMenuBar activate:menuBar modallyDisabled:isDisabled];
 672 
 673     [AWTWindow setLastKeyWindow:nil];
 674 
 675     [self _deliverWindowFocusEvent:YES oppositeWindow: opposite];
 676     [self orderChilds:YES];
 677 }
 678 
 679 - (void) windowDidResignKey: (NSNotification *) notification {
 680     // TODO: check why sometimes at start is invoked *not* on AppKit main thread.
 681 AWT_ASSERT_APPKIT_THREAD;
 682     [AWTToolkit eventCountPlusPlus];
 683     [self.javaMenuBar deactivate];
 684 
 685     // In theory, this might cause flickering if the window gaining focus
 686     // has its own menu. However, I couldn't reproduce it on practice, so
 687     // perhaps this is a non issue.
 688     CMenuBar* defaultMenu = [[ApplicationDelegate sharedDelegate] defaultMenuBar];
 689     if (defaultMenu != nil) {
 690         [CMenuBar activate:defaultMenu modallyDisabled:NO];
 691     }
 692 
 693     // the new key window
 694     NSWindow *keyWindow = [NSApp keyWindow];
 695     AWTWindow *opposite = nil;
 696     if ([AWTWindow isAWTWindow: keyWindow]) {
 697         opposite = (AWTWindow *)[keyWindow delegate];
 698         [AWTWindow setLastKeyWindow: self];
 699     } else {
 700         [AWTWindow setLastKeyWindow: nil];
 701     }
 702 
 703     [self _deliverWindowFocusEvent:NO oppositeWindow: opposite];
 704     [self orderChilds:NO];
 705 }
 706 
 707 - (void) windowDidBecomeMain: (NSNotification *) notification {
 708 AWT_ASSERT_APPKIT_THREAD;
 709     [AWTToolkit eventCountPlusPlus];
 710 
 711     JNIEnv *env = [ThreadUtilities getJNIEnv];
 712     jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
 713     if (platformWindow != NULL) {
 714         static JNF_MEMBER_CACHE(jm_windowDidBecomeMain, jc_CPlatformWindow, "windowDidBecomeMain", "()V");
 715         JNFCallVoidMethod(env, platformWindow, jm_windowDidBecomeMain);
 716         (*env)->DeleteLocalRef(env, platformWindow);
 717     }
 718 }
 719 
 720 - (BOOL)windowShouldClose:(id)sender {
 721 AWT_ASSERT_APPKIT_THREAD;
 722     [AWTToolkit eventCountPlusPlus];
 723     JNIEnv *env = [ThreadUtilities getJNIEnv];
 724     jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];


< prev index next >