Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions mac/Sources/Wind/Crosshair.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ final class Crosshair {
p.ignoresMouseEvents = true
p.level = .screenSaver
p.collectionBehavior = [.canJoinAllSpaces, .fullScreenAuxiliary, .stationary, .ignoresCycle]
p.canHide = false // see WindCursor
let v = NSView()
v.wantsLayer = true
outline.strokeColor = NSColor.black.withAlphaComponent(0.6).cgColor
Expand Down
1 change: 1 addition & 0 deletions mac/Sources/Wind/DrawZoom.swift
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,7 @@ final class DrawZoom: NSObject, SCStreamOutput, SCStreamDelegate, @unchecked Sen
w.animationBehavior = .none
w.isReleasedWhenClosed = false
w.collectionBehavior = [.canJoinAllSpaces, .stationary, .fullScreenAuxiliary, .ignoresCycle]
w.canHide = false // see WindCursor
let v = NSView(frame: CGRect(origin: .zero, size: screen.frame.size))
v.wantsLayer = true
v.layer?.backgroundColor = NSColor.black.cgColor
Expand Down
34 changes: 33 additions & 1 deletion mac/Sources/Wind/SettingsWeb.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ final class SettingsWindowController: NSObject, WKScriptMessageHandler, WKNaviga
let ucc = WKUserContentController()
ucc.add(WeakHandler(self), name: "wind")
cfg.userContentController = ucc
let web = WKWebView(frame: NSRect(x: 0, y: 0, width: 1040, height: 720), configuration: cfg)
let web = DragWebView(frame: NSRect(x: 0, y: 0, width: 1040, height: 720), configuration: cfg)
web.navigationDelegate = self
web.setValue(false, forKey: "drawsBackground") // the window's dark fill shows until the page paints
let w = NSWindow(contentRect: NSRect(x: 0, y: 0, width: 1040, height: 720),
Expand Down Expand Up @@ -78,6 +78,9 @@ final class SettingsWindowController: NSObject, WKScriptMessageHandler, WKNaviga
return
}
#endif
// A regular app while the window is open: a Dock icon and Cmd+Tab entry, and the window moves
// aside for Show Desktop like any other (an accessory app's window stayed put, owner 2026-11-11).
NSApp.setActivationPolicy(.regular)
NSApp.activate(ignoringOtherApps: true)
w.makeKeyAndOrderFront(nil)
}
Expand Down Expand Up @@ -161,6 +164,7 @@ final class SettingsWindowController: NSObject, WKScriptMessageHandler, WKNaviga
if s("action") == "fixZoomShortcuts" { fixZoom?() } else { macAction?(s("action"), s("value")) }
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { [weak self] in self?.pushMacStatus() }
case "captureBinds": onCapture?(s("on") == "1")
case "titleBand": (web as? DragWebView)?.contentBandFree = s("on") == "1"
case "dirty", "saveSession", "discardSession": break // no sessions on the Mac
default: Log.verbose("settings: unknown message \(type)")
}
Expand Down Expand Up @@ -257,6 +261,7 @@ final class SettingsWindowController: NSObject, WKScriptMessageHandler, WKNaviga
onboarding = false
window?.contentView = nil
web = nil; window = nil
NSApp.setActivationPolicy(.accessory) // back to a menu-bar agent: no Dock icon
}

/// An agent app has no menu bar, so the web view would get no Cut/Copy/Paste/Select All/Close keys.
Expand Down Expand Up @@ -356,3 +361,30 @@ extension SettingsWindowController {
func testClose() { window?.performClose(nil) }
}
#endif

