Repository navigation
Fix Menus on macOS 27 - #159
Merged
Merged
Conversation
This was referenced Oct 24, 2026
jdtsmith
force-pushed
the
fix/menus-27
branch
3 times, most recently
from
October 29, 2026 14:25
50cbd94 to
379fbcb
Compare
* src/macappkit.m (mac_fill_menubar): Re-use existing [NSApp windowsMenu], removing from parent and resetting as the app Windows menu.
macOS 27 moved menu tracking out of process, rendering inoperative our existing trick of noticing menu clicks (or key presses) on GUI during event processing, posting a MENU_BAR_ACTIVATE_EVENT and processing that event synchronously on LISP, building the menus there. We leave that apparatus in place for earlier systems. For v27+, we now request LISP to update the relevant menu just prior to it being displayed. Since menus will be visible while popup_activated() is false, we also take care to display help in the echo area in this case. This also fixes the missing Window menu shortcut keys on open (#140). * src/macappkit.m: ([EmacsController setMenuItemSelectionToTag:]): On macOS27, handle menu item selection here (i.e. in the menu item's action) if no popup is activated (i.e. when menu tracking is happening out of process). ([EmacsController handleQueuedNSEventsWithHoldingQuitIn:]): Reset menu updated flag when new events arrive. ([NSMenu replaceEmacsItemsWithWidgetValue:]): New helper to replace menu items in-place, to keep system-inserted menu items intact. ([NSMenu addItemWithWidgetValue:]): Mark separators as ours as well. ([EmacsMenu menuDidBeginTracking:]): Do not cancel menu tracking on macOS 27, even if popup_activated() is false: we expect this now! ([EmacsController menuNeedsUpdate:]): Update menus via synchronous LISP execution just in time, needed on macOS 27. ([EmacsController menu:willHighlightItem:]): Show help messages in the echo area for our menu items even when popup_activated() is false during out-of-process menu tracking. (mac_menu_show_help_function): New help display function helper. (mac_track_menu_with_block): Use it. (mac_show_menu_bar_help): Show help for menu bar items during macOS 27 out of process tracking. (mac_update_menubar_in_place_1, mac_update_menubar_in_place_handler, mac_update_menubar_in_place, mac_handle_menu_bar_selection): New helpers to update menu bars on LISP just in time. (mac_fill_menubar): Update menus items in place if requested. Also assign emacsController as delegate for all submenus and release the (unused) newMenu if updating in place. We leave the Window menu alone to ensure its shortcut keys remain bound. (mac_wake_up_select): New helper to write wake byte. * src/macappkit.h: Declare [NSMenu replaceEmacsItemsWithWidgetValue:].
jdtsmith
force-pushed
the
fix/menus-27
branch
from
November 1, 2026 14:29
379fbcb to
547f14d
Compare
Owner
Author
|
I'm going to merge this stack now despite some questions about whether it DTRT on v27.2, since at least 27.0 folks will be able to use it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a draft fix for #148. It builds on top of #157. Read the commit messages for more details, but the short summary is: mouse menu tracking now happens out of process on macOS27. So we need to update menu contents on LISP "just in time" prior to their being displayed, which we do in
menuNeedsUpdate:. This is a distinct path from the earlier menu handling, which is left in place for earlier systems and keyboard-based menu interaction. Co-authored with Claude Opus 5.5.This also incorporates and supersedes #149.
Please test, especially on macOS26/15/earlier.