From 786ccef953089cf65a77765db9b8920120b14805 Mon Sep 17 00:00:00 2001 From: Max <112043822+Maxaubert@users.noreply.github.com> Date: Wed, 11 Nov 2026 20:10:36 +0100 Subject: [PATCH 1/2] fix(mac): Settings window drags, shows in the Dock, hides for Show Desktop (0.5.9) - The page covers the transparent title bar, so the web view ate every click: DragWebView drags the window from the top 28 px (while the page sits at the top) and the empty top of the sidebar; a double click there zooms. - Wind is a regular app while Settings is open (Dock icon, Cmd+Tab, moves aside for Show Desktop) and goes back to a menu-bar agent when it closes. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Kg7JN7TXVWHMtJr9A6bUWo --- mac/Sources/Wind/SettingsWeb.swift | 34 +++++++++++++++++++++++++++++- mac/VERSION | 2 +- mac/docs/architecture.md | 4 ++++ mac/ui/src/Settings.svelte | 13 ++++++++++-- mac/ui/src/bridge.js | 2 ++ 5 files changed, 51 insertions(+), 4 deletions(-) diff --git a/mac/Sources/Wind/SettingsWeb.swift b/mac/Sources/Wind/SettingsWeb.swift index 92dd51c9..30cfb9e8 100644 --- a/mac/Sources/Wind/SettingsWeb.swift +++ b/mac/Sources/Wind/SettingsWeb.swift @@ -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), @@ -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) } @@ -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)") } @@ -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. @@ -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) } + } +} diff --git a/mac/VERSION b/mac/VERSION index 659914ae..416bfb0a 100644 --- a/mac/VERSION +++ b/mac/VERSION @@ -1 +1 @@ -0.5.8 +0.5.9 diff --git a/mac/docs/architecture.md b/mac/docs/architecture.md index 9a6fb8a0..c018edf7 100644 --- a/mac/docs/architecture.md +++ b/mac/docs/architecture.md @@ -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`. diff --git a/mac/ui/src/Settings.svelte b/mac/ui/src/Settings.svelte index 8b57c8b5..268f15b4 100644 --- a/mac/ui/src/Settings.svelte +++ b/mac/ui/src/Settings.svelte @@ -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'; @@ -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); }); @@ -163,7 +172,7 @@
{ clearSearch(); select(id); }} /> -
+
{#key searching ? '?search' : activeId}
{#if searching} diff --git a/mac/ui/src/bridge.js b/mac/ui/src/bridge.js index 7e66f650..59aea5f3 100644 --- a/mac/ui/src/bridge.js +++ b/mac/ui/src/bridge.js @@ -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' }); } From ad723d21dd5cb2d12b0a3aaa2420584e40f604c5 Mon Sep 17 00:00:00 2001 From: Max <112043822+Maxaubert@users.noreply.github.com> Date: Wed, 11 Nov 2026 20:24:11 +0100 Subject: [PATCH 2/2] fix(mac): hiding Wind hides only Settings, not its overlays The Settings window makes Wind a regular app, so Hide Others and the owner's Win+D script now hide it. Its overlay windows were hidden too and ordered back a tick later, which unhid the app and brought Settings back after a second. Overlays set canHide = false. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Kg7JN7TXVWHMtJr9A6bUWo --- mac/Sources/Wind/Crosshair.swift | 1 + mac/Sources/Wind/DrawZoom.swift | 1 + mac/Sources/Wind/WindCursor.swift | 4 ++++ mac/Sources/Wind/WindShot.swift | 1 + 4 files changed, 7 insertions(+) diff --git a/mac/Sources/Wind/Crosshair.swift b/mac/Sources/Wind/Crosshair.swift index 393fa150..6870b4f7 100644 --- a/mac/Sources/Wind/Crosshair.swift +++ b/mac/Sources/Wind/Crosshair.swift @@ -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 diff --git a/mac/Sources/Wind/DrawZoom.swift b/mac/Sources/Wind/DrawZoom.swift index 410431cc..bf59f390 100644 --- a/mac/Sources/Wind/DrawZoom.swift +++ b/mac/Sources/Wind/DrawZoom.swift @@ -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 diff --git a/mac/Sources/Wind/WindCursor.swift b/mac/Sources/Wind/WindCursor.swift index c2705486..79bbdfdb 100644 --- a/mac/Sources/Wind/WindCursor.swift +++ b/mac/Sources/Wind/WindCursor.swift @@ -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 diff --git a/mac/Sources/Wind/WindShot.swift b/mac/Sources/Wind/WindShot.swift index 3773e25c..0aed4886 100644 --- a/mac/Sources/Wind/WindShot.swift +++ b/mac/Sources/Wind/WindShot.swift @@ -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)