diff --git a/mac/Sources/Wind/AppDelegate.swift b/mac/Sources/Wind/AppDelegate.swift index 4ec1a133..e763f985 100644 --- a/mac/Sources/Wind/AppDelegate.swift +++ b/mac/Sources/Wind/AppDelegate.swift @@ -101,6 +101,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate { } started = true statusItem.button?.title = "" + applyMenuBarIcon() checkSystemZoom() Log.info("started; binds: " + Action.allCases.map { a in "\(a)=\((mag.config.binds().binds[a] ?? []).map { $0.description }.joined(separator: "|"))" }.joined(separator: " ")) @@ -173,6 +174,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate { for k in dropped { Log.error("config.json: \"\(k)\" has the wrong type, using the default") } configInvalid = false mag.apply(c) + applyMenuBarIcon() settingsWindow.update(c) Log.info("config loaded") } catch { @@ -240,6 +242,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate { menu.addItem(item("Mouse within edges", #selector(toggleEdge), on: c.mouseAlign == 1)) menu.addItem(.separator()) menu.addItem(item("Open at login", #selector(toggleLogin), on: SMAppService.mainApp.status == .enabled)) + menu.addItem(item("Show in menu bar", #selector(hideMenuBarIcon), on: true)) menu.addItem(item("Settings…", #selector(openSettings))) let more = NSMenu() more.addItem(item("Edit settings file…", #selector(openConfig))) @@ -291,6 +294,21 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate { }, fixZoom: { [weak self] in self?.turnOffSystemZoom() }, onboard: onboard) } + /// The icon shows while Wind lacks Accessibility whatever the setting: it is where Wind says so. + private func applyMenuBarIcon() { + statusItem?.isVisible = mag.config.showMenuBarIcon || !started + } + + @objc private func hideMenuBarIcon() { + let a = NSAlert() + a.messageText = "Hide Wind from the menu bar?" + a.informativeText = "Wind keeps running. To show the icon again, open Wind again (from Spotlight or Finder) and turn on Show in menu bar in Settings." + a.addButton(withTitle: "Hide"); a.addButton(withTitle: "Cancel") + NSApp.activate(ignoringOtherApps: true) + guard a.runModal() == .alertFirstButtonReturn else { return } + saveConfig { $0.showMenuBarIcon = false } + } + @objc private func toggleLogin() { let svc = SMAppService.mainApp do { diff --git a/mac/Sources/WindCore/Config.swift b/mac/Sources/WindCore/Config.swift index 905a489d..fc899569 100644 --- a/mac/Sources/WindCore/Config.swift +++ b/mac/Sources/WindCore/Config.swift @@ -70,6 +70,8 @@ public struct Config: Codable, Equatable { public var fullPointerSpeed = true public var logLevel = 1 // 0 = quiet, 1 = sessions, 2 = verbose, 3 = + every zoom write + /// The menu bar icon. Hidden, opening Wind again (Spotlight, Finder) shows Settings, where it comes back. + public var showMenuBarIcon = true // Settings window (ui/). Read by the page only, except onboarded (AppDelegate.needsSetup). public var uiPalette = "grey" // the built-in theme: grey, ember, ocean or hicon diff --git a/mac/Tests/fixtures/config_defaults.json b/mac/Tests/fixtures/config_defaults.json index 79ce230b..db33621b 100644 --- a/mac/Tests/fixtures/config_defaults.json +++ b/mac/Tests/fixtures/config_defaults.json @@ -31,6 +31,7 @@ "quit": { "type": "list", "def": "cmd+escape" }, "renderScaling": { "type": "int", "def": "0", "min": 0, "max": 0 }, "showAdvanced": { "type": "bool", "def": "0" }, + "showMenuBarIcon": { "type": "bool", "def": "1" }, "slowPanGlide": { "type": "bool", "def": "0" }, "slowPrecision": { "type": "bool", "def": "0" }, "smoothImages": { "type": "bool", "def": "0" }, diff --git a/mac/VERSION b/mac/VERSION index 416bfb0a..a918a2aa 100644 --- a/mac/VERSION +++ b/mac/VERSION @@ -1 +1 @@ -0.5.9 +0.6.0 diff --git a/mac/docs/architecture.md b/mac/docs/architecture.md index c018edf7..934c3b84 100644 --- a/mac/docs/architecture.md +++ b/mac/docs/architecture.md @@ -1080,6 +1080,8 @@ caret following off. Each Tab must move the view onto the focused button; passes Spec and plan: `~/Documents/Claude/research/wind-mac/2026-11-01-settings-port-spec-plan.md`. - **Opening Wind again** while it runs (Spotlight, Finder, `open -a Wind`) opens this window, or the setup when `needsSetup` holds (`applicationShouldHandleReopen`, 0.5.8). +- **Menu bar icon** (0.6.0): `showMenuBarIcon` (menu item "Show in menu bar", and a Settings row) hides the status + item; Wind keeps running and opening it again shows Settings. It always shows while Accessibility is missing. - **A normal window while open** (0.5.9): Wind turns into a regular app (Dock icon, Cmd+Tab, moves aside for Show Desktop) and back to a menu-bar agent when it closes. The page covers the transparent title bar, so `DragWebView` drags the window from the top 28 px (only while the page sits at the top, reported by `titleBand`) diff --git a/mac/ui/src/settings-schema.js b/mac/ui/src/settings-schema.js index 984336de..fc7319d8 100644 --- a/mac/ui/src/settings-schema.js +++ b/mac/ui/src/settings-schema.js @@ -168,6 +168,8 @@ export const groups = [ desc: 'They fight Wind for the zoom when they are on', on: 'Off', off: 'On', btn: 'Turn off', action: 'fixZoomShortcuts' }, { key: '__loginItem', type: 'macstatus', status: 'loginItem', toggle: true, label: 'Open at login', keywords: ['startup', 'start up', 'launch', 'boot', 'login items', 'autostart', 'automatically', 'sign in', 'background'], desc: 'Starts Wind when you log in', action: 'setLogin' }, + { key: 'showMenuBarIcon', type: 'toggle', label: 'Show in menu bar', keywords: ['menu bar', 'menubar', 'status bar', 'status item', 'icon', 'tray', 'hide', 'show', 'top bar', 'magnifying glass'], + desc: 'When hidden, open Wind again from Spotlight or Finder to get here', def: 1 }, { key: 'logLevel', type: 'select', label: 'Log detail', keywords: ['log', 'logging', 'verbose', 'debug', 'diagnostics', 'trace', 'quiet', 'file', 'troubleshoot'], desc: 'How much Wind writes to its log', options: ['0', '1', '2', '3'], optionLabels: { '0': 'Quiet', '1': 'Sessions', '2': 'Verbose', '3': 'Every zoom step' }, def: '1' }, { key: '__showLog', type: 'button', label: 'Show log', keywords: ['log', 'logs', 'console', 'debug', 'troubleshoot', 'problem', 'file', 'history'], diff --git a/mac/ui/tests/prefs.spec.js b/mac/ui/tests/prefs.spec.js index f0c60076..8010fb29 100644 --- a/mac/ui/tests/prefs.spec.js +++ b/mac/ui/tests/prefs.spec.js @@ -97,5 +97,5 @@ test('General holds the theme, the screenshot and advanced switches; the macOS c await go(page, 'prefs'); const keys = await page.locator('main .row').evaluateAll((rs) => rs.map((r) => r.getAttribute('data-key'))); expect(keys).toEqual(['uiPalette', 'ownScreenshot', 'showAdvanced', 'warmthPct', 'dimPct', '__accessibility', '__screenRecording', - '__zoomShortcuts', '__loginItem', 'logLevel', '__showLog', '__openIni', '__diagnostics', '__rerunSetup']); + '__zoomShortcuts', '__loginItem', 'showMenuBarIcon', 'logLevel', '__showLog', '__openIni', '__diagnostics', '__rerunSetup']); }); diff --git a/mac/ui/tests/schema.spec.js b/mac/ui/tests/schema.spec.js index a24e3397..907c63f1 100644 --- a/mac/ui/tests/schema.spec.js +++ b/mac/ui/tests/schema.spec.js @@ -104,12 +104,12 @@ test('the engine select: Render, Backdrop or Transform (default), in the Engine expect(schemaDefaults().engine).toBe('zoom'); }); -test('the macOS card: status rows, the login switch, log detail and four buttons', () => { +test('the macOS card: status rows, the login and menu bar switches, log detail and four buttons', () => { const prefs = groups.find((g) => g.id === 'prefs'); const mac = prefs.cards.find((c) => c.caption === 'macOS'); expect(mac.rows.map((r) => [r.key, r.type])).toEqual([ ['__accessibility', 'macstatus'], ['__screenRecording', 'macstatus'], ['__zoomShortcuts', 'macstatus'], - ['__loginItem', 'macstatus'], ['logLevel', 'select'], + ['__loginItem', 'macstatus'], ['showMenuBarIcon', 'toggle'], ['logLevel', 'select'], ['__showLog', 'button'], ['__openIni', 'button'], ['__diagnostics', 'button'], ['__rerunSetup', 'button'], ]); const act = Object.fromEntries(mac.rows.map((r) => [r.key, r.action]));