Skip to content

nil mac.Options causes NSWindowZoomButton to be disabled #5519

@hossein1376

Description

@hossein1376

Description

When options.Mac is nil (not set) in wails.Run(), the green zoom/fullscreen button (NSWindowZoomButton) in the macOS window titlebar traffic lights is disabled. Users cannot enter fullscreen via the native button, only through F11 or a custom menu item.

File: v2/internal/frontend/desktop/darwin/window.go

At line 65, zoomable is declared as a C.int — Go initializes it to 0 (the zero value):

var fullSizeContent, hideTitleBar, zoomable, hideTitle, useToolbar, webviewIsTransparent C.int

At lines 92-129, the assignment that sets zoomable is inside an if frontendOptions.Mac != nil guard:

if frontendOptions.Mac != nil {
    // ...
    zoomable = bool2Cint(!frontendOptions.Mac.DisableZoom)  // line 121
    // ...
}

When Mac is nil, zoomable stays at 0.

This value is then passed to the C/ObjC layer where in WailsContext.m:208-211 it is used as:

if (!zoomable && resizable) {
    NSButton *button = [self.mainWindow standardWindowButton:NSWindowZoomButton];
    [button setEnabled: NO];
}

Since zoomable is 0 (false) and resizable is 1 (true), the condition evaluates to !false && true = true, and the green zoom button is explicitly disabled.

The semantics are inverted: the natural Go zero value of 0 should mean "zoom not disabled" (i.e., enabled), but the ObjC code treats 0 as "zoom is disabled".

To Reproduce

  1. Create or use an existing Wails v2 project.
  2. In main.go, call wails.Run() without setting Mac:
    err = wails.Run(&options.App{
        Title:  "Test",
        Width:  1024,
        Height: 768,
        // Mac: &mac.Options{},   // <-- NOT set
    })
  3. Build and run on macOS.
  4. Observe the window's traffic light buttons in the top-left corner.

Expected behaviour

The green zoom/fullscreen button should be enabled by default. When mac.Options is not explicitly configured, DisableZoom logically defaults to false (zoom enabled), so the button should work.

Screenshots

Nil mac.Options:

Image

With &mac.Options{}:

Image

Attempted Fixes

Set an empty mac.Options in the app config:

import "github.com/wailsapp/wails/v2/pkg/options/mac"

err = wails.Run(&options.App{
    // ...
    Mac: &mac.Options{},
})

This triggers the non-nil branch, DisableZoom defaults to Go's false, so zoomable = 1 and the button works correctly.

System Details

$ wails doctor

# Wails
Version | v2.12.0


# System
┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
| OS           | MacOS                                                                                                                       |
| Version      | 26.5                                                                                                                        |
| ID           | 25F71                                                                                                                       |
| Branding     |                                                                                                                             |
| Go Version   | go1.26.3                                                                                                                    |
| Platform     | darwin                                                                                                                      |
| Architecture | arm64                                                                                                                       |
| CPU 1        | Apple M4 Pro                                                                                                                |
| CPU 2        | Apple M4 Pro                                                                                                                |
| GPU          | Chipset Model: Apple M4 Pro Type: GPU Bus: Built-In Total Number of Cores: 16 Vendor: Apple (0x106b) Metal Support: Metal 4 |
| Memory       | 24GB                                                                                                                        |
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

# Dependencies
┌────────────────────────────────────────────────────────────────┐
| Dependency                | Package Name | Status    | Version |
| Xcode command line tools  | N/A          | Installed | 2416    |
| Nodejs                    | N/A          | Installed | 26.0.0  |
| npm                       | N/A          | Installed | 11.12.1 |
| *Xcode                    | N/A          | Available |         |
| *upx                      | N/A          | Available |         |
| *nsis                     | N/A          | Available |         |
|                                                                |
└─────────────────── * - Optional Dependency ────────────────────┘

# Diagnosis
Optional package(s) installation details:
  - Xcode: Available at https://apps.apple.com/us/app/xcode/id497799835
  - upx : Available at https://upx.github.io/
  - nsis : More info at https://wails.io/docs/guides/windows-installer/

 SUCCESS  Your system is ready for Wails development!

 ♥   If Wails is useful to you or your company, please consider sponsoring the project:
https://github.com/sponsors/leaanthony

Additional context

This is a regression introduced by PR #3289 (from two years ago), which added the DisableZoom field to mac.Options.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't workingMacOSP2Medium priorityv2

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions