Skip to content

A tiny friend in your Mac's notch and on your iPhone that keeps an eye on your AI coding agents: Claude Code, Codex, Cursor, Gemini CLI, Antigravity and more. Approve from the notch or your Lock Screen.

Adapt resting island to displays without a notch

Jean-Pierreb11a90d0b765
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 0813b207..0e3a15a6 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -18,6 +18,9 @@ jobs:
- name: Generate project
run: cd NotchBuddy && xcodegen
+ - name: Test screen geometry
+ run: bash scripts/test-screen-geometry.sh
+
- name: Build
run: |
xcodebuild \
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 4a3ee4d6..3ade7f06 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -11,6 +11,12 @@ cd NotchBuddy && xcodegen && open NotchBuddy.xcodeproj
Never edit `NotchBuddy.xcodeproj` by hand: change `project.yml` and run `xcodegen`.
+Check resting island dimensions on screens with and without a notch:
+
+```bash
+bash scripts/test-screen-geometry.sh
+```
+
## Good first contributions
- A new integration (a poller + a pill + a detail card). Look at `StripePoller.swift` for a compact example.
diff --git a/NotchBuddy/NotchBuddy.xcodeproj/project.pbxproj b/NotchBuddy/NotchBuddy.xcodeproj/project.pbxproj
index 0423c8c5..d5a8b20a 100644
--- a/NotchBuddy/NotchBuddy.xcodeproj/project.pbxproj
+++ b/NotchBuddy/NotchBuddy.xcodeproj/project.pbxproj
@@ -12,11 +12,13 @@
06BF5FD95E03010CAFDBF2D0 /* NotchBuddyApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1BD8F3CAA60CF37640759E1 /* NotchBuddyApp.swift */; };
091EC3B2F1060D7EE1317E4E /* IslandWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D710BD7834228045869D0184 /* IslandWindowController.swift */; };
0A267EE2955C7AD8E02A296C /* N8nPoller.swift in Sources */ = {isa = PBXBuildFile; fileRef = B89DA1A0C21AE3535A1760BB /* N8nPoller.swift */; };
+ 0D68A4C4E3422487DB7B2262 /* IslandScreenGeometry.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78BC1357785CA1B099A33969 /* IslandScreenGeometry.swift */; };
0E83C1DD4D20E7FB7A904450 /* VercelPoller.swift in Sources */ = {isa = PBXBuildFile; fileRef = 71718D1B87A39A4879DD2A9D /* VercelPoller.swift */; };
0E9CE475EC53C67DAB00F8E5 /* BotEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4540F630F8BA04AFFFA3979 /* BotEngine.swift */; };
118FC4AE0AC74D84B4A134D8 /* VercelPoller.swift in Sources */ = {isa = PBXBuildFile; fileRef = 71718D1B87A39A4879DD2A9D /* VercelPoller.swift */; };
1558BB00C530B721172F6E65 /* StripePoller.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2EF78999D68D56ADE4CEFBE2 /* StripePoller.swift */; };
160EDB9D06275E2607DA5151 /* N8nPoller.swift in Sources */ = {isa = PBXBuildFile; fileRef = B89DA1A0C21AE3535A1760BB /* N8nPoller.swift */; };
+ 186AB8904029767DAA5277CF /* IslandScreenGeometry.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78BC1357785CA1B099A33969 /* IslandScreenGeometry.swift */; };
1969590AFEE6CB21404346F1 /* CalcomPoller.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3104222B3F17BA5E8DEA5277 /* CalcomPoller.swift */; };
1F11EC4E6F604C612A1ADAD1 /* AppState.swift in Sources */ = {isa = PBXBuildFile; fileRef = C2E4F18AA940EFF7E047B9F7 /* AppState.swift */; };
2132477000FD77F7EB234DAA /* FileDropView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3232F258523DD8D09B670363 /* FileDropView.swift */; };
@@ -77,6 +79,7 @@
61B5FDDE03F5F711146937E2 /* ResendPoller.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResendPoller.swift; sourceTree = "<group>"; };
6FD65943C32E150F1CD65C31 /* UploadSequenceEngine.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UploadSequenceEngine.swift; sourceTree = "<group>"; };
71718D1B87A39A4879DD2A9D /* VercelPoller.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VercelPoller.swift; sourceTree = "<group>"; };
+ 78BC1357785CA1B099A33969 /* IslandScreenGeometry.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IslandScreenGeometry.swift; sourceTree = "<group>"; };
79D8DD79C3DD9BBC584B3CB2 /* HookServer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HookServer.swift; sourceTree = "<group>"; };
7C1A7D5CBE2AC084A10C5FF3 /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = "<group>"; };
8CB8B6E5E9DA6164F979E88F /* GithubPoller.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GithubPoller.swift; sourceTree = "<group>"; };
@@ -113,6 +116,7 @@
C581F7B1A9F14B281B60063E /* GreetingCanvasView.swift */,
79D8DD79C3DD9BBC584B3CB2 /* HookServer.swift */,
15A1A8206F73376F4CAF2057 /* IslandRootView.swift */,
+ 78BC1357785CA1B099A33969 /* IslandScreenGeometry.swift */,
D8212018F09EA1E96FBD63CD /* IslandStateMachine.swift */,
8D3CE3617E9D336DDBA10F7A /* IslandTypes.swift */,
FA02B08886939FF6FE0475DD /* IslandViewContent.swift */,
@@ -281,6 +285,7 @@
8C32A0C3EAF536D3836F61D5 /* GreetingCanvasView.swift in Sources */,
2C798C3837A63B9BB561A1A0 /* HookServer.swift in Sources */,
CA3321C14A11FED94E48B3E3 /* IslandRootView.swift in Sources */,
+ 186AB8904029767DAA5277CF /* IslandScreenGeometry.swift in Sources */,
5B9A00AFB0837731FA678E4E /* IslandStateMachine.swift in Sources */,
3F19756A396F125EC711247F /* IslandTypes.swift in Sources */,
065FCE817315454DE3F85F25 /* IslandViewContent.swift in Sources */,
@@ -314,6 +319,7 @@
C0E18D0F6F5F6D131E6066B8 /* GreetingCanvasView.swift in Sources */,
9DD56C95ECABDDCE23652D50 /* HookServer.swift in Sources */,
B605F976F4141435F27CF266 /* IslandRootView.swift in Sources */,
+ 0D68A4C4E3422487DB7B2262 /* IslandScreenGeometry.swift in Sources */,
3756B7E1A55D9CEC8C4D34A4 /* IslandStateMachine.swift in Sources */,
D82E93014C8087AE81511E40 /* IslandTypes.swift in Sources */,
68A950E3C23FD612639D9776 /* IslandViewContent.swift in Sources */,
diff --git a/NotchBuddy/Sources/App/AppState.swift b/NotchBuddy/Sources/App/AppState.swift
index 6fd9f920..0b803627 100644
--- a/NotchBuddy/Sources/App/AppState.swift
+++ b/NotchBuddy/Sources/App/AppState.swift
@@ -42,6 +42,7 @@ final class AppState: ObservableObject {
// Real notch dimensions (set by IslandWindowController on launch)
var notchWidth: CGFloat = IslandConst.notchWidth
var notchHeight: CGFloat = IslandConst.notchHeight
+ var hasNotch = true
// Last app active before NotchBuddy (for window context capture)
var lastExternalApp: NSRunningApplication? = nil
diff --git a/NotchBuddy/Sources/App/GreetingCanvasView.swift b/NotchBuddy/Sources/App/GreetingCanvasView.swift
index 5c7ffe15..cda5182f 100644
--- a/NotchBuddy/Sources/App/GreetingCanvasView.swift
+++ b/NotchBuddy/Sources/App/GreetingCanvasView.swift
@@ -31,15 +31,10 @@ private let GC0 = CGPoint(x: 320, y: 90) // Mochi center
private let GHB: CGFloat = 58 // body height at full size
private let GASP: CGFloat = 1.34 // body width/height ratio
private let GEAR_X: CGFloat = 40 // ear x from small island left edge (matches BotPlacement compact x=40)
-private let GEAR_Y: CGFloat = 16 // ear y
private let GEAR_HB:CGFloat = 17 // ear body height
private let GCARD = CGRect(x: 10, y: 36, width: 620, height: 104)
private let GCARD_R:CGFloat = 20
-// Small island = compact mode size (matches our actual nw+160)
-private var GSMALL_W: CGFloat { IslandConst.notchWidth + 160 }
-private let GSMALL_H: CGFloat = IslandConst.notchHeight
-
// MARK: - Easing (mirrors E = {...})
private enum GE {
@@ -101,18 +96,18 @@ private let greetParticles: (rings: [GRing], streaks: [GStreak]) = {
// MARK: - Pose computation
-private func greetPose(_ t: Double) -> GreetPose {
+private func greetPose(_ t: Double, compact: IslandRestingLayout) -> GreetPose {
// island size interpolation (used as reference for clip, not drawn)
let gx = gSeg(t, 0, 0.5)
let g = sin(.pi*gx/2) + 0.04*sin(.pi*gx)*gx
- let iw = gLerp(Double(IslandConst.notchWidth), 640, g)
- let ih = gLerp(Double(IslandConst.notchHeight), 150, g)
+ let iw = gLerp(Double(compact.width - 160), 640, g)
+ let ih = gLerp(Double(compact.height), 150, g)
// body grows with back-ease (tiny → full size)
let gg = GE.back(gSeg(t, 0.02, GT.grow))
var hb = gLerp(3, Double(GHB), gg)
var x = Double(GC0.x)
- var y = gLerp(16, Double(GC0.y), GE.out(gSeg(t, 0.02, GT.grow)))
+ var y = gLerp(Double(compact.botCenterY), Double(GC0.y), GE.out(gSeg(t, 0.02, GT.grow)))
var sx = 1.0, sy = 1.0, tilt = 0.0
// dip (1.25→1.52): body squishes forward
@@ -179,12 +174,12 @@ private func greetPose(_ t: Double) -> GreetPose {
)
}
-private func smallPose() -> GreetPose {
- let sw = Double(GSMALL_W)
+private func smallPose(_ compact: IslandRestingLayout) -> GreetPose {
+ let sw = Double(compact.width)
return GreetPose(
- hb: Double(GEAR_HB),
+ hb: Double(GEAR_HB * compact.botDiameter / 20),
x: 320 - sw/2 + Double(GEAR_X),
- y: Double(GEAR_Y),
+ y: Double(compact.botCenterY),
sx: 1, sy: 1, tilt: 0,
eye: .dot, open: 1, eyeRoll: 0,
lookX: 0, lookY: 0,
@@ -192,14 +187,14 @@ private func smallPose() -> GreetPose {
badge: 1, tint: 0.6, halo: 0.6, haloBlue: 1,
minis: 1, fx: 1,
header: 0, card: 0,
- iw: sw, ih: Double(GSMALL_H)
+ iw: sw, ih: Double(compact.height)
)
}
-private func pose(_ t: Double, tc: Double) -> GreetPose {
- if t < tc { return greetPose(min(t, GT.end + 10)) }
- let a = greetPose(tc)
- let b = smallPose()
+private func pose(_ t: Double, tc: Double, compact: IslandRestingLayout) -> GreetPose {
+ if t < tc { return greetPose(min(t, GT.end + 10), compact: compact) }
+ let a = greetPose(tc, compact: compact)
+ let b = smallPose(compact)
let e = GE.inOut(gSeg(t, tc, tc + GT.COLLAPSE))
var p = a
p.iw = gLerp(a.iw, b.iw, e); p.ih = gLerp(a.ih, b.ih, e)
@@ -495,16 +490,17 @@ private func drawHeader(_ ctx: CGContext, alpha: Double) {
private let miniColors = ["#E86A6A","#3E86E0","#EFAE5A","#8C73F2"]
-private func drawMinis(_ ctx: CGContext, alpha: Double) {
+private func drawMinis(_ ctx: CGContext, alpha: Double, compact: IslandRestingLayout) {
guard alpha > 0.01 else { return }
- let cx = 320 + GSMALL_W/2 - 27
- let cy: CGFloat = 16
- let sp: CGFloat = 6
+ let cx = 320 - compact.width/2 + compact.miniGridCenterX
+ let cy = compact.botCenterY
+ let sp: CGFloat = 6 * compact.miniGridScale
let offsets: [(CGFloat, CGFloat)] = [(-sp,-sp),(sp,-sp),(-sp,sp),(sp,sp)]
for (i,(dx,dy)) in offsets.enumerated() {
ctx.saveGState()
ctx.translateBy(x: cx+dx, y: cy+dy)
- ctx.scaleBy(x: CGFloat(alpha), y: CGFloat(alpha))
+ let scale = CGFloat(alpha) * compact.miniGridScale
+ ctx.scaleBy(x: scale, y: scale)
ctx.setFillColor(gHex(miniColors[i]))
ctx.addPath(mochiPath(hw: 5.3, hh: 4)); ctx.fillPath()
ctx.restoreGState()
@@ -513,8 +509,8 @@ private func drawMinis(_ ctx: CGContext, alpha: Double) {
// MARK: - Full draw function
-private func drawGreeting(_ ctx: CGContext, size: CGSize, t: Double, tc: Double) {
- let p = pose(t, tc: tc)
+private func drawGreeting(_ ctx: CGContext, size: CGSize, t: Double, tc: Double, compact: IslandRestingLayout) {
+ let p = pose(t, tc: tc, compact: compact)
// Card background (dark panel)
if p.card > 0 {
@@ -538,7 +534,7 @@ private func drawGreeting(_ ctx: CGContext, size: CGSize, t: Double, tc: Double)
}
// drawHeader: no icons during greeting
- drawMinis(ctx, alpha: p.minis)
+ drawMinis(ctx, alpha: p.minis, compact: compact)
drawMochi(ctx, p: p)
}
@@ -561,7 +557,9 @@ struct GreetingCanvasView: View {
let t = timeline.date.timeIntervalSince(startDate)
Canvas { context, size in
context.withCGContext { cgCtx in
- drawGreeting(cgCtx, size: size, t: t, tc: tc)
+ drawGreeting(cgCtx, size: size, t: t, tc: tc,
+ compact: IslandRestingLayout(width: state.notchWidth + 160,
+ height: state.notchHeight))
}
}
// Fire greetComplete exactly once at T.end (when no hover)
diff --git a/NotchBuddy/Sources/App/IslandRootView.swift b/NotchBuddy/Sources/App/IslandRootView.swift
index 9de472e1..bda8bfee 100644
--- a/NotchBuddy/Sources/App/IslandRootView.swift
+++ b/NotchBuddy/Sources/App/IslandRootView.swift
@@ -95,6 +95,12 @@ struct IslandContainer: View {
// fire from the current position (e.g. choose at 60,101) when canvas deactivates.
// Hidden during upload canvas or greeting (both draw their own Mochi).
BotPlacement(state: state, islandW: islandWidth, islandH: islandHeight)
+ // Keep idle animations inside the resting strip. Expanded views
+ // retain the panel's full height for particles and hands.
+ .mask(alignment: .topLeading) {
+ Rectangle().frame(width: islandWidth,
+ height: state.mode == .expanded ? 320 : islandHeight)
+ }
.opacity(uploadActive || greetingActive ? 0 : 1)
.animation(.easeInOut(duration: 0.25), value: uploadActive || greetingActive)
@@ -103,6 +109,7 @@ struct IslandContainer: View {
Group {
if state.mode == .compact {
CompactMiniGrid(state: state)
+ .scaleEffect(IslandRestingLayout(width: islandWidth, height: islandHeight).miniGridScale)
.position(x: islandWidth - 40, y: islandHeight / 2)
.transition(.opacity)
}
@@ -251,7 +258,7 @@ struct BotPlacement: View {
let islandH: CGFloat
var body: some View {
- let (cx, cy, diameter, opacity) = botPosition(mode: state.mode, view: state.view, islandW: islandW, islandH: islandH, uploadProgress: state.uploadProgress)
+ let (cx, cy, diameter, opacity) = botPosition(mode: state.mode, view: state.view, islandW: islandW, islandH: islandH, uploadProgress: state.uploadProgress, hasNotch: state.hasNotch)
let canvasSize = diameter / 0.6
let overhang: CGFloat = 40
let isUploading = state.view == .uploading
@@ -338,10 +345,13 @@ struct BotPlacement: View {
}
}
-func botPosition(mode: IslandMode, view: IslandView, islandW: CGFloat, islandH: CGFloat, uploadProgress: Double) -> (CGFloat, CGFloat, CGFloat, Double) {
+func botPosition(mode: IslandMode, view: IslandView, islandW: CGFloat, islandH: CGFloat, uploadProgress: Double, hasNotch: Bool = true) -> (CGFloat, CGFloat, CGFloat, Double) {
+ let resting = IslandRestingLayout(width: islandW, height: islandH)
switch mode {
- case .hidden: return (46, 16, 6, 0)
- case .compact: return (40, 16, 20, 1)
+ case .hidden:
+ return hasNotch ? (46, 16, 6, 0)
+ : (islandW / 2, resting.botCenterY, resting.botDiameter, 1)
+ case .compact: return (40, resting.botCenterY, resting.botDiameter, 1)
case .expanded:
let layout = IslandConst.viewLayouts[view]!
let diameter = layout.botDiameter
diff --git a/NotchBuddy/Sources/App/IslandScreenGeometry.swift b/NotchBuddy/Sources/App/IslandScreenGeometry.swift
new file mode 100644
index 00000000..a06f8a4b
--- /dev/null
+++ b/NotchBuddy/Sources/App/IslandScreenGeometry.swift
@@ -0,0 +1,42 @@
+import Foundation
+
+/// Resting island dimensions, using a physical notch only when the screen has one.
+struct IslandScreenGeometry {
+ static let fallbackNotchWidth: CGFloat = 184
+ private static let noNotchWidth: CGFloat = 80
+ private static let noNotchHeight: CGFloat = 24
+
+ let hasNotch: Bool
+ let width: CGFloat
+ let height: CGFloat
+
+ init(screenWidth: CGFloat, safeAreaTop: CGFloat,
+ auxiliaryLeftWidth: CGFloat?, auxiliaryRightWidth: CGFloat?,
+ menuBarHeight: CGFloat) {
+ hasNotch = safeAreaTop > 0
+ if hasNotch {
+ if let left = auxiliaryLeftWidth, let right = auxiliaryRightWidth {
+ let measuredWidth = screenWidth - left - right
+ width = measuredWidth > 0 && measuredWidth < screenWidth
+ ? measuredWidth : Self.fallbackNotchWidth
+ } else {
+ width = Self.fallbackNotchWidth
+ }
+ height = safeAreaTop
+ } else {
+ width = Self.noNotchWidth
+ height = min(Self.noNotchHeight, menuBarHeight)
+ }
+ }
+}
+
+/// Shared by the compact view and the greeting's collapse destination.
+struct IslandRestingLayout {
+ let width: CGFloat
+ let height: CGFloat
+
+ var botDiameter: CGFloat { min(20, max(0, height - 6)) }
+ var botCenterY: CGFloat { height / 2 }
+ var miniGridScale: CGFloat { min(1, max(0, height - 4) / 28) }
+ var miniGridCenterX: CGFloat { width - 40 }
+}
diff --git a/NotchBuddy/Sources/App/IslandTypes.swift b/NotchBuddy/Sources/App/IslandTypes.swift
index 8fe91387..c2777a9a 100644
--- a/NotchBuddy/Sources/App/IslandTypes.swift
+++ b/NotchBuddy/Sources/App/IslandTypes.swift
@@ -79,7 +79,7 @@ enum AgentLayoutMode {
// MARK: - Constants (from NW, NH, EW in prototype)
enum IslandConst {
- static let notchWidth: CGFloat = 184
+ static let notchWidth: CGFloat = IslandScreenGeometry.fallbackNotchWidth
static let notchHeight: CGFloat = 32
static let expandedWidth: CGFloat = 640
static let earRadius: CGFloat = 14
diff --git a/NotchBuddy/Sources/App/IslandWindowController.swift b/NotchBuddy/Sources/App/IslandWindowController.swift
index a9e48ff4..d01c5e61 100644
--- a/NotchBuddy/Sources/App/IslandWindowController.swift
+++ b/NotchBuddy/Sources/App/IslandWindowController.swift
@@ -42,11 +42,13 @@ final class IslandWindowController: NSWindowController {
// Notch real dimensions (set on init)
private var notchW: CGFloat = IslandConst.notchWidth
private var notchH: CGFloat = IslandConst.notchHeight
+ private var hasNotch = true
convenience init() {
let screen = Self.notchScreen() ?? NSScreen.main!
- let nW = Self.notchWidth(for: screen)
- let nH = Self.notchHeight(for: screen)
+ let geometry = Self.screenGeometry(for: screen)
+ let nW = geometry.width
+ let nH = geometry.height
let panelW: CGFloat = 720
let panelH: CGFloat = 320
@@ -64,6 +66,7 @@ final class IslandWindowController: NSWindowController {
self.islandPanel = panel
self.notchW = nW
self.notchH = nH
+ self.hasNotch = geometry.hasNotch
setupPanel(screen: screen)
}
@@ -79,6 +82,7 @@ final class IslandWindowController: NSWindowController {
// Propagate real notch dimensions to AppState
AppState.shared.notchWidth = notchW
AppState.shared.notchHeight = notchH
+ AppState.shared.hasNotch = hasNotch
let contentSize = panel.contentRect(forFrameRect: panel.frame).size
@@ -210,7 +214,11 @@ final class IslandWindowController: NSWindowController {
// Island rect in panel coords
let islandRect = panel.currentIslandFrame(nw: notchW, nh: notchH)
- let inIsland = islandRect.insetBy(dx: -6, dy: -6).contains(local)
+ // On a screen without a notch, the resting bar must not intercept clicks
+ // in the app window immediately below the menu bar.
+ let hoverRect = !hasNotch && state.mode != .expanded
+ ? islandRect : islandRect.insetBy(dx: -6, dy: -6)
+ let inIsland = hoverRect.contains(local)
// Toggle click-through
let shouldAcceptMouse = inIsland || inAttachDrag || attachDragStart != nil
@@ -740,7 +748,7 @@ final class IslandWindowController: NSWindowController {
let islandMinX = (panelW - islandW) / 2
let (cx, cy, diameter, _) = botPosition(mode: s.mode, view: s.view,
islandW: islandW, islandH: islandH,
- uploadProgress: s.uploadProgress)
+ uploadProgress: s.uploadProgress, hasNotch: s.hasNotch)
let radius = (diameter / 0.6) / 2
// botPosition cy is from island TOP; panel AppKit coords have y=0 at bottom
// island top in AppKit coords = panelH (island glued to top of panel/screen)
@@ -757,16 +765,18 @@ final class IslandWindowController: NSWindowController {
NSScreen.screens.first { $0.safeAreaInsets.top > 0 }
}
- static func notchWidth(for screen: NSScreen) -> CGFloat {
- let aux = (screen.auxiliaryTopLeftArea?.width ?? 0) +
- (screen.auxiliaryTopRightArea?.width ?? 0)
- let w = screen.frame.width - aux
- return w > 0 ? w : IslandConst.notchWidth
- }
-
- static func notchHeight(for screen: NSScreen) -> CGFloat {
- let h = screen.safeAreaInsets.top
- return h > 0 ? h : IslandConst.notchHeight
+ static func screenGeometry(for screen: NSScreen) -> IslandScreenGeometry {
+ let visibleMenuBarHeight = screen.frame.maxY - screen.visibleFrame.maxY
+ // visibleFrame includes the menu bar only while it is visible. Keep a
+ // small resting bar when menus auto-hide or the app is in full screen.
+ let menuBarHeight = visibleMenuBarHeight > 0
+ ? visibleMenuBarHeight : NSStatusBar.system.thickness
+ return IslandScreenGeometry(
+ screenWidth: screen.frame.width, safeAreaTop: screen.safeAreaInsets.top,
+ auxiliaryLeftWidth: screen.auxiliaryTopLeftArea?.width,
+ auxiliaryRightWidth: screen.auxiliaryTopRightArea?.width,
+ menuBarHeight: menuBarHeight
+ )
}
nonisolated func cleanup() {
diff --git a/design/captures/no_notch_compact.png b/design/captures/no_notch_compact.png
new file mode 100644
index 00000000..93aff72c
Binary files /dev/null and b/design/captures/no_notch_compact.png differ
diff --git a/design/captures/no_notch_hidden.png b/design/captures/no_notch_hidden.png
new file mode 100644
index 00000000..9988756d
Binary files /dev/null and b/design/captures/no_notch_hidden.png differ
diff --git a/docs/SPEC.md b/docs/SPEC.md
index 8861f672..8dca0adf 100644
--- a/docs/SPEC.md
+++ b/docs/SPEC.md
@@ -11,7 +11,7 @@ Toutes les mesures sont en points macOS. Les valeurs viennent de `reference/notc
- **Clics traversants** : la zone transparente ne doit jamais bloquer les clics. Toggle `ignoresMouseEvents` à 60 Hz selon que `NSEvent.mouseLocation` est dans la forme de l'island (plus 6 pt de marge) ou pas.
- La panel peut devenir key uniquement quand un champ texte de l'island a le focus (prompt, mail). Sinon elle ne vole jamais le focus.
- Détection du notch : `NSScreen.safeAreaInsets.top` > 0 et `auxiliaryTopLeftArea` / `auxiliaryTopRightArea`. Largeur du notch `wN` = largeur écran − les deux zones auxiliaires ; hauteur `hN` = `safeAreaInsets.top`. Le prototype utilise `wN = 184`, `hN = 32` : dans l'app, prendre les vraies valeurs.
-- Pas d'écran avec notch (capot fermé) : afficher sur l'écran principal un faux notch noir de 184 × 24 en haut au centre.
+- Pas d'écran avec notch (Mac de bureau, écran externe ou capot fermé) : afficher sur l'écran principal une barre noire de 80 pt au repos (`hidden`), avec Mochi visible au centre et son animation en pause ; 240 pt en `compact`, en haut au centre. Hauteur plafonnée à 24 pt et à celle de la barre de menus ; personnage et pastilles adaptés à cette hauteur. Le salut se replie vers les dimensions réelles de la barre compacte. La zone de survol au repos ne déborde pas sous la barre. Les vues ouvertes gardent leur largeur de 640 pt.
- Suivi de la souris : polling de `NSEvent.mouseLocation` à chaque frame. Aucune permission nécessaire.
### Forme de l'island
diff --git a/scripts/test-screen-geometry.sh b/scripts/test-screen-geometry.sh
new file mode 100644
index 00000000..4b2b011c
--- /dev/null
+++ b/scripts/test-screen-geometry.sh
@@ -0,0 +1,8 @@
+#!/usr/bin/env bash
+set -euo pipefail
+cd "$(dirname "$0")/.."
+TEST_DIR="$(mktemp -d "${TMPDIR:-/tmp}/coucou-geometry.XXXXXX")"
+trap 'rm -rf "$TEST_DIR"' EXIT
+swiftc NotchBuddy/Sources/App/IslandScreenGeometry.swift \
+ tests/IslandScreenGeometryTests.swift -o "$TEST_DIR/geometry-tests"
+"$TEST_DIR/geometry-tests"
diff --git a/tests/IslandScreenGeometryTests.swift b/tests/IslandScreenGeometryTests.swift
new file mode 100644
index 00000000..79c57f30
--- /dev/null
+++ b/tests/IslandScreenGeometryTests.swift
@@ -0,0 +1,53 @@
+import Foundation
+
+@main
+enum IslandScreenGeometryTests {
+ static func main() {
+ // Regression: absent auxiliary areas must never mean "screen-wide notch".
+ for screenWidth: CGFloat in [1080, 1920, 2560, 3840] {
+ let geometry = IslandScreenGeometry(
+ screenWidth: screenWidth, safeAreaTop: 0,
+ auxiliaryLeftWidth: nil, auxiliaryRightWidth: nil, menuBarHeight: 30
+ )
+ precondition(!geometry.hasNotch)
+ precondition(geometry.width == 80)
+ precondition(geometry.height == 24)
+ }
+
+ // A shorter menu bar must also contain the resting island.
+ let shortMenuBar = IslandScreenGeometry(
+ screenWidth: 1920, safeAreaTop: 0,
+ auxiliaryLeftWidth: nil, auxiliaryRightWidth: nil, menuBarHeight: 22
+ )
+ precondition(shortMenuBar.height == 22)
+
+ // Real MacBook notch measurements retain their physical dimensions.
+ let macBook = IslandScreenGeometry(
+ screenWidth: 1512, safeAreaTop: 32,
+ auxiliaryLeftWidth: 660, auxiliaryRightWidth: 660, menuBarHeight: 32
+ )
+ precondition(macBook.hasNotch)
+ precondition(macBook.width == 192 && macBook.height == 32)
+
+ // Incomplete or invalid measurements use the notch fallback, not the screen.
+ for auxiliaryWidth: CGFloat? in [nil, 0, 1000] {
+ let geometry = IslandScreenGeometry(
+ screenWidth: 1512, safeAreaTop: 32,
+ auxiliaryLeftWidth: auxiliaryWidth, auxiliaryRightWidth: auxiliaryWidth,
+ menuBarHeight: 32
+ )
+ precondition(geometry.width == 184 && geometry.height == 32)
+ }
+ // Compact/greeting destinations share the measured resting height.
+ for height: CGFloat in [22, 24, 32, 38] {
+ let compact = IslandRestingLayout(width: 240, height: height)
+ precondition(compact.botCenterY == height / 2)
+ precondition(compact.botDiameter == min(20, height - 6))
+ precondition(compact.botCenterY - compact.botDiameter / 2 >= 3)
+ precondition(compact.botCenterY + compact.botDiameter / 2 <= height - 3)
+ precondition(compact.miniGridCenterX == 200)
+ precondition(compact.miniGridScale * 28 <= height - 4)
+ }
+ print("Island screen geometry and resting layout: 13 cases passed")
+ }
+}