Merge branch 'fix/pip-edge-and-magnetic-corners' into main
17 files changed,
+814
−112
internal/calls/static/call-layout.js+49 −1internal/calls/static/calls.css+17 −10native/apple/Sources/CallsInterop/BarLayoutHarness.swift+12 −2native/apple/Sources/CallsInterop/Interop.swift+13 −0native/apple/Sources/CallsInterop/StageSnapshots.swift+73 −0native/apple/Sources/CallsKit/CallBarFit.swift+103 −1native/apple/Sources/CallsKit/CallFixtures.swift+2 −0native/apple/Sources/CallsKit/CallsSettingsView.swift+27 −12native/apple/Sources/CallsKit/MacFullWindowCall.swift+47 −20native/apple/Sources/CallsKit/MiniWindow.swift+13 −2native/apple/Sources/CallsKit/MiniWindowRules.swift+111 −45native/apple/Sources/CallsMac/CallsMac.swift+3 −0native/apple/Tests/CallsKitTests/CallBarFitTests.swift+132 −0native/apple/Tests/CallsKitTests/MiniWindowTests.swift+166 −14native/ios/Sources/PhoneFullScreenCall.swift+14 −1native/ios/project.yml+1 −1test/browser/call.mjs+31 −3
CI failed — run details
diff --git a/internal/calls/static/call-layout.js b/internal/calls/static/call-layout.js| index ca1411c..bb10627 100644 |
| --- a/internal/calls/static/call-layout.js |
| +++ b/internal/calls/static/call-layout.js |
| @@ -494,6 +494,7 @@ |
| labelTools(fig, pinned === fig.dataset.tile); |
| } |
| fitGrid(); |
| + clearBar(); |
| if (menuFig) { |
| if (!menuFig.isConnected) closeMenu(false); |
| else { |
| @@ -524,7 +525,53 @@ |
| set('--calls-grid-lift', fit.lastLift + 'px'); |
| all.forEach((fig, i) => fig.toggleAttribute('data-last-row', i >= fit.lastRow)); |
| } |
| - if (stageEl && window.ResizeObserver) new ResizeObserver(() => fitGrid()).observe(stageEl); |
| + if (stageEl && window.ResizeObserver) new ResizeObserver(() => { fitGrid(); clearBar(); }).observe(stageEl); |
| + |
| + // clearBar keeps the bar and a floating self view in a bottom corner |
| + // apart (SelfViewBarLayout in the apps, 2026-10-30: "the |
| + // picture-in-picture is weirdly close to the in-call chrome"). The self |
| + // view stays 16px in from its corner whether the controls show or not, |
| + // and the bar, still centred, narrows to keep 16px from it on both |
| + // sides: data-pip-clear="edge" and --calls-bar-w. Where even the bar's |
| + // least width would not fit there — a narrow window, or the self view |
| + // pushed towards the middle by an open chat — the self view rises 12px |
| + // above the bar while it shows instead: data-pip-clear="rise". A phone's |
| + // bar, a button at each end, always has it rise. |
| + const bar = document.getElementById('controls'); |
| + const phone = window.matchMedia ? matchMedia('(max-width: 599px), (max-height: 499px) and (pointer: coarse)') : null; |
| + function clearBar() { |
| + if (!win || !bar) return; |
| + const pip = tiles.querySelector(':scope > .calls-tile-pip'); |
| + let clear = ''; |
| + let width = ''; |
| + if (pip && corner.startsWith('bottom') && !(phone && phone.matches)) { |
| + const open = expanded && !chat.hidden; |
| + const w = win.clientWidth; |
| + const room = Math.min(760, w - 32, w - 2 * (16 + pip.offsetWidth + 16)); |
| + clear = 'rise'; |
| + if (!(open && corner === 'bottom-right')) { |
| + const was = bar.style.inlineSize; |
| + bar.style.inlineSize = 'min-content'; |
| + const least = bar.getBoundingClientRect().width; |
| + bar.style.inlineSize = was; |
| + if (least <= room) { |
| + clear = 'edge'; |
| + width = Math.floor(room) + 'px'; |
| + } |
| + } |
| + } |
| + if ((win.dataset.pipClear || '') !== clear) { |
| + if (clear) win.dataset.pipClear = clear; |
| + else delete win.dataset.pipClear; |
| + } |
| + if (win.style.getPropertyValue('--calls-bar-w') !== width) { |
| + if (width) win.style.setProperty('--calls-bar-w', width); |
| + else win.style.removeProperty('--calls-bar-w'); |
| + } |
| + } |
| + if (phone && phone.addEventListener) phone.addEventListener('change', clearBar); |
| + // A button the bar reveals later (Devices, Chat) changes its least width. |
| + if (bar) new MutationObserver(clearBar).observe(bar, { subtree: true, attributes: true, attributeFilter: ['hidden'] }); |
| // ---- pointer drag ---- |
| @@ -673,6 +720,7 @@ |
| : ''; |
| if (unreadLive.textContent !== said) unreadLive.textContent = said; |
| } |
| + clearBar(); |
| } |
| speakerButton.addEventListener('click', () => { setMode('speaker'); layout(); }); |
| gridButton.addEventListener('click', () => { setMode('grid'); layout(); }); |
diff --git a/internal/calls/static/calls.css b/internal/calls/static/calls.css| index 14b6b3d..594d00e 100644 |
| --- a/internal/calls/static/calls.css |
| +++ b/internal/calls/static/calls.css |
| @@ -766,12 +766,18 @@ body:has(> .calls-window) { background: var(--rst-bg); } |
| } |
| /* The self view, floating (Stage.selfFloats): about a fifth of the |
| - window's width, 150 to 260px at 16:9, 12px in from the corner it was |
| - put in (call-layout.js's data-corner), kept clear of the bar while it |
| - shows, of the title in the top left, and of an open chat. Dragged, it |
| + window's width, 150 to 260px at 16:9, 16px in from the corner it was |
| + put in (call-layout.js's data-corner), clear of the title in the top |
| + left and of an open chat. In a bottom corner it stays put whether the |
| + controls show or not, and the bar narrows to keep clear of it |
| + (data-pip-clear="edge", call-layout.js's clearBar); only where the |
| + bar could not fit beside it does it rise, 12px above the bar, while |
| + the bar shows (2026-10-30, SelfViewBarLayout in the apps). Dragged, it |
| follows the pointer and settles in the corner it was headed for. */ |
| +.calls-window[data-chrome='shown']:not([data-pip-clear='edge']) { --calls-pip-rise: calc(var(--calls-bar-reserve) - 4px); } |
| +.calls-window[data-pip-clear='edge'] #controls { inline-size: var(--calls-bar-w); } |
| .calls-window #tiles > .calls-tile-pip { |
| - --calls-pip-top: calc(12px + var(--calls-title-h) * var(--calls-title-on, 0) + 4px * var(--calls-title-on, 0)); |
| + --calls-pip-top: calc(16px + var(--calls-title-h) * var(--calls-title-on, 0)); |
| position: absolute; |
| z-index: 2; |
| inline-size: clamp(150px, 20cqw, 260px); |
| @@ -779,16 +785,16 @@ body:has(> .calls-window) { background: var(--rst-bg); } |
| aspect-ratio: 16 / 9; |
| border-radius: 10px; |
| box-shadow: 0 3px 16px rgb(0 0 0 / 0.35); |
| - inset: auto 12px calc(12px + max(0px, var(--calls-lift) - 4px)) auto; |
| + inset: auto 16px calc(16px + var(--calls-pip-rise, 0px)) auto; |
| cursor: grab; |
| transition: inset 0.2s ease-out, translate 0s; |
| } |
| .calls-window[data-chrome='shown'] #tiles > .calls-tile-pip { --calls-title-on: 1; } |
| -.calls-window #tiles[data-corner='top-left'] > .calls-tile-pip { inset: var(--calls-pip-top) auto auto 12px; } |
| -.calls-window #tiles[data-corner='top-right'] > .calls-tile-pip { inset: 12px 12px auto auto; } |
| -.calls-window #tiles[data-corner='bottom-left'] > .calls-tile-pip { inset: auto auto calc(12px + max(0px, var(--calls-lift) - 4px)) 12px; } |
| +.calls-window #tiles[data-corner='top-left'] > .calls-tile-pip { inset: var(--calls-pip-top) auto auto 16px; } |
| +.calls-window #tiles[data-corner='top-right'] > .calls-tile-pip { inset: 16px 16px auto auto; } |
| +.calls-window #tiles[data-corner='bottom-left'] > .calls-tile-pip { inset: auto auto calc(16px + var(--calls-pip-rise, 0px)) 16px; } |
| .calls-window:has(.calls-chat-overlay:not([hidden])) #tiles:not([data-corner='top-left'], [data-corner='bottom-left']) > .calls-tile-pip { |
| - inset-inline-end: calc(12px + min(320px, 100cqw - 24px) + 12px); |
| + inset-inline-end: calc(12px + min(320px, 100cqw - 24px) + 16px); |
| } |
| /* An upright camera (a phone held upright, yours) floats upright: 9:16, |
| 1.6 times as tall as a landscape self view (the filmstrip's height), |
| @@ -1414,7 +1420,8 @@ body:has(> .calls-window) { background: var(--rst-bg); } |
| .calls-chat-overlay { |
| position: absolute; |
| z-index: 5; |
| - inset-block: 12px calc(var(--calls-bar-reserve) + 8px); |
| + /* 12px clear of the bar, level with a self view risen beside it. */ |
| + inset-block: 12px calc(var(--calls-bar-reserve) + 12px); |
| inset-inline-end: 12px; |
| inline-size: min(320px, calc(100% - 24px)); |
| display: flex; |
diff --git a/native/apple/Sources/CallsInterop/BarLayoutHarness.swift b/native/apple/Sources/CallsInterop/BarLayoutHarness.swift| index 45db033..16bb8a4 100644 |
| --- a/native/apple/Sources/CallsInterop/BarLayoutHarness.swift |
| +++ b/native/apple/Sources/CallsInterop/BarLayoutHarness.swift |
| @@ -9,8 +9,8 @@ import SwiftUI |
| /// sizes by resizing the one window live, as a person dragging its edge |
| /// does, and set below the minimum the way only the system can (tiling, |
| /// a display change). At each size the bar must be whole inside the |
| -/// window, centred on it, and its buttons inside the bar. A snapshot of |
| -/// each goes to the folder. |
| +/// window, centred on it, and its buttons inside the bar, and a floating |
| +/// self view at least 12 pt from it. A snapshot of each goes to the folder. |
| @MainActor enum BarLayoutHarness { |
| struct Step { |
| var name: String |
| @@ -96,6 +96,16 @@ import SwiftUI |
| let off = abs(pane.midX - width / 2) |
| if off > 1 { problems.append("bar off centre by \(fmt(off)) (bar \(fmt(pane)), window \(fmt(width)))") } |
| if pane.width < 1 { problems.append("bar not laid out") } |
| + // The floating self view (2026-10-30): never within 12 pt of the |
| + // bar, at any size (SelfViewBarLayout). |
| + let selfView = CallBarProbe.selfView |
| + if selfView.width > 1 { |
| + let dx = max(selfView.minX - pane.maxX, pane.minX - selfView.maxX, 0) |
| + let dy = max(selfView.minY - pane.maxY, pane.minY - selfView.maxY, 0) |
| + if max(dx, dy) < 12 - 0.5 { |
| + problems.append("self view \(fmt(selfView)) within \(fmt(max(dx, dy))) pt of the bar \(fmt(pane))") |
| + } |
| + } |
| let line = "\(name): window \(fmt(width)) bar \(fmt(pane)) buttons \(fmt(row))" |
| print(problems.isEmpty ? "ok \(line)" : "FAIL \(line): \(problems.joined(separator: "; "))") |
| failures += problems.map { "\(name): \($0)" } |
diff --git a/native/apple/Sources/CallsInterop/Interop.swift b/native/apple/Sources/CallsInterop/Interop.swift| index 9b12746..83d02d1 100644 |
| --- a/native/apple/Sources/CallsInterop/Interop.swift |
| +++ b/native/apple/Sources/CallsInterop/Interop.swift |
| @@ -83,6 +83,19 @@ struct Input: Decodable { |
| } catch { exit(1) } |
| return |
| } |
| + if CommandLine.arguments.count == 4, CommandLine.arguments[1] == "--pip-snapshots" { |
| + do { |
| + try await PiPSnapshots.save( |
| + to: URL(fileURLWithPath: CommandLine.arguments[2]), tag: CommandLine.arguments[3]) |
| + } catch { exit(1) } |
| + return |
| + } |
| + if CommandLine.arguments.count == 3, CommandLine.arguments[1] == "--settings-snapshots" { |
| + do { |
| + try await SettingsSnapshots.save(to: URL(fileURLWithPath: CommandLine.arguments[2])) |
| + } catch { exit(1) } |
| + return |
| + } |
| if CommandLine.arguments.count == 3, CommandLine.arguments[1] == "--bar-layout" { |
| exit(await BarLayoutHarness.run(to: URL(fileURLWithPath: CommandLine.arguments[2])) ? 0 : 1) |
| } |
diff --git a/native/apple/Sources/CallsInterop/StageSnapshots.swift b/native/apple/Sources/CallsInterop/StageSnapshots.swift| index bbf2c38..c8c5119 100644 |
| --- a/native/apple/Sources/CallsInterop/StageSnapshots.swift |
| +++ b/native/apple/Sources/CallsInterop/StageSnapshots.swift |
| @@ -119,3 +119,76 @@ import SwiftUI |
| } |
| } |
| } |
| + |
| +/// The floating self view against the control bar (2026-10-30, Paul on |
| +/// 0.4.15: "The picture-in-picture is weirdly close to the in-call |
| +/// chrome"): a call of two, and a call of one waiting for others, with the |
| +/// controls shown and hidden, at the smallest window and a large one, in |
| +/// the bottom right and the bottom left, and beside an open chat. Run once |
| +/// on the code before a change and once after, with `tag` naming which. |
| +@MainActor enum PiPSnapshots { |
| + static func save(to folder: URL, tag: String) async throws { |
| + NSApplication.shared.setActivationPolicy(.prohibited) |
| + try FileManager.default.createDirectory(at: folder, withIntermediateDirectories: true) |
| + let suite = "CallsInterop.PiPSnapshots" |
| + guard let defaults = UserDefaults(suiteName: suite) else { return } |
| + defaults.removePersistentDomain(forName: suite) |
| + defer { defaults.removePersistentDomain(forName: suite) } |
| + func shot( |
| + _ name: String, _ fixture: CallFixture = .focus, corner: PiPCorner = .bottomTrailing, |
| + chat: Bool = false, shown: Bool, size: CGSize |
| + ) async throws { |
| + defaults.set(corner.rawValue, forKey: PiPCorner.key) |
| + let file = folder.appendingPathComponent( |
| + "pip-\(name)-\(Int(size.width))x\(Int(size.height))-\(shown ? "shown" : "hidden")-\(tag).png") |
| + let call = Call(playAudio: false) |
| + fixture.apply(to: call) |
| + call.levels.speaker.showFixture(fixture == .alone ? nil : "ana") |
| + try await LobbySnapshots.render( |
| + MacCallView( |
| + call: call, grid: false, showingChat: chat, style: .fullWindow, controlsShown: shown, |
| + leave: {}, rejoin: {} |
| + ) |
| + .tint(CallsAppearance.accent) |
| + .environment(\.fixtureStagePicture, .busy) |
| + .defaultAppStorage(defaults), |
| + scheme: .dark, size: size, to: file) |
| + // Off screen there is no glass, so the pane is outlined where it |
| + // laid out: what the self view is kept clear of. |
| + if shown { outline(CallBarProbe.pane, in: file, size: size) } |
| + } |
| + for size in [CGSize(width: 760, height: 540), CGSize(width: 1440, height: 900)] { |
| + for shown in [true, false] { |
| + try await shot("two-bottom-right", shown: shown, size: size) |
| + try await shot("alone-bottom-right", .alone, shown: shown, size: size) |
| + try await shot("two-bottom-left", corner: .bottomLeading, shown: shown, size: size) |
| + } |
| + try await shot("two-chat", chat: true, shown: true, size: size) |
| + } |
| + } |
| + |
| + /// Strokes `rect` (top-left origin, points) as a capsule onto the PNG |
| + /// at `file`, drawn for a view `size` points large. |
| + private static func outline(_ rect: CGRect, in file: URL, size: CGSize) { |
| + guard rect.width > 1, let image = NSImage(contentsOf: file), |
| + let rep = image.representations.first as? NSBitmapImageRep ?? NSBitmapImageRep( |
| + data: image.tiffRepresentation ?? Data()), |
| + let context = NSGraphicsContext(bitmapImageRep: rep) |
| + else { return } |
| + let scale = CGFloat(rep.pixelsWide) / size.width |
| + NSGraphicsContext.saveGraphicsState() |
| + NSGraphicsContext.current = context |
| + let flipped = CGRect( |
| + x: rect.minX * scale, y: (size.height - rect.maxY) * scale, width: rect.width * scale, |
| + height: rect.height * scale) |
| + let path = NSBezierPath( |
| + roundedRect: flipped, xRadius: flipped.height / 2, yRadius: flipped.height / 2) |
| + NSColor(white: 1, alpha: 0.08).setFill() |
| + path.fill() |
| + NSColor(white: 1, alpha: 0.45).setStroke() |
| + path.lineWidth = 1.5 * scale |
| + path.stroke() |
| + NSGraphicsContext.restoreGraphicsState() |
| + try? rep.representation(using: .png, properties: [:])?.write(to: file) |
| + } |
| +} |
diff --git a/native/apple/Sources/CallsKit/CallBarFit.swift b/native/apple/Sources/CallsKit/CallBarFit.swift| index 345900b..47e5763 100644 |
| --- a/native/apple/Sources/CallsKit/CallBarFit.swift |
| +++ b/native/apple/Sources/CallsKit/CallBarFit.swift |
| @@ -45,7 +45,14 @@ public struct CallBarFit: Equatable, Sendable { |
| /// The bar for a window `windowWidth` wide showing `controls` (Share |
| /// meeting link is only there for a member; Video layout only here). |
| public static func fit(windowWidth: CGFloat, controls: [Control]) -> CallBarFit { |
| - let room = max(0, windowWidth - 2 * margin) |
| + fit(room: max(0, windowWidth - 2 * margin), controls: controls) |
| + } |
| + |
| + /// The bar for `room` points of width, centred in it: the window's less |
| + /// its margins, or less what a self view in a bottom corner keeps clear |
| + /// (SelfViewBarLayout). |
| + public static func fit(room: CGFloat, controls: [Control]) -> CallBarFit { |
| + let room = max(0, room) |
| for spacing in [roomy, snug, tight] where needed(controls, spacing, more: false) <= room { |
| return CallBarFit(spacing: spacing, overflow: [], width: min(maxWidth, room)) |
| } |
| @@ -70,4 +77,99 @@ public struct CallBarFit: Equatable, Sendable { |
| } |
| public func shows(_ control: Control) -> Bool { !overflow.contains(control) } |
| + |
| + /// The pane's height: a button and the padding above and below it. |
| + public var height: CGFloat { Self.button + 2 * spacing.padding } |
| + |
| + /// Whether `room` holds the bar at its least: the essentials and ⋯, |
| + /// tight. Narrower than that and something would be cut off. |
| + public static func holds(_ room: CGFloat, controls: [Control]) -> Bool { |
| + let essentials = controls.filter(\.essential) |
| + return needed(essentials, tight, more: essentials.count < controls.count) <= room |
| + } |
| +} |
| + |
| +/// The floating self view and the full-window bar, placed together |
| +/// (2026-10-30, Paul on 0.4.15: "The picture-in-picture is weirdly close |
| +/// to the in-call chrome … Should the picture in picture just stay close |
| +/// to the edge of the screen from the start?"). |
| +/// |
| +/// Until 0.4.15 the self view rose above the bar whenever the controls |
| +/// showed, and settled back when they went: a few points above a bar |
| +/// that ran on underneath it, and moving every time the pointer did. Now |
| +/// it stays put, `edge` in from the window's edges in whichever corner it |
| +/// was put, and the bar makes room instead: still centred on the window, |
| +/// it narrows to keep `clearance` from a self view in a bottom corner on |
| +/// both sides — the side the self view is on, and, to stay centred, the |
| +/// other — moving the least used controls into ⋯ as it does for a narrow |
| +/// window (CallBarFit). Centred and narrower rather than shifted aside, |
| +/// because a bar that slides off centre as the self view crosses from |
| +/// one corner to another reads as a bar that moved; and the room is |
| +/// there at every size the window allows (at its 760 × 540 least the bar |
| +/// has 392 pt, which holds everything but a member's Video layout and |
| +/// Share meeting link, which go into ⋯). |
| +/// |
| +/// Only where even the essentials would not fit beside it does the self |
| +/// view rise, `rise` above the bar, while the bar shows: a window the |
| +/// system made narrower than the app allows, or the self view pushed |
| +/// towards the middle by an open chat — which holds the controls up, so |
| +/// there it sits level with the chat's own bottom edge, and stays. |
| +public struct SelfViewBarLayout: Equatable, Sendable { |
| + /// The self view's distance from the window's edges, as the bar's |
| + /// margin and the devices panel's. |
| + public static let edge: CGFloat = 16 |
| + /// The gap between the bar and a self view beside it: the window's |
| + /// own margin again, so the edges, the bar and the self view are |
| + /// spaced by one measure (Paul asked for at least 12). |
| + public static let clearance: CGFloat = 16 |
| + /// The gap between the bar and a self view that has to rise above it, |
| + /// and an open panel's: 12, as the panels have always kept. |
| + public static let rise: CGFloat = 12 |
| + |
| + public var bar: CallBarFit |
| + /// Where the self view is while the bar is hidden. |
| + public var resting: CGRect |
| + /// Where it is while the bar shows: `resting`, unless it has to rise. |
| + public var raised: CGRect |
| + |
| + public var rises: Bool { resting != raised } |
| + public func selfView(barShown: Bool) -> CGRect { barShown ? raised : resting } |
| + |
| + /// - Parameters: |
| + /// - window: the call's size. |
| + /// - selfView: the floating self view's size; nil when nobody floats |
| + /// (Grid, or a filmstrip you are in), and the bar is the window's. |
| + /// - corner: the corner it was put in. |
| + /// - top: what the top of the window keeps clear (the title strip). |
| + /// - trailing: what the right of the window keeps clear (an open chat). |
| + /// - controls: the bar's controls. |
| + public static func layout( |
| + window: CGSize, selfView size: CGSize?, corner: PiPCorner, top: CGFloat = 0, |
| + trailing: CGFloat = 0, controls: [CallBarFit.Control] |
| + ) -> SelfViewBarLayout { |
| + let whole = CallBarFit.fit(windowWidth: window.width, controls: controls) |
| + guard let size else { return SelfViewBarLayout(bar: whole, resting: .zero, raised: .zero) } |
| + let x = corner.leading ? edge : window.width - trailing - edge - size.width |
| + let y = corner.top ? top + edge : window.height - edge - size.height |
| + // A window too small for it still keeps the view on it. |
| + let resting = CGRect( |
| + x: min(max(x, 0), max(window.width - size.width, 0)), |
| + y: min(max(y, 0), max(window.height - size.height, 0)), |
| + width: size.width, height: size.height) |
| + guard !corner.top else { return SelfViewBarLayout(bar: whole, resting: resting, raised: resting) } |
| + let half = |
| + corner.leading |
| + ? window.width / 2 - resting.maxX - clearance |
| + : resting.minX - clearance - window.width / 2 |
| + let room = min(window.width - 2 * CallBarFit.margin, 2 * half) |
| + let beside = corner.leading || trailing == 0 |
| + if beside, CallBarFit.holds(room, controls: controls) { |
| + return SelfViewBarLayout( |
| + bar: CallBarFit.fit(room: room, controls: controls), resting: resting, raised: resting) |
| + } |
| + let barTop = window.height - CallBarFit.margin - whole.height |
| + var raised = resting |
| + raised.origin.y = max(0, barTop - rise - size.height) |
| + return SelfViewBarLayout(bar: whole, resting: resting, raised: raised) |
| + } |
| } |
diff --git a/native/apple/Sources/CallsKit/CallFixtures.swift b/native/apple/Sources/CallsKit/CallFixtures.swift| index 83375a8..7b5ff6d 100644 |
| --- a/native/apple/Sources/CallsKit/CallFixtures.swift |
| +++ b/native/apple/Sources/CallsKit/CallFixtures.swift |
| @@ -373,6 +373,8 @@ private struct FixturePerson: View { |
| public static var first: CGRect = .zero |
| public static var last: CGRect = .zero |
| public static var row: CGRect { first.union(last) } |
| + /// The floating self view, or zero when nobody floats. |
| + public static var selfView: CGRect = .zero |
| } |
| /// Records a bar button's frame for CallBarProbe; nothing else reads it. |
diff --git a/native/apple/Sources/CallsKit/CallsSettingsView.swift b/native/apple/Sources/CallsKit/CallsSettingsView.swift| index 93482af..c90b3a3 100644 |
| --- a/native/apple/Sources/CallsKit/CallsSettingsView.swift |
| +++ b/native/apple/Sources/CallsKit/CallsSettingsView.swift |
| @@ -9,12 +9,17 @@ |
| MiniWindowPreferences.defaultEnabled |
| @AppStorage(MiniWindowPreferences.cornerKey) private var corner = |
| MiniWindowPreferences.defaultCorner |
| - @AppStorage(MiniWindowPreferences.placementKey) private var placement = |
| - MiniWindowPreferences.defaultPlacement |
| + @AppStorage(MiniWindowPreferences.moveFreelyKey) private var moveFreely = |
| + MiniWindowPreferences.defaultMoveFreely |
| + @AppStorage(MiniWindowPreferences.snapToCornersKey) private var snapToCorners = |
| + MiniWindowPreferences.defaultSnapToCorners |
| @AppStorage(MiniWindowPreferences.positionsKey) private var positions: String? |
| @AppStorage(CallLayoutStyle.key) private var callLayout = CallLayoutStyle.defaultStyle |
| - public init(model: CallsModel) { self.model = model } |
| + public init(model: CallsModel) { |
| + self.model = model |
| + MiniWindowPreferences.migrate(.standard) |
| + } |
| public var body: some View { |
| Form { |
| @@ -38,10 +43,18 @@ |
| "During a call, a small window of the call stays on top of other apps. The full call returns when you come back to Calls." |
| ) |
| } |
| - Picker(selection: $placement) { |
| - ForEach(MiniWindowPlacement.allCases) { placement in |
| - Text(placement.title).tag(placement) |
| + // Two switches, never both off (MiniWindowPreferences): the one |
| + // still on cannot be turned off until the other is back on. |
| + LabeledContent { |
| + VStack(alignment: .leading, spacing: 6) { |
| + Toggle("Move freely", isOn: $moveFreely) |
| + .disabled(moveFreely && !snapToCorners) |
| + .accessibilityIdentifier("miniWindowMoveFreely") |
| + Toggle("Snap to corners", isOn: $snapToCorners) |
| + .disabled(snapToCorners && !moveFreely) |
| + .accessibilityIdentifier("miniWindowSnapToCorners") |
| } |
| + .toggleStyle(.checkbox) |
| } label: { |
| Text("Mini window placement") |
| Text(placementNote) |
| @@ -54,9 +67,9 @@ |
| } label: { |
| Text("Mini window position") |
| Text( |
| - placement == .corners |
| - ? "You can also drag the mini window to another corner, and resize it from its edges." |
| - : "Where it starts. Choosing a corner here moves it back into that corner." |
| + moveFreely |
| + ? "Where it starts. Choosing a corner here moves it back into that corner." |
| + : "You can also drag the mini window to another corner, and resize it from its edges." |
| ) |
| } |
| .disabled(!miniWindow) |
| @@ -100,10 +113,12 @@ |
| } |
| private var placementNote: String { |
| - switch placement { |
| - case .corners: |
| + switch (moveFreely, snapToCorners) { |
| + case (true, true): |
| + "The mini window stays where you leave it, and snaps into a corner when you let go near one. Hold ⌥ Option while dragging to place it exactly, without snapping." |
| + case (false, _): |
| "A dragged mini window settles in the nearest corner. Hold ⌥ Option while dragging to leave it exactly where you drop it, for this call." |
| - case .anywhere: |
| + case (true, false): |
| "The mini window stays exactly where you leave it, remembered for each display." |
| } |
| } |
diff --git a/native/apple/Sources/CallsKit/MacFullWindowCall.swift b/native/apple/Sources/CallsKit/MacFullWindowCall.swift| index 03a0f9d..f05ea97 100644 |
| --- a/native/apple/Sources/CallsKit/MacFullWindowCall.swift |
| +++ b/native/apple/Sources/CallsKit/MacFullWindowCall.swift |
| @@ -19,8 +19,10 @@ |
| extension MacCallView { |
| /// Room kept clear at the top for the title bar's traffic lights. |
| static let titleBarHeight: CGFloat = 32 |
| - /// Height of the floating bar with its margin below: what the self |
| - /// view and a tile's name move up by while the bar shows. |
| + /// Height of the floating bar with its margin below: what the |
| + /// filmstrip and a tile's name move up by while the bar shows. The |
| + /// floating self view stays put and the bar makes room for it instead |
| + /// (SelfViewBarLayout). |
| static let barReserve: CGFloat = 44 + 20 + 16 |
| static let panelWidth: CGFloat = 320 |
| static let tileBackdrop = Color(white: 0.13) |
| @@ -153,7 +155,7 @@ |
| let strip = selfFloats ? [] : filmstrip |
| let thumb = Self.filmstripTile(in: size) |
| let band = strip.isEmpty ? 0 : thumb.height + 2 * Self.filmstripPadding |
| - let stageLift = StageLabel.lift(bar: lift, band: band) |
| + let stageLift = max(StageLabel.lift(bar: lift, band: band), selfClearance(in: size)) |
| return ZStack(alignment: .bottom) { |
| Group { |
| if let focused { |
| @@ -186,6 +188,14 @@ |
| } |
| } |
| + /// How far the stage's name rises to sit 8 pt above a self view in |
| + /// the bottom left, where it would otherwise be under it; 0 anywhere |
| + /// else. (The name is 8 pt in from the stage's bottom left.) |
| + private func selfClearance(in size: CGSize) -> CGFloat { |
| + guard !grid, selfFloats, PiPCorner(rawValue: pipCorner) == .bottomLeading else { return 0 } |
| + return size.height - selfBarLayout(in: size).selfView(barShown: chrome.visible).minY |
| + } |
| + |
| /// Room above and below the filmstrip's tiles. |
| static let filmstripPadding: CGFloat = 8 |
| @@ -263,13 +273,13 @@ |
| // MARK: Self view |
| /// You, small and floating: dragged anywhere, settling in the nearest |
| - /// corner, kept clear of the bar while it shows and of an open chat. |
| - /// Muted shows on it whether or not the controls do. |
| + /// corner, 16 pt in from the window's edges and staying there whether |
| + /// the controls show or not — the bar keeps clear of you |
| + /// (SelfViewBarLayout) — and clear of an open chat. Muted shows on it |
| + /// whether or not the controls do. |
| private func selfView(in size: CGSize) -> some View { |
| - let corner = PiPCorner(rawValue: pipCorner) ?? .bottomTrailing |
| - let pip = PiPLayout.size( |
| - in: size, touch: false, shape: selfShape ?? fixtureFeeds["me"].map(VideoShape.of)) |
| - let frame = PiPLayout.frame(corner: corner, size: pip, in: size, insets: selfInsets(in: size)) |
| + let pip = selfViewSize(in: size) |
| + let frame = selfBarLayout(in: size).selfView(barShown: chrome.visible) |
| return MacVideoTile( |
| track: call.localTrack, label: "You", muted: call.muted, mirrored: true, |
| cameraOff: call.cameraOff, placeholder: call.selfPlaceholder, cornerRadius: 10, |
| @@ -278,6 +288,14 @@ |
| ) |
| .frame(width: pip.width, height: pip.height) |
| .shadow(color: .black.opacity(0.35), radius: 8, y: 3) |
| + .background( |
| + GeometryReader { tile in |
| + Color.clear |
| + .onAppear { CallBarProbe.selfView = tile.frame(in: .global) } |
| + .onChange(of: tile.frame(in: .global)) { _, now in CallBarProbe.selfView = now } |
| + } |
| + ) |
| + .onDisappear { CallBarProbe.selfView = .zero } |
| .position(x: frame.midX + pipDrag.width, y: frame.midY + pipDrag.height) |
| .gesture( |
| DragGesture() |
| @@ -302,14 +320,20 @@ |
| } |
| } |
| - private func selfInsets(in size: CGSize) -> EdgeInsets { |
| - var trailing: CGFloat = 0 |
| - if showingChat { trailing += Self.panelWidth + 12 } |
| - // The title bar's strip, with the traffic lights and any title in |
| - // it, is the only thing at the top: a self view goes below it. |
| - return EdgeInsets( |
| - top: Self.titleBarHeight, leading: 0, |
| - bottom: chrome.visible ? Self.barReserve - 12 : 0, trailing: trailing) |
| + private func selfViewSize(in size: CGSize) -> CGSize { |
| + PiPLayout.size(in: size, touch: false, shape: selfShape ?? fixtureFeeds["me"].map(VideoShape.of)) |
| + } |
| + |
| + /// The bar and the floating self view, placed together: the bar |
| + /// keeps clear of you rather than you of it. The title bar's strip, |
| + /// with the traffic lights and any title in it, is the only thing at |
| + /// the top, so a self view goes below it; an open chat keeps it to |
| + /// the chat's left. |
| + func selfBarLayout(in size: CGSize) -> SelfViewBarLayout { |
| + SelfViewBarLayout.layout( |
| + window: size, selfView: !grid && selfFloats ? selfViewSize(in: size) : nil, |
| + corner: PiPCorner(rawValue: pipCorner) ?? .bottomTrailing, top: Self.titleBarHeight, |
| + trailing: showingChat ? Self.panelWidth + 12 : 0, controls: barControls) |
| } |
| // MARK: Title and notices |
| @@ -419,7 +443,8 @@ |
| let top = Self.titleBarHeight + 8 |
| // Below the title, which shows while a panel is open. |
| let devicesTop = Self.titleBarHeight + 40 |
| - let bottom = Self.barReserve + 8 |
| + // 12 pt clear of the bar, level with a self view risen beside chat. |
| + let bottom = Self.barReserve + SelfViewBarLayout.rise |
| if showingDevices { |
| VStack(spacing: 0) { |
| HStack { |
| @@ -493,9 +518,11 @@ |
| /// The bar: centred on the window and whole at every width |
| /// (CallBarFit), its width set from the window's rather than left to |
| /// whatever its row asks for — tightening, then moving the least used |
| - /// controls into ⋯, before anything could reach past an edge. |
| + /// controls into ⋯, before anything could reach past an edge — and |
| + /// narrowed to keep clear of a self view resting in a bottom corner |
| + /// (SelfViewBarLayout). |
| private func bar(in size: CGSize) -> some View { |
| - let fit = CallBarFit.fit(windowWidth: size.width, controls: barControls) |
| + let fit = selfBarLayout(in: size).bar |
| return controls(fullWindow: true, fit: fit) |
| .padding(fit.spacing.padding) |
| .frame(width: fit.width) |
diff --git a/native/apple/Sources/CallsKit/MiniWindow.swift b/native/apple/Sources/CallsKit/MiniWindow.swift| index 2ff455c..6e6bad6 100644 |
| --- a/native/apple/Sources/CallsKit/MiniWindow.swift |
| +++ b/native/apple/Sources/CallsKit/MiniWindow.swift |
| @@ -236,7 +236,7 @@ |
| let frame = memory.dropped( |
| panel.frame, in: screen.visibleFrame, display: screen.callsDisplayKey, option: option, |
| preferences: preferences) |
| - panel.expand(to: frame, animated: frame != panel.frame) |
| + settle(panel, at: frame, in: screen.visibleFrame) |
| } |
| private func resized() { |
| @@ -245,7 +245,18 @@ |
| let frame = memory.resized( |
| panel.frame, in: screen.visibleFrame, display: screen.callsDisplayKey, |
| preferences: preferences) |
| - panel.expand(to: frame, animated: frame != panel.frame) |
| + settle(panel, at: frame, in: screen.visibleFrame) |
| + } |
| + |
| + /// Slides the window to where it settles, over 0.2 s (none with |
| + /// Reduce Motion), and when a corner took it, a tick on a Force Touch |
| + /// trackpad: the feel of a magnet catching. |
| + private func settle(_ panel: MiniWindowPanel, at frame: CGRect, in visible: CGRect) { |
| + let moved = frame != panel.frame |
| + if moved, MiniWindowCorner.allCases.contains(where: { $0.frame(size: frame.size, in: visible) == frame }) { |
| + NSHapticFeedbackManager.defaultPerformer.perform(.alignment, performanceTime: .now) |
| + } |
| + panel.expand(to: frame, animated: moved) |
| } |
| private func collapse() { |
diff --git a/native/apple/Sources/CallsKit/MiniWindowRules.swift b/native/apple/Sources/CallsKit/MiniWindowRules.swift| index 2e421b3..29e8fb6 100644 |
| --- a/native/apple/Sources/CallsKit/MiniWindowRules.swift |
| +++ b/native/apple/Sources/CallsKit/MiniWindowRules.swift |
| @@ -2,10 +2,10 @@ |
| import CoreGraphics |
| import Foundation |
| - /// Where the mini window sits on screen. Four corners and nothing in |
| - /// between, like FaceTime's and iOS's picture in picture: a window that |
| - /// can rest anywhere ends up resting over whatever you were about to |
| - /// click, and a corner is a place you can find again without looking. |
| + /// Where the mini window sits on screen. A corner by default, like |
| + /// FaceTime's and iOS's picture in picture: a corner is a place you can |
| + /// find again without looking. Since 2026-10-30 it may also rest |
| + /// anywhere it is put, with the corners magnetic (MiniWindowPreferences). |
| public enum MiniWindowCorner: String, CaseIterable, Identifiable, Sendable { |
| case bottomRight, bottomLeft, topRight, topLeft |
| @@ -35,6 +35,20 @@ |
| width: size.width, height: size.height) |
| } |
| + /// The corner a magnet pulls `frame` into: the one whose snapped frame |
| + /// is within `distance` of it (between top-left origins, so in a |
| + /// corner's own terms how far the window is from sitting in it), the |
| + /// nearest if two are; nil in the open, where it stays put. |
| + public static func magnet( |
| + for frame: CGRect, in visible: CGRect, distance: CGFloat = MiniWindowRules.snapDistance |
| + ) -> MiniWindowCorner? { |
| + let away = allCases.map { corner -> (MiniWindowCorner, CGFloat) in |
| + let snapped = corner.frame(size: frame.size, in: visible) |
| + return (corner, hypot(snapped.minX - frame.minX, snapped.minY - frame.minY)) |
| + } |
| + return away.filter { $0.1 <= distance }.min { $0.1 < $1.1 }?.0 |
| + } |
| + |
| /// The corner a dragged window belongs to: whichever side of the |
| /// screen's middle its own middle landed on. |
| public static func nearest(to frame: CGRect, in visible: CGRect) -> MiniWindowCorner { |
| @@ -49,29 +63,20 @@ |
| } |
| } |
| - /// Whether a dragged mini window settles in a corner or stays where it |
| - /// was dropped. Corners by default, for the reason MiniWindowCorner |
| - /// gives; "anywhere" is for the person who knows which part of their |
| - /// screen they never look at. |
| - public enum MiniWindowPlacement: String, CaseIterable, Identifiable, Sendable { |
| - case corners, anywhere |
| - |
| - public var id: String { rawValue } |
| - |
| - public var title: String { |
| - switch self { |
| - case .corners: "Snap to corners" |
| - case .anywhere: "Anywhere I put it" |
| - } |
| - } |
| - } |
| - |
| public enum MiniWindowRules { |
| /// 16:9 at the width of a small picture in picture: big enough to |
| /// read a face, small enough to leave the app you went to usable. |
| /// The size it opens at until someone resizes it. |
| public static let size = CGSize(width: 320, height: 180) |
| public static let inset: CGFloat = 20 |
| + /// How near its snapped place a window let go has to be for a |
| + /// magnetic corner to take it, with "Move freely" and "Snap to |
| + /// corners" both on: 96 pt, a fixed distance of the pointer's travel |
| + /// rather than a share of the window, so the target is the same |
| + /// whatever size the window has been made — about a third of the |
| + /// default window's width, half the smallest's, and well short of the |
| + /// middle of any screen, where a window is clearly meant to stay put. |
| + public static let snapDistance: CGFloat = 96 |
| public static let aspect: CGFloat = 16 / 9 |
| /// Narrower than this and Mute, Leave and Collapse no longer fit |
| /// across the top. |
| @@ -276,24 +281,56 @@ |
| } |
| } |
| - /// The two preferences, read and written in one place so the Settings |
| + /// The preferences, read and written in one place so the Settings |
| /// window and the mini window cannot disagree about a key or a default. |
| /// |
| /// On by default, because the person who asked for it switches apps |
| /// during most calls, and a setting nobody knows about that is off is a |
| /// feature that does not exist. |
| + /// |
| + /// Placement is two switches, both on by default (2026-10-30, Paul: |
| + /// "That way I can pull the mini window from the corner if I want, but |
| + /// easily snap it back"): "Move freely" leaves a dragged window where it |
| + /// is dropped; "Snap to corners" takes it into a corner. Both on, it |
| + /// rests anywhere and a corner pulls it in when it is let go near one |
| + /// (MiniWindowRules.snapDistance). Snapping alone is the old "Snap to |
| + /// corners", always into the nearest; moving alone, the old "Anywhere I |
| + /// put it". Never both off: there would be nowhere for it to go. |
| public struct MiniWindowPreferences { |
| public static let enabledKey = "miniWindow.enabled" |
| public static let cornerKey = "miniWindow.corner" |
| - public static let placementKey = "miniWindow.placement" |
| + public static let moveFreelyKey = "miniWindow.moveFreely" |
| + public static let snapToCornersKey = "miniWindow.snapToCorners" |
| + /// Until 0.4.16, one choice: "corners" or "anywhere". Read once, by |
| + /// `migrate`, and removed. |
| + public static let legacyPlacementKey = "miniWindow.placement" |
| public static let widthKey = "miniWindow.width" |
| public static let positionsKey = "miniWindow.positions" |
| public static let defaultEnabled = true |
| public static let defaultCorner = MiniWindowCorner.bottomRight |
| - public static let defaultPlacement = MiniWindowPlacement.corners |
| + public static let defaultMoveFreely = true |
| + public static let defaultSnapToCorners = true |
| private let defaults: UserDefaults |
| - public init(defaults: UserDefaults = .standard) { self.defaults = defaults } |
| + public init(defaults: UserDefaults = .standard) { |
| + self.defaults = defaults |
| + Self.migrate(defaults) |
| + } |
| + |
| + /// The one choice of 0.4.15 and before, as the two switches. "Anywhere |
| + /// I put it" was someone turning snapping off, so it stays off. "Snap |
| + /// to corners" was everyone else — chosen or, far more often, the |
| + /// default — and becomes the new default, both on, which is what the |
| + /// only person to have used it asked for; snapping alone remains a |
| + /// click away. Idempotent: the old key goes once it has been read. |
| + public static func migrate(_ defaults: UserDefaults) { |
| + guard let legacy = defaults.string(forKey: legacyPlacementKey) else { return } |
| + if defaults.object(forKey: moveFreelyKey) == nil, defaults.object(forKey: snapToCornersKey) == nil { |
| + defaults.set(true, forKey: moveFreelyKey) |
| + defaults.set(legacy != "anywhere", forKey: snapToCornersKey) |
| + } |
| + defaults.removeObject(forKey: legacyPlacementKey) |
| + } |
| public var enabled: Bool { |
| get { defaults.object(forKey: Self.enabledKey) as? Bool ?? Self.defaultEnabled } |
| @@ -308,12 +345,23 @@ |
| nonmutating set { defaults.set(newValue.rawValue, forKey: Self.cornerKey) } |
| } |
| - public var placement: MiniWindowPlacement { |
| - get { |
| - defaults.string(forKey: Self.placementKey).flatMap(MiniWindowPlacement.init(rawValue:)) |
| - ?? Self.defaultPlacement |
| + /// A dragged window stays where it is dropped (unless a corner takes it). |
| + public var moveFreely: Bool { |
| + get { defaults.object(forKey: Self.moveFreelyKey) as? Bool ?? Self.defaultMoveFreely } |
| + nonmutating set { |
| + defaults.set(newValue, forKey: Self.moveFreelyKey) |
| + if !newValue, !snapToCorners { defaults.set(true, forKey: Self.snapToCornersKey) } |
| + } |
| + } |
| + |
| + /// A dragged window settles in a corner: the nearest, or with |
| + /// `moveFreely`, one it is let go near. |
| + public var snapToCorners: Bool { |
| + get { defaults.object(forKey: Self.snapToCornersKey) as? Bool ?? Self.defaultSnapToCorners } |
| + nonmutating set { |
| + defaults.set(newValue, forKey: Self.snapToCornersKey) |
| + if !newValue, !moveFreely { defaults.set(true, forKey: Self.moveFreelyKey) } |
| } |
| - nonmutating set { defaults.set(newValue.rawValue, forKey: Self.placementKey) } |
| } |
| /// The width last resized to. Only the width: the height follows |
| @@ -326,7 +374,7 @@ |
| nonmutating set { defaults.set(Double(newValue), forKey: Self.widthKey) } |
| } |
| - /// Where the window was left in "anywhere" mode, per display, as an |
| + /// Where the window was left placed freely, per display, as an |
| /// offset from that display's visible frame (see |
| /// MiniWindowRules.offset). Keyed by the display's ID as a string, and |
| /// kept as one JSON string so that Settings can clear it through |
| @@ -351,11 +399,19 @@ |
| } |
| public func forgetPositions() { defaults.removeObject(forKey: Self.positionsKey) } |
| + |
| + /// One display's free position forgotten: it went into a corner. |
| + public func forgetPosition(on display: String) { |
| + var all = positions |
| + guard all.removeValue(forKey: display) != nil else { return } |
| + guard let data = try? JSONEncoder().encode(all) else { return } |
| + defaults.set(String(decoding: data, as: UTF8.self), forKey: Self.positionsKey) |
| + } |
| } |
| /// What the mini window remembers for one call and forgets when it |
| /// ends: whether it was collapsed to a tab, and any position it was |
| - /// ⌥-dragged to while the setting is "Snap to corners". Every call |
| + /// ⌥-dragged to while it may only snap to corners. Every call |
| /// starts expanded — a tab left over from yesterday's call would be a |
| /// call nobody can see they are in. |
| public struct MiniWindowCallMemory: Equatable { |
| @@ -373,7 +429,7 @@ |
| if let offset = oneOff[display] { |
| return MiniWindowRules.frame(offset: offset, size: size, in: visible) |
| } |
| - if preferences.placement == .anywhere, let offset = preferences.position(on: display) { |
| + if preferences.moveFreely, let offset = preferences.position(on: display) { |
| return MiniWindowRules.frame(offset: offset, size: size, in: visible) |
| } |
| return preferences.corner.frame(size: size, in: visible) |
| @@ -382,29 +438,39 @@ |
| /// A drag ended with the window at `frame` on `display`. Returns |
| /// where it settles. |
| /// |
| - /// - "Anywhere I put it": exactly there (clamped on screen), saved for |
| - /// that display. |
| - /// - "Snap to corners" with ⌥ held: exactly there, for this call only. |
| - /// - "Snap to corners": the nearest corner, which becomes the setting, |
| - /// and any one-off on that display is dropped. |
| + /// - ⌥ held: exactly there (clamped on screen), whatever the corners |
| + /// would have done — saved for that display if it may move freely, |
| + /// for this call only if it may only snap. |
| + /// - Snapping alone: the nearest corner. |
| + /// - Both: a corner if it was let go within `snapDistance` of one, |
| + /// and otherwise exactly there, saved for that display. |
| + /// - Moving freely alone: exactly there, saved for that display. |
| + /// |
| + /// A corner it settles in becomes the setting, and that display's |
| + /// free position and any one-off on it are forgotten. |
| public mutating func dropped( |
| _ frame: CGRect, in visible: CGRect, display: String, option: Bool, |
| preferences: MiniWindowPreferences |
| ) -> CGRect { |
| let placed = MiniWindowRules.clamp(frame, into: visible) |
| - switch (preferences.placement, option) { |
| - case (.anywhere, _): |
| - preferences.setPosition(MiniWindowRules.offset(of: placed, in: visible), on: display) |
| - return placed |
| - case (.corners, true): |
| + let free = preferences.moveFreely |
| + if option, !free { |
| oneOff[display] = MiniWindowRules.offset(of: placed, in: visible) |
| return placed |
| - case (.corners, false): |
| + } |
| + if !option, preferences.snapToCorners, |
| + let corner = free |
| + ? MiniWindowCorner.magnet(for: placed, in: visible) |
| + : MiniWindowCorner.nearest(to: frame, in: visible) |
| + { |
| oneOff[display] = nil |
| - let corner = MiniWindowCorner.nearest(to: frame, in: visible) |
| preferences.corner = corner |
| + preferences.forgetPosition(on: display) |
| return corner.frame(size: frame.size, in: visible) |
| } |
| + oneOff[display] = nil |
| + preferences.setPosition(MiniWindowRules.offset(of: placed, in: visible), on: display) |
| + return placed |
| } |
| /// A resize ended with the window at `frame`. It settles as a drop |
diff --git a/native/apple/Sources/CallsMac/CallsMac.swift b/native/apple/Sources/CallsMac/CallsMac.swift| index 375caba..d6265b9 100644 |
| --- a/native/apple/Sources/CallsMac/CallsMac.swift |
| +++ b/native/apple/Sources/CallsMac/CallsMac.swift |
| @@ -90,6 +90,9 @@ final class CallsAppDelegate: NSObject, NSApplicationDelegate { |
| } |
| func applicationDidFinishLaunching(_ notification: Notification) { |
| + // 0.4.15's one placement choice, as 0.4.16's two switches, before |
| + // Settings can read them. |
| + MiniWindowPreferences.migrate(.standard) |
| // On macOS 26 and later a bundled app's Dock icon comes from Assets.car, |
| // which the system masks and renders in the person's icon style. Setting |
| // a picture here would replace that with a flat PNG, so only a run |
diff --git a/native/apple/Tests/CallsKitTests/CallBarFitTests.swift b/native/apple/Tests/CallsKitTests/CallBarFitTests.swift| index 4c7cca4..410ace8 100644 |
| --- a/native/apple/Tests/CallsKitTests/CallBarFitTests.swift |
| +++ b/native/apple/Tests/CallsKitTests/CallBarFitTests.swift |
| @@ -52,3 +52,135 @@ final class CallBarFitTests: XCTestCase { |
| [.devices, .layout]) |
| } |
| } |
| + |
| +/// The floating self view and the bar together (2026-10-30, Paul on |
| +/// 0.4.15: "The picture-in-picture is weirdly close to the in-call |
| +/// chrome"). The self view stays in its corner, 16 pt from the edges, |
| +/// whether the controls show or not, and the bar keeps clear of it. |
| +final class SelfViewBarLayoutTests: XCTestCase { |
| + private let member = CallBarFit.Control.allCases |
| + private let guest = CallBarFit.Control.allCases.filter { $0 != .link } |
| + private let title: CGFloat = 32 |
| + |
| + /// The bar's frame as MacFullWindowCall draws it: centred, `margin` up. |
| + private func barFrame(_ fit: CallBarFit, in window: CGSize) -> CGRect { |
| + CGRect( |
| + x: (window.width - fit.width) / 2, y: window.height - CallBarFit.margin - fit.height, |
| + width: fit.width, height: fit.height) |
| + } |
| + |
| + /// The least distance between two rectangles that do not overlap; 0 if they do. |
| + private func gap(_ a: CGRect, _ b: CGRect) -> CGFloat { |
| + let dx = max(b.minX - a.maxX, a.minX - b.maxX, 0) |
| + let dy = max(b.minY - a.maxY, a.minY - b.maxY, 0) |
| + return max(dx, dy) |
| + } |
| + |
| + func testInABottomCornerItNeverMovesAndTheBarKeepsAtLeast12Clear() { |
| + for height in [540.0, 700, 900, 1440] { |
| + for width in stride(from: 760.0, through: 3840, by: 3) { |
| + let window = CGSize(width: width, height: height) |
| + for shape in [VideoShape.landscape, .portrait] { |
| + let pip = PiPLayout.size(in: window, touch: false, shape: shape) |
| + for corner in [PiPCorner.bottomTrailing, .bottomLeading] { |
| + for controls in [member, guest] { |
| + let layout = SelfViewBarLayout.layout( |
| + window: window, selfView: pip, corner: corner, top: title, controls: controls) |
| + let at = "\(corner) \(shape) at \(width) × \(height)" |
| + XCTAssertFalse(layout.rises, "the self view moves with the controls, \(at)") |
| + XCTAssertEqual(layout.selfView(barShown: true), layout.selfView(barShown: false), at) |
| + let selfView = layout.resting |
| + // In its corner, 16 pt from both edges. |
| + XCTAssertEqual(window.height - selfView.maxY, 16, at) |
| + XCTAssertEqual(corner.leading ? selfView.minX : width - selfView.maxX, 16, at) |
| + let bar = barFrame(layout.bar, in: window) |
| + XCTAssertGreaterThanOrEqual(gap(bar, selfView), 12, "\(at): bar \(bar), self \(selfView)") |
| + XCTAssertGreaterThanOrEqual(gap(bar, selfView), SelfViewBarLayout.clearance - 0.001, at) |
| + // Centred, inside the window, and whole. |
| + XCTAssertEqual(bar.midX, width / 2, accuracy: 0.001, at) |
| + XCTAssertGreaterThanOrEqual(bar.minX, CallBarFit.margin, at) |
| + for control in controls where control.essential { |
| + XCTAssertTrue(layout.bar.shows(control), "\(control), \(at)") |
| + } |
| + let shown = controls.filter(layout.bar.shows) |
| + XCTAssertLessThanOrEqual( |
| + CallBarFit.needed(shown, layout.bar.spacing, more: !layout.bar.overflow.isEmpty), |
| + layout.bar.width + 0.001, at) |
| + } |
| + } |
| + } |
| + } |
| + } |
| + } |
| + |
| + func testAtTheSmallestWindowOnlyTheLeastUsedGoIntoMore() { |
| + let window = CGSize(width: 760, height: 540) |
| + let pip = PiPLayout.size(in: window, touch: false) |
| + let fit = { (controls: [CallBarFit.Control]) in |
| + SelfViewBarLayout.layout( |
| + window: window, selfView: pip, corner: .bottomTrailing, top: self.title, controls: controls |
| + ).bar |
| + } |
| + XCTAssertEqual(fit(member).overflow, [.layout, .link]) |
| + XCTAssertEqual(fit(guest).overflow, []) |
| + // Wide enough, and the bar is the ordinary one. |
| + let wide = CGSize(width: 1718, height: 1000) |
| + XCTAssertEqual( |
| + SelfViewBarLayout.layout( |
| + window: wide, selfView: PiPLayout.size(in: wide, touch: false), corner: .bottomTrailing, |
| + top: title, controls: member |
| + ).bar, CallBarFit.fit(windowWidth: 1718, controls: member)) |
| + } |
| + |
| + func testInATopCornerTheBarIsTheWindowsAndTheSelfViewIsBelowTheTitle() { |
| + let window = CGSize(width: 1000, height: 640) |
| + let pip = PiPLayout.size(in: window, touch: false) |
| + for corner in [PiPCorner.topLeading, .topTrailing] { |
| + let layout = SelfViewBarLayout.layout( |
| + window: window, selfView: pip, corner: corner, top: title, controls: member) |
| + XCTAssertEqual(layout.bar, CallBarFit.fit(windowWidth: 1000, controls: member)) |
| + XCTAssertFalse(layout.rises) |
| + XCTAssertEqual(layout.resting.minY, title + 16) |
| + } |
| + } |
| + |
| + func testWithNobodyFloatingTheBarIsTheWindows() { |
| + let layout = SelfViewBarLayout.layout( |
| + window: CGSize(width: 900, height: 600), selfView: nil, corner: .bottomTrailing, |
| + controls: member) |
| + XCTAssertEqual(layout.bar, CallBarFit.fit(windowWidth: 900, controls: member)) |
| + } |
| + |
| + func testBesideAnOpenChatItRisesLevelWithTheChatAnd12Clear() { |
| + // The chat holds the controls up, so it does not move while open. |
| + for width in [760.0, 1000, 1718] { |
| + let window = CGSize(width: width, height: 640) |
| + let pip = PiPLayout.size(in: window, touch: false) |
| + let layout = SelfViewBarLayout.layout( |
| + window: window, selfView: pip, corner: .bottomTrailing, top: title, trailing: 320 + 12, |
| + controls: member) |
| + XCTAssertTrue(layout.rises) |
| + let raised = layout.selfView(barShown: true) |
| + let bar = barFrame(layout.bar, in: window) |
| + XCTAssertEqual(bar.minY - raised.maxY, SelfViewBarLayout.rise, accuracy: 0.001) |
| + XCTAssertGreaterThanOrEqual(gap(bar, raised), 12) |
| + XCTAssertEqual(raised.maxX, width - 320 - 12 - 16) |
| + // Level with the chat panel's bottom (MacFullWindowCall.panels). |
| + XCTAssertEqual(window.height - raised.maxY, 80 + SelfViewBarLayout.rise, accuracy: 0.001) |
| + } |
| + } |
| + |
| + func testAWindowTooNarrowForTheBarBesideItRaisesItInstead() { |
| + // Below the app's minimum: only the system makes a window this narrow. |
| + for width in stride(from: 200.0, to: 760, by: 1) { |
| + let window = CGSize(width: width, height: 480) |
| + let pip = PiPLayout.size(in: window, touch: false) |
| + let layout = SelfViewBarLayout.layout( |
| + window: window, selfView: pip, corner: .bottomTrailing, top: title, controls: member) |
| + let bar = barFrame(layout.bar, in: window) |
| + let shown = layout.selfView(barShown: true) |
| + XCTAssertGreaterThanOrEqual(gap(bar, shown), 12, "at \(width)") |
| + if layout.rises { XCTAssertEqual(layout.bar, CallBarFit.fit(windowWidth: width, controls: member)) } |
| + } |
| + } |
| +} |
diff --git a/native/apple/Tests/CallsKitTests/MiniWindowTests.swift b/native/apple/Tests/CallsKitTests/MiniWindowTests.swift| index 4b11517..7020a47 100644 |
| --- a/native/apple/Tests/CallsKitTests/MiniWindowTests.swift |
| +++ b/native/apple/Tests/CallsKitTests/MiniWindowTests.swift |
| @@ -249,11 +249,19 @@ |
| let store = UserDefaults(suiteName: name)! |
| defer { store.removePersistentDomain(forName: name) } |
| var memory = MiniWindowCallMemory() |
| + let preferences = MiniWindowPreferences(defaults: store) |
| + // Snapping alone: the nearest corner, from anywhere. |
| + preferences.moveFreely = false |
| let dropped = CGRect(x: 800, y: 500, width: 480, height: 270) |
| let settled = memory.dropped( |
| - dropped, in: visible, display: "1", option: false, |
| - preferences: MiniWindowPreferences(defaults: store)) |
| + dropped, in: visible, display: "1", option: false, preferences: preferences) |
| XCTAssertEqual(settled, MiniWindowCorner.topRight.frame(size: dropped.size, in: visible)) |
| + // Both on: the corner it was let go near, at its size too. |
| + preferences.moveFreely = true |
| + let near = MiniWindowCorner.bottomLeft.frame(size: dropped.size, in: visible).offsetBy(dx: 40, dy: 30) |
| + XCTAssertEqual( |
| + memory.dropped(near, in: visible, display: "1", option: false, preferences: preferences), |
| + MiniWindowCorner.bottomLeft.frame(size: dropped.size, in: visible)) |
| } |
| } |
| @@ -322,7 +330,8 @@ |
| } |
| } |
| - /// Placement: corners, anywhere, and ⌥ for one call. |
| + /// Placement: two switches, Move freely and Snap to corners, both on by |
| + /// default (2026-10-30); magnetic corners when both are on; and ⌥. |
| final class MiniWindowPlacementTests: XCTestCase { |
| private let visible = CGRect(x: 0, y: 70, width: 1440, height: 805) |
| private let size = CGSize(width: 320, height: 180) |
| @@ -334,19 +343,18 @@ |
| return MiniWindowPreferences(defaults: defaults) |
| } |
| - func testCornersByDefault() { |
| + func testBothOnByDefaultAndInTheBottomRight() { |
| let preferences = preferences() |
| - XCTAssertEqual(preferences.placement, .corners) |
| - XCTAssertEqual( |
| - MiniWindowPlacement.allCases.map(\.title), ["Snap to corners", "Anywhere I put it"]) |
| + XCTAssertTrue(preferences.moveFreely) |
| + XCTAssertTrue(preferences.snapToCorners) |
| XCTAssertEqual( |
| MiniWindowCallMemory().frame(size: size, in: visible, display: "1", preferences: preferences), |
| MiniWindowCorner.bottomRight.frame(size: size, in: visible)) |
| } |
| - func testAnywhereKeepsTheDropExactlyAndRemembersItPerDisplay() { |
| + func testMovingFreelyAloneKeepsTheDropExactlyAndRemembersItPerDisplay() { |
| let preferences = preferences() |
| - preferences.placement = .anywhere |
| + preferences.snapToCorners = false |
| var memory = MiniWindowCallMemory() |
| let drop = CGRect(x: 612, y: 333, width: 320, height: 180) |
| XCTAssertEqual( |
| @@ -364,7 +372,7 @@ |
| func testAFreePositionFollowsItsDisplayWhenTheArrangementChanges() { |
| let preferences = preferences() |
| - preferences.placement = .anywhere |
| + preferences.snapToCorners = false |
| var memory = MiniWindowCallMemory() |
| let right = CGRect(x: 1440, y: 0, width: 1920, height: 1055) |
| _ = memory.dropped( |
| @@ -379,7 +387,7 @@ |
| func testAFreePositionIsClampedBackOnAScreenThatShrank() { |
| let preferences = preferences() |
| - preferences.placement = .anywhere |
| + preferences.snapToCorners = false |
| var memory = MiniWindowCallMemory() |
| let big = CGRect(x: 0, y: 0, width: 2560, height: 1415) |
| _ = memory.dropped( |
| @@ -398,8 +406,9 @@ |
| XCTAssertEqual(half.origin, CGPoint(x: 0, y: 0)) |
| } |
| - func testOptionDragPlacesFreelyForThisCallOnly() { |
| + func testWithSnappingAloneOptionDragPlacesFreelyForThisCallOnly() { |
| let preferences = preferences() |
| + preferences.moveFreely = false |
| var memory = MiniWindowCallMemory() |
| let drop = CGRect(x: 612, y: 333, width: 320, height: 180) |
| XCTAssertEqual( |
| @@ -418,8 +427,9 @@ |
| MiniWindowCorner.bottomRight.frame(size: size, in: visible)) |
| } |
| - func testAnOrdinaryDragAfterAnOptionDragSnapsAndForgetsTheOneOff() { |
| + func testWithSnappingAloneAnOrdinaryDragSnapsToTheNearestAndForgetsTheOneOff() { |
| let preferences = preferences() |
| + preferences.moveFreely = false |
| var memory = MiniWindowCallMemory() |
| _ = memory.dropped( |
| CGRect(x: 612, y: 333, width: 320, height: 180), in: visible, display: "1", option: true, |
| @@ -452,15 +462,157 @@ |
| XCTAssertFalse(controller.memory.collapsed) |
| } |
| + func testBothOnLetGoNearACornerItSnapsIntoIt() { |
| + let preferences = preferences() |
| + var memory = MiniWindowCallMemory() |
| + // 60 pt left of and 50 pt above where the top-left corner would hold it. |
| + let topLeft = MiniWindowCorner.topLeft.frame(size: size, in: visible) |
| + let near = topLeft.offsetBy(dx: 60, dy: -50) |
| + XCTAssertEqual( |
| + memory.dropped(near, in: visible, display: "1", option: false, preferences: preferences), |
| + topLeft) |
| + XCTAssertEqual(preferences.corner, .topLeft) |
| + // Every corner, from just inside the snap distance. |
| + for corner in MiniWindowCorner.allCases { |
| + let snapped = corner.frame(size: size, in: visible) |
| + let inward = CGVector(dx: corner.right ? -1 : 1, dy: corner.top ? -1 : 1) |
| + // Diagonally inward, just short of the distance. |
| + let reach = MiniWindowRules.snapDistance / CGFloat(2).squareRoot() * 0.99 |
| + let dropped = snapped.offsetBy(dx: inward.dx * reach, dy: inward.dy * reach) |
| + XCTAssertEqual( |
| + memory.dropped(dropped, in: visible, display: "1", option: false, preferences: preferences), |
| + snapped, "\(corner)") |
| + } |
| + // Dragged past the screen's edge into the corner: clamped, then taken. |
| + let past = MiniWindowCorner.bottomRight.frame(size: size, in: visible).offsetBy(dx: 300, dy: -200) |
| + XCTAssertEqual( |
| + memory.dropped(past, in: visible, display: "1", option: false, preferences: preferences), |
| + MiniWindowCorner.bottomRight.frame(size: size, in: visible)) |
| + } |
| + |
| + func testBothOnLetGoInTheOpenItStaysAndIsRemembered() { |
| + let preferences = preferences() |
| + var memory = MiniWindowCallMemory() |
| + let middle = CGRect(x: 612, y: 333, width: 320, height: 180) |
| + XCTAssertEqual( |
| + memory.dropped(middle, in: visible, display: "1", option: false, preferences: preferences), |
| + middle) |
| + XCTAssertEqual(preferences.corner, .bottomRight, "a free drop is not a corner") |
| + XCTAssertEqual( |
| + MiniWindowCallMemory().frame(size: size, in: visible, display: "1", preferences: preferences), |
| + middle, "the next call opens where it was left") |
| + // Just outside the snap distance of a corner: still the open. |
| + let snapped = MiniWindowCorner.bottomLeft.frame(size: size, in: visible) |
| + let outside = snapped.offsetBy(dx: MiniWindowRules.snapDistance + 1, dy: 0) |
| + XCTAssertEqual( |
| + memory.dropped(outside, in: visible, display: "1", option: false, preferences: preferences), |
| + outside) |
| + // Back into a corner: the corner, and the free position is forgotten |
| + // so the next call opens there too. |
| + _ = memory.dropped( |
| + snapped.offsetBy(dx: 10, dy: 10), in: visible, display: "1", option: false, |
| + preferences: preferences) |
| + XCTAssertNil(preferences.position(on: "1")) |
| + XCTAssertEqual( |
| + MiniWindowCallMemory().frame(size: size, in: visible, display: "1", preferences: preferences), |
| + snapped) |
| + } |
| + |
| + func testBothOnOptionPlacesExactlyIgnoringTheCornersAndRemembersIt() { |
| + let preferences = preferences() |
| + var memory = MiniWindowCallMemory() |
| + let near = MiniWindowCorner.topRight.frame(size: size, in: visible).offsetBy(dx: -20, dy: -20) |
| + XCTAssertEqual( |
| + memory.dropped(near, in: visible, display: "1", option: true, preferences: preferences), |
| + near) |
| + XCTAssertEqual(preferences.corner, .bottomRight) |
| + XCTAssertTrue(memory.oneOff.isEmpty, "free placement is remembered, not a one-off") |
| + XCTAssertEqual( |
| + MiniWindowCallMemory().frame(size: size, in: visible, display: "1", preferences: preferences), |
| + near) |
| + } |
| + |
| + func testTheMagnetIsOnlyNearTheCorners() { |
| + XCTAssertNil( |
| + MiniWindowCorner.magnet(for: CGRect(x: 560, y: 380, width: 320, height: 180), in: visible)) |
| + for corner in MiniWindowCorner.allCases { |
| + let snapped = corner.frame(size: size, in: visible) |
| + XCTAssertEqual(MiniWindowCorner.magnet(for: snapped, in: visible), corner) |
| + } |
| + // The smallest window on a small screen: the magnets never meet. |
| + let small = CGRect(x: 0, y: 0, width: 1024, height: 700) |
| + let tiny = MiniWindowRules.minimumSize() |
| + let middle = CGRect( |
| + x: small.midX - tiny.width / 2, y: small.midY - tiny.height / 2, width: tiny.width, |
| + height: tiny.height) |
| + XCTAssertNil(MiniWindowCorner.magnet(for: middle, in: small)) |
| + } |
| + |
| + func testBothCanNeverBeOff() { |
| + let preferences = preferences() |
| + preferences.moveFreely = false |
| + XCTAssertTrue(preferences.snapToCorners) |
| + preferences.snapToCorners = false |
| + XCTAssertFalse(preferences.snapToCorners) |
| + XCTAssertTrue(preferences.moveFreely, "turning the last one off turns the other back on") |
| + preferences.moveFreely = false |
| + XCTAssertTrue(preferences.snapToCorners) |
| + XCTAssertFalse(preferences.moveFreely) |
| + } |
| + |
| func testForgettingPositionsPutsItBackInTheCorner() { |
| let preferences = preferences() |
| - preferences.placement = .anywhere |
| + preferences.snapToCorners = false |
| preferences.setPosition(CGPoint(x: 10, y: 10), on: "1") |
| preferences.forgetPositions() |
| XCTAssertNil(preferences.position(on: "1")) |
| } |
| } |
| + /// 0.4.15's one placement choice, read once as 0.4.16's two switches. |
| + final class MiniWindowMigrationTests: XCTestCase { |
| + private func defaults(_ legacy: String?) -> UserDefaults { |
| + let name = "MiniWindowMigrationTests.\(UUID().uuidString)" |
| + let defaults = UserDefaults(suiteName: name)! |
| + addTeardownBlock { defaults.removePersistentDomain(forName: name) } |
| + if let legacy { defaults.set(legacy, forKey: MiniWindowPreferences.legacyPlacementKey) } |
| + return defaults |
| + } |
| + |
| + func testSnapToCornersBecomesBothOn() { |
| + let store = defaults("corners") |
| + let preferences = MiniWindowPreferences(defaults: store) |
| + XCTAssertTrue(preferences.moveFreely) |
| + XCTAssertTrue(preferences.snapToCorners) |
| + XCTAssertNil(store.object(forKey: MiniWindowPreferences.legacyPlacementKey)) |
| + // Written, so Settings' own reading of the keys agrees. |
| + XCTAssertEqual(store.object(forKey: MiniWindowPreferences.moveFreelyKey) as? Bool, true) |
| + XCTAssertEqual(store.object(forKey: MiniWindowPreferences.snapToCornersKey) as? Bool, true) |
| + } |
| + |
| + func testAnywhereIPutItBecomesMovingFreelyAlone() { |
| + let store = defaults("anywhere") |
| + MiniWindowPreferences.migrate(store) |
| + let preferences = MiniWindowPreferences(defaults: store) |
| + XCTAssertTrue(preferences.moveFreely) |
| + XCTAssertFalse(preferences.snapToCorners) |
| + } |
| + |
| + func testNothingChosenIsTheNewDefaultAndMigratingTwiceChangesNothing() { |
| + let store = defaults(nil) |
| + MiniWindowPreferences.migrate(store) |
| + XCTAssertNil(store.object(forKey: MiniWindowPreferences.moveFreelyKey)) |
| + let preferences = MiniWindowPreferences(defaults: store) |
| + XCTAssertTrue(preferences.moveFreely && preferences.snapToCorners) |
| + // A choice made since is never overwritten by an old key. |
| + preferences.snapToCorners = false |
| + store.set("corners", forKey: MiniWindowPreferences.legacyPlacementKey) |
| + MiniWindowPreferences.migrate(store) |
| + XCTAssertFalse(MiniWindowPreferences(defaults: store).snapToCorners) |
| + XCTAssertNil(store.object(forKey: MiniWindowPreferences.legacyPlacementKey)) |
| + } |
| + } |
| + |
| /// Space-to-mute's rules, and how AppKit's first responder is read. |
| final class SpaceToMuteTests: XCTestCase { |
| func testBareSpaceWithNothingFocusedToggles() { |
diff --git a/native/ios/Sources/PhoneFullScreenCall.swift b/native/ios/Sources/PhoneFullScreenCall.swift| index c5040ce..524c9d4 100644 |
| --- a/native/ios/Sources/PhoneFullScreenCall.swift |
| +++ b/native/ios/Sources/PhoneFullScreenCall.swift |
| @@ -14,6 +14,14 @@ extension PhoneCall { |
| /// The round buttons' size, and the bar's height with its margin. |
| static let button: CGFloat = 56 |
| static let barHeight: CGFloat = 56 + 16 |
| + |
| + /// How far up from the screen's bottom the self view's insets reach |
| + /// while the bar shows: the bar over the safe area as ever, and never |
| + /// less than its buttons' tops (they sit `max(safe, 16) + 4` up), so |
| + /// with PiPLayout's 12 pt margin the view is at least 12 pt clear of them. |
| + static func selfViewRaise(safeBottom: CGFloat) -> CGFloat { |
| + max(safeBottom + barHeight, max(safeBottom, 16) + 4 + button) |
| + } |
| static let tileBackdrop = Color(white: 0.13) |
| var fullScreen: some View { |
| @@ -220,9 +228,14 @@ extension PhoneCall { |
| let corner = PiPCorner(rawValue: pipCorner) ?? .bottomTrailing |
| let pip = PiPLayout.size( |
| in: size, touch: true, shape: selfShape ?? fixtureFeeds["me"].map(VideoShape.of)) |
| + // Above the bar while it shows: here its buttons are at the corners, |
| + // End call in the bottom right, so the self view cannot stay put as |
| + // the Mac's does. At least 12 pt above the buttons' tops (2026-10-30): |
| + // a phone with no home indicator (safe.bottom 0) had it 8 pt off them. |
| let insets = EdgeInsets( |
| top: safe.top, leading: safe.leading, |
| - bottom: safe.bottom + (chrome.visible ? Self.barHeight : 0), trailing: safe.trailing) |
| + bottom: chrome.visible ? Self.selfViewRaise(safeBottom: safe.bottom) : safe.bottom, |
| + trailing: safe.trailing) |
| let frame = PiPLayout.frame(corner: corner, size: pip, in: size, insets: insets) |
| return PhoneVideoTile( |
| track: call.localTrack, label: "You", muted: call.muted, mirrored: true, |
diff --git a/native/ios/project.yml b/native/ios/project.yml| index e74d97a..f842718 100644 |
| --- a/native/ios/project.yml |
| +++ b/native/ios/project.yml |
| @@ -10,7 +10,7 @@ settings: |
| base: |
| SWIFT_VERSION: '5.0' |
| CODE_SIGN_STYLE: Automatic |
| - MARKETING_VERSION: '0.4.15' |
| + MARKETING_VERSION: '0.4.16' |
| CURRENT_PROJECT_VERSION: '1' |
| # The App Group the app and its broadcast extension share: the socket |
| # the iPhone's screen crosses lives in its container. One setting |
diff --git a/test/browser/call.mjs b/test/browser/call.mjs| index 2bbe12e..45396d6 100644 |
| --- a/test/browser/call.mjs |
| +++ b/test/browser/call.mjs |
| @@ -6247,12 +6247,40 @@ const run = { |
| // ── The self view, floating in a call of two ── |
| const pip = pageA.locator('#tiles > .calls-tile-self'); |
| check(await pip.evaluate((f) => f.classList.contains('calls-tile-pip')), 'in a call of two you float in a corner'); |
| + // 2026-10-30 (SelfViewBarLayout): it stays 16px in from its corner |
| + // whether the controls show or not, the bar keeping at least 12px |
| + // clear of it; only a window too narrow for the bar beside it has it |
| + // rise above the bar instead, 12px clear. |
| + const apart = (p, b) => Math.max(b.x - (p.x + p.width), p.x - (b.x + b.width), b.y - (p.y + p.height), p.y - (b.y + b.height), 0); |
| + for (const [width, edge] of [[820, false], [1100, true], [1440, true]]) { |
| + await pageA.setViewportSize({ width, height: width === 1440 ? 900 : 600 }); |
| + await pageA.evaluate(() => window.callsChrome.pin(true)); |
| + await sleep(500); |
| + const p = await pip.boundingBox(); |
| + const b = await box(pageA, '#controls'); |
| + const w = await box(pageA, '.calls-window'); |
| + const clear = await pageA.evaluate(() => document.querySelector('.calls-window').dataset.pipClear || ''); |
| + check(apart(p, b) >= 11.5 && clear === (edge ? 'edge' : 'rise'), |
| + width + ' px: the self view is at least 12px from the bar while it shows, ' + (edge ? 'beside it' : 'above it') + |
| + ' (' + JSON.stringify({ p, b, clear }) + ')'); |
| + await shot(pageA, width + '-selfview-shown'); |
| + await pageA.evaluate(() => window.callsChrome.pin(false)); |
| + await sleep(500); |
| + const q = await pip.boundingBox(); |
| + check(Math.abs(w.x + w.width - (q.x + q.width) - 16) < 1 && Math.abs(w.y + w.height - (q.y + q.height) - 16) < 1, |
| + width + ' px: 16px in from the bottom right with the controls hidden (' + JSON.stringify({ q, w }) + ')'); |
| + if (edge) { |
| + check(Math.abs(q.x - p.x) < 1 && Math.abs(q.y - p.y) < 1, |
| + width + ' px: and it does not move as the controls come and go (' + JSON.stringify({ p, q }) + ')'); |
| + } |
| + await shot(pageA, width + '-selfview-hidden'); |
| + await pageA.evaluate(() => window.callsChrome.pin(null)); |
| + } |
| + await pageA.setViewportSize({ width: 1440, height: 900 }); |
| + await sleep(300); |
| await pageA.mouse.move(cx, cy); |
| const p0 = await pip.boundingBox(); |
| const w0 = await box(pageA, '.calls-window'); |
| - const b0 = await box(pageA, '#controls'); |
| - check(p0.x + p0.width > w0.x + w0.width - 20 && p0.y + p0.height <= b0.y, |
| - 'bottom right by default, clear of the bar while it shows (' + JSON.stringify({ p0, b0 }) + ')'); |
| await pageA.mouse.move(p0.x + p0.width / 2, p0.y + p0.height / 2); |
| await pageA.mouse.down(); |
| for (let i = 1; i <= 12; i++) { |