Skip to content

gpui: add a macOS tray / status-bar item - #15

Open
Cyberistic wants to merge 1 commit into
remorses:gpuixfrom
Cyberistic:feat/tray
Open

Cyberistic wants to merge 1 commit into
remorses:gpuixfrom
Cyberistic:feat/tray

Conversation

@Cyberistic

@Cyberistic Cyberistic commented Oct 24, 2026 •

Copy link
Copy Markdown

Adds a tray / status-bar item, separate from the app menu bar.
tested on mac only
closes remorses/gpuix#109

image
let tray = cx.create_tray(TrayOptions {
    icon: Some("icon.png".into()),
    title: None,
    tooltip: Some("My app".into()),
})?;
tray.set_menu(vec![
    TrayMenuItem { id: "open".into(), label: "Open".into(), enabled: true, checked: false },
    TrayMenuItem { id: "quit".into(), label: "Quit".into(), enabled: true, checked: false },
]);

cx.on_tray_event(|event, cx| match event {
    TrayEvent::Click => {},
    TrayEvent::MenuItem(id) if id == "quit" => cx.quit(),
    TrayEvent::MenuItem(id) => {}
});

agent slop below:

Limits: no template-image inference, per-item icons, submenus, separators or key equivalents; the item is main-thread only (off-thread set_menu logs and is dropped); Windows needs an .ico (LoadImageW does not decode PNG), Linux decodes PNG for IconPixmap but skips .icns; duplicate ids are allowed and report the same id.

Adds `App::create_tray`, `App::on_tray_event`, `App::keep_running`, and
the `TrayOptions`, `TrayMenuItem`, `TrayEvent` and `TrayHandle` types.

Tray events never reach the application from a native callback: AppKit's
menu tracking, the Windows message loop and the Linux tray service only
fill a channel, and the foreground task built by `App::on_tray_event`
drains it with an unborrowed App. `App::keep_running` is the tray's
companion: it keeps the process alive when the last window closes.

macOS backs the items with an `NSStatusItem` in the menu bar, Windows
with `Shell_NotifyIconW` and a hidden message window, and Linux with a
StatusNotifierItem through `ksni`, which also serves the dbusmenu.
`set_title` is macOS-only and `set_tooltip` maps to each platform's
nearest equivalent; both are documented as no-ops where unsupported.
@Cyberistic Cyberistic changed the title gpui: add a macOS tray / status-bar item gpui: add tray items on macOS, Windows and Linux Oct 25, 2026
@Cyberistic Cyberistic changed the title gpui: add tray items on macOS, Windows and Linux gpui: add a macOS tray / status-bar item Oct 25, 2026
@Cyberistic
Cyberistic marked this pull request as ready for review October 25, 2026 04:24
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