Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix duplicate menu items in Window menu #1092

Merged
merged 1 commit into from Sep 20, 2020

Conversation

ychin
Copy link
Member

@ychin ychin commented Sep 18, 2020

Previously MacVim would see a lot of duplicate window menu items like "Enter Full Screen" or "Tile Window to Left of Screen" when the user toggles between two windows. This is because the setWindowsMenu: call was injecting these items, but AppKit isn't smart enough to de-duplicate them (unlike the window list at the bottom). Just fix this by making a copy of the main menu before passing it in. This way every time we try to set a main menu (which happens whenever we jump among Vim windows as each Vim can have different menu items), it will be set with a fresh copy of main menu that doesn't have the injected menu items in it.

  • This also requires adding a refresh functionality because adding/removing items to the original menu no longer get automatically reflected to the app since it only knows about the copied version.

Also, set NSFullScreenMenuItemEverywhere to prevent AppKit from injecting "Enter Full Screen" items. MacVim already has similar menu items to handle that.

Also, remove old private API call to setAppleMenu:. As far as I could tell this is not useful anymore in recent macOS versions and that line of code was written in 2008.

Fix #566, Fix #992

Previously MacVim would see a lot of duplicate window menu items like
"Enter Full Screen" or "Tile Window to Left of Screen" when the user
toggles between two windows. This is because the `setWindowsMenu:` call
was injecting these items, but AppKit isn't smart enough to de-duplicate
them (unlike the window list at the bottom). Just fix this by making a
copy of the main menu before passing it in. This way every time we try
to set a main menu (which happens whenever we jump among Vim windows as
each Vim can have different menu items), it will be set with a fresh one
that doesn't have the injected menu items in it.

- This also requires adding a refresh functionality because
  adding/removing items to the original menu no longer get automatically
  reflected to the app since it only knows about the copied version.

Also, set NSFullScreenMenuItemEverywhere to prevent AppKit from
injecting "Enter Full Screen" items. MacVim already has similar menu
items to handle that.

Also, remove old private API call to `setAppleMenu:`. As far as I could
tell this is not useful anymore in recent macOS versions and that line
of code was written in 2008.

Fix macvim-dev#566, Fix macvim-dev#992
@ychin ychin force-pushed the fix-duplicate-window-menu-items branch from 2828a57 to d412800 Compare September 20, 2020 11:05
@ychin ychin merged commit 944005e into macvim-dev:master Sep 20, 2020
@ychin ychin deleted the fix-duplicate-window-menu-items branch September 20, 2020 12:35
@ychin ychin added this to the snapshot-166 milestone Sep 22, 2020
@ychin ychin added the UI Issues related to UI elements, tabs, scrollbars, window resizing, etc. label Mar 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
UI Issues related to UI elements, tabs, scrollbars, window resizing, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Window Menu Bug on macOS 10.15.2 Enter Full Screen menu line repeated
1 participant