mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
fix: duplicate fullscreen macOS menu item (#49597)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
@@ -56,11 +56,6 @@ static NSDictionary* UNNotificationResponseToNSDictionary(
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)applicationWillFinishLaunching:(NSNotification*)notify {
|
- (void)applicationWillFinishLaunching:(NSNotification*)notify {
|
||||||
// Don't add the "Enter Full Screen" menu item automatically.
|
|
||||||
[[NSUserDefaults standardUserDefaults]
|
|
||||||
setBool:NO
|
|
||||||
forKey:@"NSFullScreenMenuItemEverywhere"];
|
|
||||||
|
|
||||||
[[[NSWorkspace sharedWorkspace] notificationCenter]
|
[[[NSWorkspace sharedWorkspace] notificationCenter]
|
||||||
addObserver:self
|
addObserver:self
|
||||||
selector:@selector(willPowerOff:)
|
selector:@selector(willPowerOff:)
|
||||||
|
|||||||
@@ -560,6 +560,14 @@ NSArray* ConvertSharingItemToNS(const SharingItem& item) {
|
|||||||
|
|
||||||
- (void)menuWillOpen:(NSMenu*)menu {
|
- (void)menuWillOpen:(NSMenu*)menu {
|
||||||
isMenuOpen_ = YES;
|
isMenuOpen_ = YES;
|
||||||
|
|
||||||
|
// macOS automatically injects a duplicate "Toggle Full Screen" menu item
|
||||||
|
// when we set menu.delegate on submenus. Remove hidden duplicates.
|
||||||
|
for (NSMenuItem* item in menu.itemArray) {
|
||||||
|
if (item.isHidden && item.action == @selector(toggleFullScreenMode:))
|
||||||
|
[menu removeItem:item];
|
||||||
|
}
|
||||||
|
|
||||||
[self refreshMenuTree:menu];
|
[self refreshMenuTree:menu];
|
||||||
if (model_)
|
if (model_)
|
||||||
model_->MenuWillShow();
|
model_->MenuWillShow();
|
||||||
|
|||||||
Reference in New Issue
Block a user