Skip to content

fix(systray): recover click type on macOS 27 - #5919

Open
ChewbaccaCookie wants to merge 1 commit into
wailsapp:masterfrom
ChewbaccaCookie:fix/5752-macos27-tray-click-event-coercion
Open

fix(systray): recover click type on macOS 27#5919
ChewbaccaCookie wants to merge 1 commit into
wailsapp:masterfrom
ChewbaccaCookie:fix/5752-macos27-tray-click-event-coercion

Conversation

@ChewbaccaCookie

@ChewbaccaCookie ChewbaccaCookie commented Aug 6, 2026

Copy link
Copy Markdown

Description

Context

macOS 27 Golden Gate (currently in developer beta) rebuilds the menu bar and NSStatusItem
internals substantially. Apple has publicly acknowledged the direction of travel on developer forums thread 832823
(https://developer.apple.com/forums/thread/832823): "Local event monitors are no longer the
recommended way of scanning for events on status items." The wider menu-bar-app ecosystem
(Ice, BetterDisplay, Deskflow, SaneBar, …) is hitting parallel issues. This PR is a tactical
fix for one specific symptom in Wails

Info: a broader review of the local-event-monitor pattern in systemtray_darwin.m is a reasonable follow-up. This is partially already started in #5760.

Problem

On macOS 27 Golden Gate, left-clicking a Wails system tray icon does nothing (#5752).
Right-click still works.

The root cause is a behaviour change in AppKit's event dispatch:

  • NSStatusItem's target/action (-[StatusItemController statusItemClicked:]) fires from the
    button's sendActionOn: handler.
  • Previously, [NSApp currentEvent] inside that action returned the originating
    NSEventTypeLeftMouseDown / NSEventTypeRightMouseDown.

Fix

Introduce a small C helper, systemTrayCoerceEventType, that maps the raw event type to a
button processClick can dispatch on:

  1. If the raw type is already NSEventTypeLeftMouseDown / NSEventTypeRightMouseDown (macOS ≤26
    path), pass it through unchanged.
  2. Otherwise, fall back to [NSEvent pressedMouseButtons] — bit 1 (right) wins over bit 0
    (left), matching existing right-click-takes-precedence semantics.
  3. If nothing is pressed either, default to left — the action wouldn't have fired without a
    click, so something triggered it.

statusItemClicked: sends the coerced value to Go instead of raw event.type. The Go switch is
untouched, so macOS ≤26 behaviour is unchanged.

Fixes #5752.

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)
  • WEP (proposal only; no implementation)
  • 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?

Was tested on macOS 27.0 beta(26A5388g) and on macOS 26.5.2 (25F84).

  • Windows
  • macOS
  • Linux

Test Configuration

Wails v3.0.0-beta.4 › Wails Doctor
                                                                                                                        
# System
        
┌────────────────────────────┐
| Name          | MacOS      |
| Version       | 27.0       |
| ID            | 26A5388g   |
| Branding      | MacOS 27.0 |
| Platform      | darwin     |
| Architecture  | arm64      |
| Apple Silicon | true       |
| CPU           | Apple M3   |
| CPU           | Apple M3   |
| GPU           | 10 cores   |
| Memory        | 16 GB      |
└────────────────────────────┘
                   
# Build Environment
                   
┌──────────────────────────────────────────────────────────────────────┐
| Wails CLI      | v3.0.0-beta.4                                       |
| Go Version     | go1.26.5                                            |
| -buildmode     | exe                                                 |
| -compiler      | gc                                                  |
| CGO_CFLAGS     |                                                     |
| CGO_CPPFLAGS   |                                                     |
| CGO_CXXFLAGS   |                                                     |
| CGO_ENABLED    | 1                                                   |
| CGO_LDFLAGS    |                                                     |
| DefaultGODEBUG | cryptocustomrand=1,tlssecpmlkem=0,urlstrictcolons=0 |
| GOARCH         | arm64                                               |
| GOARM64        | v8.0                                                |
| GOOS           | darwin                                              |
└──────────────────────────────────────────────────────────────────────┘
              
# Dependencies
              
┌──────────────────────────────────────────────────────────────────────────────────────────────────────────┐
| *Android SDK       | Not found. Set ANDROID_HOME (install via Android Studio or the command-line tools). |
| *NSIS              | Not Installed. Install with `brew install makensis`.                                |
| *Xcode (iOS)       | Not installed. iOS builds need full Xcode (App Store), not just the CLI tools.      |
| *iOS Device SDK    | Not found                                                                           |
| *iOS Simulator SDK | Not found                                                                           |
| Xcode cli tools    | 2417                                                                                |
| npm                | 10.9.8                                                                              |
| docker             | *Not installed (optional - for cross-compilation)                                   |
|                                                                                                          |
└──────────────────────────────────────── * - Optional Dependency ─────────────────────────────────────────┘
         
# Signing
         
┌────────────────────────────────────────┐
| macOS Signing   | Not configured       |
| Windows Signing | Not configured       |
| Linux Signing   | Not configured (GPG) |
└────────────────────────────────────────┘
                     
# Checking for issues
                     
 SUCCESS  No issues found
           
# Diagnosis
           
 SUCCESS  Your system is ready for Wails development!

Checklist:

  • (v2 only) I have updated website/src/pages/changelog.mdx with details of this PR (v3 changelog entries are added automatically)
  • 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 -> no documentation changes done
  • 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

  • Bug Fixes
    • Improved macOS system tray click handling to correctly identify left- and right-button interactions.
    • Fixed ambiguous click events on newer macOS versions, ensuring tray actions are dispatched reliably.
    • Improved handling when mouse buttons are pressed or released in different event sequences.
  • Tests
    • Added regression coverage for macOS system tray mouse-event behavior.

On macOS 27 Golden Gate, [NSApp currentEvent] inside an NSStatusItem
action selector no longer reflects the originating mouse-down, so
processClick's left/right switch dropped the event.

Coerce via [NSEvent pressedMouseButtons] as a fallback. Behaviour on
macOS <=26 is unchanged (the coercion is a no-op when the raw event
type is already a mouse-down). Adds a table-driven regression test.

Closes wailsapp#5752
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The Darwin status item callback now coerces macOS event types using the pressed-button state before dispatch. A Go wrapper exposes the C helper for testing. Darwin regression tests cover legacy and macOS 27 event types.

Changes

Darwin status item event handling

Layer / File(s) Summary
Event coercion and callback wiring
v3/pkg/application/systemtray_darwin.h, v3/pkg/application/systemtray_darwin.m, v3/pkg/application/systemtray_darwin.go
The C helper preserves explicit mouse-down events, infers right clicks from the pressed-button mask, defaults to left clicks, and passes the coerced type to systrayClickCallback. The Go wrapper delegates to the C helper.
Event coercion regression coverage
v3/pkg/application/systemtray_darwin_test.go
Darwin-only table-driven tests cover legacy mouse-down events, macOS 27 event types, left-button defaults, mouse-up recovery, and right-button precedence.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: leaanthony

Poem

I’m a rabbit with ears held high,
Coercing clicks beneath the sky.
Left or right, the path is clear,
MacOS 27 now behaves near.
Tests hop through each event with cheer.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title clearly and concisely identifies the macOS 27 systray click-type recovery fix.
Description check ✅ Passed The description explains the problem, fix, issue, test environments, reproduction context, and relevant checklist results.
Linked Issues check ✅ Passed The description links the relevant bug with “Fixes #5752,” matching the repository requirement for bug fixes.
Out of Scope Changes check ✅ Passed The implementation and regression test directly support macOS 27 system tray click recovery and remain within the stated objective.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@ChewbaccaCookie
ChewbaccaCookie force-pushed the fix/5752-macos27-tray-click-event-coercion branch from 3563e45 to cbe84c2 Compare August 6, 2026 15:17
@ChewbaccaCookie ChewbaccaCookie changed the title fix: macos 27 left mouse click system tray fix fix(systray): recover click type on macOS 27 Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[v3][macOS 27] Tray menu fails to open/render on click

1 participant