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

Print this page

        

*** 28,37 **** --- 28,38 ---- #import <JavaRuntimeSupport/JavaRuntimeSupport.h> #import "sun_lwawt_macosx_CPlatformWindow.h" #import "com_apple_eawt_event_GestureHandler.h" #import "com_apple_eawt_FullScreenHandler.h" + #import "ApplicationDelegate.h" #import "AWTWindow.h" #import "AWTView.h" #import "CMenu.h" #import "CMenuBar.h"
*** 546,560 **** // Finds appropriate menubar in our hierarchy, AWTWindow *awtWindow = self; while (awtWindow.ownerWindow != nil) { awtWindow = awtWindow.ownerWindow; } CMenuBar *menuBar = nil; if ([awtWindow.nsWindow isVisible]){ menuBar = awtWindow.javaMenuBar; } ! [CMenuBar activate:menuBar modallyDisabled:!awtWindow.isEnabled]; [AWTWindow setLastKeyWindow:nil]; [self _deliverWindowFocusEvent:YES oppositeWindow: opposite]; } --- 547,570 ---- // Finds appropriate menubar in our hierarchy, AWTWindow *awtWindow = self; while (awtWindow.ownerWindow != nil) { awtWindow = awtWindow.ownerWindow; } + CMenuBar *menuBar = nil; + BOOL isDisabled = NO; if ([awtWindow.nsWindow isVisible]){ menuBar = awtWindow.javaMenuBar; + isDisabled = !awtWindow.isEnabled; + } + + if (menuBar == nil) { + menuBar = [[ApplicationDelegate sharedDelegate] defaultMenuBar]; + isDisabled = NO; } ! ! [CMenuBar activate:menuBar modallyDisabled:isDisabled]; [AWTWindow setLastKeyWindow:nil]; [self _deliverWindowFocusEvent:YES oppositeWindow: opposite]; }
*** 563,572 **** --- 573,590 ---- // TODO: check why sometimes at start is invoked *not* on AppKit main thread. AWT_ASSERT_APPKIT_THREAD; [AWTToolkit eventCountPlusPlus]; [self.javaMenuBar deactivate]; + // In theory, this might cause flickering if the window gaining focus + // has its own menu. However, I couldn't reproduce it on practice, so + // perhaps this is a non issue. + CMenuBar* defaultMenu = [[ApplicationDelegate sharedDelegate] defaultMenuBar]; + if (defaultMenu != nil) { + [CMenuBar activate:defaultMenu modallyDisabled:NO]; + } + // the new key window NSWindow *keyWindow = [NSApp keyWindow]; AWTWindow *opposite = nil; if ([AWTWindow isAWTWindow: keyWindow]) { opposite = (AWTWindow *)[keyWindow delegate];
*** 827,841 **** CMenuBar *menuBar = OBJC(menuBarPtr); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ AWTWindow *window = (AWTWindow*)[nsWindow delegate]; ! if ([nsWindow isKeyWindow]) [window.javaMenuBar deactivate]; window.javaMenuBar = menuBar; if ([nsWindow isKeyWindow]) { ! [CMenuBar activate:window.javaMenuBar modallyDisabled:NO]; } }]; JNF_COCOA_EXIT(env); } --- 845,867 ---- CMenuBar *menuBar = OBJC(menuBarPtr); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ AWTWindow *window = (AWTWindow*)[nsWindow delegate]; ! if ([nsWindow isKeyWindow]) { ! [window.javaMenuBar deactivate]; ! } ! window.javaMenuBar = menuBar; + CMenuBar* actualMenuBar = menuBar; + if (actualMenuBar == nil) { + actualMenuBar = [[ApplicationDelegate sharedDelegate] defaultMenuBar]; + } + if ([nsWindow isKeyWindow]) { ! [CMenuBar activate:actualMenuBar modallyDisabled:NO]; } }]; JNF_COCOA_EXIT(env); }