< 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             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                         // Place the child above the owner
 471                         [window setLevel:NSFloatingWindowLevel];
 472                     } else {
 473                         // Place the child to the owner's level
 474                         [window setLevel:NSNormalWindowLevel];
 475                     }
 476                     // Adjust ordering
 477                     [window orderWindow:NSWindowAbove relativeTo:[owner.nsWindow windowNumber]];
 478                     break;
 479                 }
 480                 awtWindow = awtWindow.ownerWindow;
 481             }
 482         }
 483     }
 484 }
 485 
 486 // NSWindow overrides
 487 - (BOOL) canBecomeKeyWindow {
 488 AWT_ASSERT_APPKIT_THREAD;
 489     return self.isEnabled && IS(self.styleBits, SHOULD_BECOME_KEY);
 490 }
 491 
 492 - (BOOL) canBecomeMainWindow {
 493 AWT_ASSERT_APPKIT_THREAD;
 494     if (!self.isEnabled) {
 495         // Native system can bring up the NSWindow to
 496         // the top even if the window is not main.
 497         // We should bring up the modal dialog manually
 498         [AWTToolkit eventCountPlusPlus];
 499 
 500         JNIEnv *env = [ThreadUtilities getJNIEnv];
 501         jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
 502         if (platformWindow != NULL) {
 503             static JNF_MEMBER_CACHE(jm_checkBlockingAndOrder, jc_CPlatformWindow,
 504                                     "checkBlockingAndOrder", "()Z");
 505             JNFCallBooleanMethod(env, platformWindow, jm_checkBlockingAndOrder);


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


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


< prev index next >