Skip to content

feat(macos): support applicationDockMenu: (right-click Dock menu) - #1295

Open
thomnico wants to merge 1 commit into
tauri-apps:devfrom
thomnico:macos-dock-menu
Open

feat(macos): support applicationDockMenu: (right-click Dock menu)#1295
thomnico wants to merge 1 commit into
tauri-apps:devfrom
thomnico:macos-dock-menu

Conversation

@thomnico

@thomnico thomnico commented Aug 2, 2026

Copy link
Copy Markdown

Summary

Adds support for applicationDockMenu: — the menu Cocoa shows when the user right-clicks (or Control-clicks / long-presses) the application's Dock icon. Currently unsupported: macOS falls back to its default minimal menu (Show/Hide, Quit) with no way for the app to customize it.

New public API on EventLoopWindowTargetExtMacOS:

fn set_dock_menu(&self, menu: Option<objc2::rc::Retained<objc2_app_kit::NSMenu>>);

Same shape as the existing set_badge_label/set_dock_visibility methods. Can be called at any point after the event loop starts, including from a menu item's own click handler (e.g. to rebuild the menu with an updated checkmark) — the next right-click picks up the change.

Why a small module instead of an Event variant

applicationDockMenu: must return its value synchronously to Cocoa — there's no round-trip available through tao's event queue the way there is for e.g. Event::Reopen. So the menu is stored in a small module-level Mutex (platform_impl/macos/dock_menu.rs), read directly by the new application_dock_menu handler in app_delegate.rs. Same main-thread-only invariant as the rest of that file's id usage (documented inline).

Testing

Used this in a real app (menu bar app built on tao 0.36, EventLoopBuilder::<UserEvent>::with_user_event()) — right-click on the Dock icon now shows a custom CheckMenuItem built with muda, synced with the same toggle exposed elsewhere in the app (tray menu, application menu bar). Confirmed working on macOS (tested by the end user, not just compiled).

Notes

  • Added "NSMenu" to the objc2-app-kit feature list in Cargo.toml (was missing, needed for NSMenu/Retained<NSMenu>).
  • cargo fmt --check and cargo check --target aarch64-apple-darwin pass.
  • Happy to add a dock_menu example under examples/ if useful for review — didn't want to guess at what you'd want there without asking first.

Adds EventLoopWindowTargetExtMacOS::set_dock_menu(), letting apps
register a menu shown on right-click / Control-click / long-press of
the Dock icon. Previously unsupported — macOS falls back to Cocoa's
default minimal menu (Show/Hide, Quit) with no way to add custom
items.

The menu is stored in a small module-level Mutex (main-thread only,
same invariant as the rest of app_state.rs's `id` usage) because
`applicationDockMenu:` must return its value synchronously — unlike
e.g. Event::Reopen, there's no round-trip through tao's event queue
available for this callback.
@thomnico
thomnico requested a review from a team as a code owner August 2, 2026 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant