Skip to content

[V3 Alpha] Improves macOS Window menu support - #4588

Merged
leaanthony merged 8 commits into
wailsapp:v3-alphafrom
nidib:v3-alpha-window-controls-in-window-menu
Sep 25, 2025
Merged

leaanthony merged 8 commits into
wailsapp:v3-alphafrom
nidib:v3-alpha-window-controls-in-window-menu

Conversation

@nidib

@nidib nidib commented Sep 18, 2025 •

Copy link
Copy Markdown
Contributor

Description

This PR improves macOS integration by:

  • Adding support for the Window menu role, enabling open windows to appear under the system Window menu.
  • Setting NSWindowTabbingModeDisallowed to disable unwanted tabbing behavior and tab controls in the Window menu.
  • Updating the menu example to use NewWithOptions for better window configuration.

Evidence 1

Windows binding to MacOS's Window menu

https://share.cleanshot.com/swdZxgrY

Evidence 2

Window controls done by external tools (Raycast > center window)

https://share.cleanshot.com/lYp8pZ7h

Type of change

Please select the option that is relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Tested locally in MacOS 15.6.1

  • Windows
  • macOS
  • Linux

Test Configuration

wails3 doctor
 Wails (v3.0.0-dev)  Wails Doctor 
                                                                                                                                                                                                                 
# System 

┌──────────────────────────────────────────────────┐
| Name          | MacOS                            |
| Version       | 15.6.1                           |
| ID            | 24G90                            |
| Branding      | Sequoia                          |
| Platform      | darwin                           |
| Architecture  | arm64                            |
| Apple Silicon | true                             |
| CPU           | Apple M4 Max                     |
| CPU 1         | Apple M4 Max                     |
| CPU 2         | Apple M4 Max                     |
| GPU           | 32 cores, Metal Support: Metal 3 |
| Memory        | 36 GB                            |
└──────────────────────────────────────────────────┘

# Build Environment 

┌─────────────────────────────────────────────────────────┐
| Wails CLI    | v3.0.0-dev                               |
| Go Version   | go1.24.5                                 |
| Revision     | bf805b4152ccff2d2ed7d980c0e7e7dcde926c14 |
| Modified     | true                                     |
| -buildmode   | exe                                      |
| -compiler    | gc                                       |
| CGO_CFLAGS   |                                          |
| CGO_CPPFLAGS |                                          |
| CGO_CXXFLAGS |                                          |
| CGO_ENABLED  | 1                                        |
| CGO_LDFLAGS  |                                          |
| GOARCH       | arm64                                    |
| GOARM64      | v8.0                                     |
| GOOS         | darwin                                   |
| vcs          | git                                      |
| vcs.modified | true                                     |
| vcs.revision | bf805b4152ccff2d2ed7d980c0e7e7dcde926c14 |
| vcs.time     | 2025-08-09T11:44:30Z                     |
└─────────────────────────────────────────────────────────┘

# Dependencies 

┌────────────────────────────────────────────────────────────────────────┐
| npm             | 10.5.0                                               |
| *NSIS           | Not Installed. Install with `brew install makensis`. |
| Xcode cli tools | 2410                                                 |
|                                                                        |
└─────────────────────── * - Optional Dependency ────────────────────────┘

# Checking for issues 

 SUCCESS  No issues found

# Diagnosis 

 SUCCESS  Your system is ready for Wails development!

Checklist:

  • I have updated website/src/pages/changelog.mdx with details of this PR
  • My code follows the general coding style of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Summary by CodeRabbit

  • New Features
    • macOS: Adds a native “Window” menu to the menu bar, enabling standard window controls (e.g., minimize, zoom, bring all to front) for a more consistent macOS experience.
  • Documentation
    • Updated changelog to note the addition of native window controls in the macOS menu bar.

@coderabbitai

coderabbitai Bot commented Sep 18, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

Adds macOS Windows menu support by setting NSApp.WindowsMenu when a submenu has the WindowMenu role, updates the menu example to use NewWithOptions with Name/Title, and documents the change in the unreleased changelog.

Changes

Cohort / File(s) Summary
Example window options
v3/examples/menu/main.go
Switches window creation from New() to NewWithOptions(application.WebviewWindowOptions{Name, Title}); retains background color setup.
macOS Windows menu handling
v3/pkg/application/menu_darwin.go
Adds C function addWindowsMenu(void* menu) and invokes it when a submenu has the WindowMenu role to set NSApp.WindowsMenu; existing roles unchanged.
Changelog update
v3/UNRELEASED_CHANGELOG.md
Notes: “macOS: Shows native window controls in the menu bar” with PR reference.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant App as App
  participant Menu as Menu Builder
  participant NSApp as macOS NSApp
  participant C as C Bridge

  App->>Menu: Build menus
  loop For each menu/submenu item
    Menu->>Menu: Check role
    alt role == WindowMenu
      Menu->>C: addWindowsMenu(nsSubmenu)
      C->>NSApp: set WindowsMenu = nsSubmenu
      Note over NSApp: Windows menu registered
    else role == ServicesMenu
      Menu->>C: setServicesMenu(nsSubmenu)
    else
      Menu->>Menu: No special handling
    end
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • leaanthony

Poem

Hop hop hooray, a window menu appears,
Mac bars now gleam with native gears.
Options named, titles bright,
Rabbits compile by moonlit night.
With one small bridge across the sea,
The Windows menu hops to Cocoa tea. 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title "[V3 Alpha] Improves macOS Window menu support" is concise, single-line, and accurately captures the primary change — adding/improving macOS Window menu behavior and related example updates — making it clear and relevant to reviewers scanning history.
Description Check ✅ Passed The PR description largely follows the repository template: it includes a clear Description, Type of change, testing details with wails doctor output, platform testing selection, evidence links, and a filled checklist, but it is missing an explicit "Fixes #" link and the checklist shows the website changelog entry and tests were not added; these items should be addressed to fully comply with the template.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 99af1fb and dbb1dc4.

