< 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) orderChildWindows:(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             AWTWindow *owner = awtWindow.ownerWindow;
 463             if (IS(awtWindow.styleBits, ALWAYS_ON_TOP)) {
 464                 // Do not order 'always on top' windows
 465                 continue;
 466             }
 467             while (awtWindow.ownerWindow != nil) {
 468                 if (awtWindow.ownerWindow == self) {
 469                     if (focus) {
 470                         // Move the childWindow to floating level
 471                         // so it will appear in front of its
 472                         // parent which owns the focus
 473                         [window setLevel:NSFloatingWindowLevel];
 474                     } else {
 475                         // Focus owner has changed, move the childWindow
 476                         // back to normal window level
 477                         [window setLevel:NSNormalWindowLevel];
 478                     }
 479                     // The childWindow should be displayed in front of
 480                     // its nearest parentWindow
 481                     [window orderWindow:NSWindowAbove relativeTo:[owner.nsWindow windowNumber]];
 482                     break;
 483                 }
 484                 awtWindow = awtWindow.ownerWindow;
 485             }
 486         }
 487     }
 488 }
 489 
 490 // NSWindow overrides
 491 - (BOOL) canBecomeKeyWindow {
 492 AWT_ASSERT_APPKIT_THREAD;
 493     return self.isEnabled && IS(self.styleBits, SHOULD_BECOME_KEY);
 494 }
 495 
 496 - (BOOL) canBecomeMainWindow {
 497 AWT_ASSERT_APPKIT_THREAD;
 498     if (!self.isEnabled) {
 499         // Native system can bring up the NSWindow to
 500         // the top even if the window is not main.
 501         // We should bring up the modal dialog manually
 502         [AWTToolkit eventCountPlusPlus];
 503 
 504         JNIEnv *env = [ThreadUtilities getJNIEnv];
 505         jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
 506         if (platformWindow != NULL) {
 507             static JNF_MEMBER_CACHE(jm_checkBlockingAndOrder, jc_CPlatformWindow,
 508                                     "checkBlockingAndOrder", "()Z");
 509             JNFCallBooleanMethod(env, platformWindow, jm_checkBlockingAndOrder);


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


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


< prev index next >