< prev index next >
src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuBar.m
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -29,10 +29,11 @@
#import "CMenuBar.h"
#import "CMenu.h"
#import "ThreadUtilities.h"
+#import "ApplicationDelegate.h"
#import "sun_lwawt_macosx_CMenuBar.h"
__attribute__((visibility("default")))
NSString *CMenuBarDidReuseItemNotification =
@@ -99,10 +100,14 @@
if (!menubar) {
[CMenuBar clearMenuBarExcludingAppleMenu_OnAppKitThread:YES];
return;
}
+#ifdef DEBUG
+ NSLog(@"activating menu bar: %@", menubar);
+#endif
+
@synchronized([CMenuBar class]) {
sActiveMenuBar = menubar;
}
@synchronized(menubar) {
@@ -182,17 +187,35 @@
}
-(void) deactivate {
AWT_ASSERT_APPKIT_THREAD;
+ BOOL isDeactivated = NO;
@synchronized([CMenuBar class]) {
+ if (sActiveMenuBar == self) {
sActiveMenuBar = nil;
+ isDeactivated = YES;
+ }
}
+ if (isDeactivated) {
+#ifdef DEBUG
+ NSLog(@"deactivating menu bar: %@", self);
+#endif
+
@synchronized(self) {
fModallyDisabled = NO;
}
+
+ // 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];
+ }
+ }
}
-(void) javaAddMenu: (CMenu *)theMenu {
@synchronized(self) {
[fMenuList addObject: theMenu];
< prev index next >