/// The page covers the whole window (transparent title bar), so the web view takes every click and the
/// window could not be dragged. The title bar band (and the empty top of the sidebar, beside the traffic
/// lights) drags the window, and a double click there zooms it, as in a native title bar. The page keeps
/// those bands free of controls (Sidebar.svelte's top padding; the page banner, reported by `titleBand`).
final class DragWebView: WKWebView {
static let titleBand: CGFloat = 28, sideBand: CGFloat = 40, sideWidth: CGFloat = 240, narrow: CGFloat = 700, lights: CGFloat = 84

/// The page column's top band holds only the page banner (scrolled to the top). Scrolled, controls pass
/// under it and keep their clicks; the page reports it (`titleBand`).
var contentBandFree = true

static func dragsWindow(at p: NSPoint, width: CGFloat, contentFree: Bool) -> Bool {
if width <= narrow { return p.y < titleBand && p.x < lights } // narrow: the strip's left gap only
if p.x < sideWidth { return p.y < sideBand }
return contentFree && p.y < titleBand
}

override func mouseDown(with e: NSEvent) {
let p = convert(e.locationInWindow, from: nil)
let y = isFlipped ? p.y : bounds.height - p.y
guard let w = window, DragWebView.dragsWindow(at: NSPoint(x: p.x, y: y), width: bounds.width, contentFree: contentBandFree) else {
super.mouseDown(with: e); return
}
if e.clickCount == 2 { w.performZoom(nil) } else { w.performDrag(with: e) }
}
}
4 changes: 4 additions & 0 deletions mac/Sources/Wind/WindCursor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ final class WindCursor {
p.ignoresMouseEvents = true
p.level = NSWindow.Level(rawValue: NSWindow.Level.screenSaver.rawValue + 1) // above the crosshair
p.collectionBehavior = [.canJoinAllSpaces, .fullScreenAuxiliary, .stationary, .ignoresCycle]
// Wind is a regular, hideable app while Settings is open (Hide Others, the owner's Win+D script):
// hiding it must take only the Settings window. An overlay hidden with the app was ordered back
// in a tick later, which unhid the whole app and brought Settings back (owner 2026-11-11).
p.canHide = false
let v = NSView()
v.wantsLayer = true
image.contentsGravity = .resize
Expand Down
1 change: 1 addition & 0 deletions mac/Sources/Wind/WindShot.swift
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ final class ShotPanel {
p.ignoresMouseEvents = true
p.level = NSWindow.Level(rawValue: NSWindow.Level.screenSaver.rawValue + 1)
p.collectionBehavior = [.canJoinAllSpaces, .fullScreenAuxiliary, .stationary, .ignoresCycle]
p.canHide = false // see WindCursor
let v = NSView()
v.wantsLayer = true
v.layer?.addSublayer(layers.root)
Expand Down
2 changes: 1 addition & 1 deletion mac/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.8
0.5.9
4 changes: 4 additions & 0 deletions mac/docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -1080,6 +1080,10 @@ 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).
- **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`)
and the empty top of the sidebar; a double click there zooms.
- **Page:** `ui/` is Windows Wind's Svelte settings UI (copied at Wind commit `982e162`, see
`ui/README.md`), adapted for the Mac. `scripts/build.sh` builds `ui/dist` and bundles it as
`Wind.app/Contents/Resources/ui`.
Expand Down
13 changes: 11 additions & 2 deletions mac/ui/src/Settings.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import '$shared/design/themes.css';
import { groups, missingPermissions } from './settings-schema.js';
import { getSession, setConfig, openIni, exportDiagnostics, windowControl, onMessage,
getMacStatus, onMacStatus, macAction } from './bridge.js';
getMacStatus, onMacStatus, macAction, titleBand } from './bridge.js';
import { fill } from './session.js';
import { themes, normalizePalette } from '$shared/design/themes.js';
import { capturing } from './lib/capture.js';
Expand Down Expand Up @@ -155,6 +155,15 @@
const advOn = $derived(Number(values.showAdvanced) === 1);
const shown = (r) => visible(r) && (!r.adv || advOn);
const extra = $derived({ version: VERSION, mac, onAction, onMacAction });

// Tell the host when the top of the page column holds only the banner, so it can drag the window there
// (DragWebView). Scrolled or searching, controls sit under that band and keep their clicks.
let bandFree = null;
function reportBand() {
const free = !searching && (!main || main.scrollTop < 1);
if (free !== bandFree) { bandFree = free; titleBand(free); }
}
$effect(() => { searching; activeId; queueMicrotask(reportBand); });
</script>

<svelte:window onkeydown={onKeydown} />
Expand All @@ -163,7 +172,7 @@
<div class="body">
<Sidebar groups={top} {bottom} active={searching ? '' : activeId} version={VERSION} {query} {onSearch}
onSelect={(id) => { clearSearch(); select(id); }} />
<main class="main" data-page={searching ? 'search' : group.id} bind:this={main} tabindex="-1" aria-label={searching ? 'Search results' : group.label}>
<main class="main" data-page={searching ? 'search' : group.id} bind:this={main} onscroll={reportBand} tabindex="-1" aria-label={searching ? 'Search results' : group.label}>
{#key searching ? '?search' : activeId}
<div class="page" class:fade={navigated}>
{#if searching}
Expand Down
2 changes: 2 additions & 0 deletions mac/ui/src/bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,6 @@ export function onMacStatus(fn) { return onMessage(m => { if (m && m.type === 'm
// openAccessibility | openScreenRecording | fixZoomShortcuts | setLogin (value "1"/"0") | showLog | rerunSetup
export function macAction(action, value = '') { post({ type: 'macAction', action, value: String(value) }); }
// While a keybind box records, Wind's own hotkeys are paused so the press reaches the page.
/** The top of the page column holds only the banner (scrolled to the top): the host drags the window there. */
export function titleBand(on) { post({ type: 'titleBand', on: on ? '1' : '0' }); }
export function captureBinds(on) { post({ type: 'captureBinds', on: on ? '1' : '0' }); }
Loading