📒 Files selected for processing (1)
  • v3/UNRELEASED_CHANGELOG.md (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • v3/UNRELEASED_CHANGELOG.md

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Sep 18, 2025
@dosubot dosubot Bot added the Enhancement New feature or request label Sep 18, 2025
@dosubot

dosubot Bot commented Sep 18, 2025

Copy link
Copy Markdown

Related Documentation

Checked 1 published document(s). No updates required.

You have 2 draft document(s). Publish docs to keep them always up-to-date

How did I do? Any feedback?  Join Discord

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
v3/examples/menu/main.go (1)

149-152: Remove duplicate background color assignment.

Line 152 contains a redundant call to SetBackgroundColour with identical parameters. This doesn't affect functionality but adds unnecessary code.

Apply this diff to remove the duplicate:

-	window := app.Window.NewWithOptions(application.WebviewWindowOptions{
-		Name:  "menu-example",
-		Title: "Menu Example",
-	}).SetBackgroundColour(application.NewRGB(33, 37, 41)).SetBackgroundColour(application.NewRGB(33, 37, 41))
+	window := app.Window.NewWithOptions(application.WebviewWindowOptions{
+		Name:  "menu-example",
+		Title: "Menu Example",
+	}).SetBackgroundColour(application.NewRGB(33, 37, 41))
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between afbbcc9 and 2de514e.

📒 Files selected for processing (3)
  • v3/examples/menu/main.go (1 hunks)
  • v3/pkg/application/menu_darwin.go (2 hunks)
  • v3/pkg/application/webview_window_darwin.go (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2024-10-08T22:11:37.054Z
Learnt from: leaanthony
PR: wailsapp/wails#3763
File: v3/examples/window/main.go:472-475
Timestamp: 2024-10-08T22:11:37.054Z
Learning: In `v3/examples/window/main.go`, `time.Sleep` is used within a goroutine and does not block the UI thread.

Applied to files:

  • v3/examples/menu/main.go
🧬 Code graph analysis (2)
v3/pkg/application/menu_darwin.go (1)
v3/pkg/application/roles.go (1)
  • WindowMenu (17-17)
v3/examples/menu/main.go (1)
v3/pkg/application/webview_window_options.go (1)
  • WebviewWindowOptions (32-143)
🔇 Additional comments (4)
v3/pkg/application/menu_darwin.go (2)

56-60: LGTM!

The Windows menu implementation follows the established pattern for macOS menu roles. The addWindowsMenu function correctly uses the bridge cast and sets NSApp.windowsMenu to enable window management features.


105-107: LGTM!

The Windows menu role processing follows the same pattern as the existing ServicesMenu handling. This will properly wire up the Windows menu when the WindowMenu role is specified in the menu structure.

v3/pkg/application/webview_window_darwin.go (1)

48-49: LGTM! Appropriate fix for macOS tabbing behavior.

Setting NSWindowTabbingModeDisallowed after the delegate assignment is the correct approach. This prevents unwanted window tabbing and associated tab controls from appearing in the Window menu, which aligns with the PR's goal of improving macOS Window menu support.

v3/examples/menu/main.go (1)

149-151: Well-structured window configuration with meaningful metadata.

The use of NewWithOptions with explicit Name and Title fields provides good window identification for the macOS Window menu integration. The naming convention using "menu-example" is clear and descriptive for this example application.

@leaanthony

Copy link
Copy Markdown
Member

You legend! Thanks! 🙏 Could we split out the tab mode to a different setting? I think this would be better and give the developer more control? Please could you also add an entry to the changelog located at v3/UNRELEASED_CHANGELOG.md? Thanks!

@nidib

nidib commented Sep 20, 2025 •

Copy link
Copy Markdown
Contributor Author

Could we split out the tab mode to a different setting?

So we'd be removing it from this PR and adding it in its own PR?

Update: Did remove the hardcoded disabling of tab controls. So it can be implemented in a future PR as an optional config by developers.

@github-actions github-actions Bot added the Documentation Improvements or additions to documentation label Sep 24, 2025
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Sep 24, 2025
@leaanthony

Copy link
Copy Markdown
Member

Update: Did remove the hardcoded disabling of tab controls. So it can be implemented in a future PR as an optional config by developers.

Nice one! It's still a good thing to add mind! You ok opening a PR for that?

@leaanthony
leaanthony enabled auto-merge (squash) September 24, 2025 07:26
auto-merge was automatically disabled September 24, 2025 14:18

Head branch was pushed to by a user without write access

@sonarqubecloud

Copy link
Copy Markdown

@leaanthony
leaanthony merged commit 335fa0b into wailsapp:v3-alpha Sep 25, 2025
52 checks passed
Grantmartin2002 pushed a commit to Grantmartin2002/wails that referenced this pull request Apr 29, 2026
* feat: Binds window menu to app windows

* chore: disables tab feature & controls from menu by default

* docs: Adds title to example for it to show in the window menu item

* style: removes redundant SetBackgroundColor call

* chore: rolls back disabling tab controls for a future optional config

* docs: adds change description to unreleased notes

---------

Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
@taliesin-ai taliesin-ai added the v3 label Aug 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Documentation Improvements or additions to documentation Enhancement New feature or request lgtm This PR has been approved by a maintainer MacOS size:S This PR changes 10-29 lines, ignoring generated files. v3

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants