oficina / meet Public

Live glass and glow snapshots: CallsInterop --glass-snapshots

Liquid Glass is drawn by the window server, not an off-screen bitmap, so
these render real windows parked below the desktop and capture them with
screencapture -l: the bar over black, white and busy frames in glass and
in the forced fallback material, the Devices panel, the names glowing
at four levels, and the mini window tab.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 4a92abdf75162fefc073f57d0767f4d1942876af parent c15f18c
4 files changed, +116 −0
  • native/apple/Sources/CallsInterop/CallSnapshots.swift +79 −0
  • native/apple/Sources/CallsInterop/Interop.swift +6 −0
  • native/apple/Sources/CallsKit/Call.swift +12 −0
  • native/apple/Sources/CallsKit/CallFixtures.swift +19 −0
diff --git a/native/apple/Sources/CallsInterop/CallSnapshots.swift b/native/apple/Sources/CallsInterop/CallSnapshots.swift
index 5ce2c9c..add0cb4 100644
--- a/native/apple/Sources/CallsInterop/CallSnapshots.swift
+++ b/native/apple/Sources/CallsInterop/CallSnapshots.swift
@@ -52,4 +52,83 @@ import SwiftUI
try await shot("contrast-busy-hidden", .focus, shown: false, backdrop: .busy)
}
}
+
+ /// The glass and the glow as the window server draws them (0.3.7). An
+ /// off-screen bitmap has no Liquid Glass and no backdrop to blur, so
+ /// these are real windows, parked below the desktop where nobody sees
+ /// them, and captured by `screencapture -l`: the control bar over black,
+ /// white and a busy frame, in glass and in the material older systems
+ /// draw; the Devices panel; the names glowing at four levels; the tab.
+ static func saveGlass(to folder: URL) async throws {
+ NSApplication.shared.setActivationPolicy(.prohibited)
+ try FileManager.default.createDirectory(at: folder, withIntermediateDirectories: true)
+ let size = CGSize(width: 1000, height: 640)
+ func shot(
+ _ name: String, _ fixture: CallFixture, grid: Bool = false, devices: Bool = false,
+ glass: Bool = true, backdrop: FixtureBackdrop? = nil, me: FixtureSelf? = nil,
+ speaking: FixtureSpeaking? = nil
+ ) async throws {
+ let call = Call(playAudio: false)
+ fixture.apply(to: call)
+ me?.apply(to: call)
+ speaking?.apply(to: call)
+ try await renderLive(
+ MacCallView(
+ call: call, grid: grid, showingDevices: devices, style: .fullWindow,
+ controlsShown: true, leave: {}, rejoin: {}
+ )
+ .tint(CallsAppearance.accent)
+ .environment(\.fixtureBackdrop, backdrop)
+ .environment(\.callOverlayGlass, glass),
+ size: size, to: folder.appendingPathComponent("mac-\(name).png"))
+ }
+ for glass in [true, false] {
+ let kind = glass ? "glass" : "fallback"
+ for backdrop in FixtureBackdrop.allCases {
+ try await shot("bar-\(kind)-\(backdrop.rawValue)", .focus, glass: glass, backdrop: backdrop)
+ }
+ try await shot("bar-\(kind)-busy-muted", .focus, glass: glass, backdrop: .busy, me: .muted)
+ try await shot("bar-\(kind)-busy-sharing", .focus, glass: glass, backdrop: .busy, me: .sharing)
+ try await shot("devices-\(kind)", .focus, devices: true, glass: glass, backdrop: .busy)
+ }
+ for level in FixtureSpeaking.allCases {
+ try await shot("glow-\(level.rawValue)", .grid, grid: true, speaking: level)
+ try await shot("glow-focus-\(level.rawValue)", .focus, speaking: level)
+ }
+ for level in [FixtureSpeaking.silent, .high] {
+ let call = Call(playAudio: false)
+ CallFixture.focus.apply(to: call)
+ level.apply(to: call)
+ try await renderLive(
+ ZStack {
+ FixtureBackdrop.busy.view
+ MiniWindowSnapshot.tab(call: call)
+ },
+ size: CGSize(width: MiniWindowTab.size.width + 40, height: MiniWindowTab.size.height + 40),
+ to: folder.appendingPathComponent("mac-tab-\(level.rawValue).png"))
+ }
+ }
+
+ /// A real window below the desktop, captured by the window server.
+ static func renderLive(_ content: some View, size: CGSize, to file: URL) async throws {
+ let view = NSHostingView(rootView: content.environment(\.colorScheme, .dark))
+ view.frame.size = size
+ let window = NSWindow(
+ contentRect: NSRect(origin: CGPoint(x: 0, y: 0), size: size),
+ styleMask: [.borderless], backing: .buffered, defer: false)
+ window.isReleasedWhenClosed = false
+ window.level = NSWindow.Level(rawValue: Int(CGWindowLevelForKey(.desktopWindow)) - 1)
+ window.appearance = NSAppearance(named: .darkAqua)
+ window.contentView = view
+ window.orderBack(nil)
+ try await Task.sleep(for: .milliseconds(600))
+ view.layoutSubtreeIfNeeded()
+ let capture = Process()
+ capture.executableURL = URL(fileURLWithPath: "/usr/sbin/screencapture")
+ capture.arguments = ["-x", "-o", "-l", String(window.windowNumber), file.path]
+ try capture.run()
+ capture.waitUntilExit()
+ window.close()
+ guard capture.terminationStatus == 0 else { throw CocoaError(.fileWriteUnknown) }
+ }
}
diff --git a/native/apple/Sources/CallsInterop/Interop.swift b/native/apple/Sources/CallsInterop/Interop.swift
index 1ce3a5a..8e341c6 100644
--- a/native/apple/Sources/CallsInterop/Interop.swift
+++ b/native/apple/Sources/CallsInterop/Interop.swift
@@ -30,6 +30,12 @@ struct Input: Decodable {
} catch { exit(1) }
return
}
+ if CommandLine.arguments.count == 3, CommandLine.arguments[1] == "--glass-snapshots" {
+ do {
+ try await CallSnapshots.saveGlass(to: URL(fileURLWithPath: CommandLine.arguments[2]))
+ } catch { exit(1) }
+ return
+ }
if CommandLine.arguments.count == 2, CommandLine.arguments[1] == "--audio-selftest" {
exit(await AudioSelfTestHarness.run() ? 0 : 1)
}
diff --git a/native/apple/Sources/CallsKit/Call.swift b/native/apple/Sources/CallsKit/Call.swift
index 68e0ea0..c02bd4b 100644
--- a/native/apple/Sources/CallsKit/Call.swift
+++ b/native/apple/Sources/CallsKit/Call.swift
@@ -804,4 +804,16 @@ extension Call {
self.cameraOff = cameraOff
self.sharingScreen = sharingScreen
}
+
+ /// Everyone's glow, and yours, held at one level, for the snapshots.
+ @_spi(Fixtures) public func showFixtureSpeaking(level: Float) {
+ levels.mic.glow.showFixture(level: level)
+ // Nobody muted glows: muted, the speaking gate is shut.
+ if muted { levels.mic.glow.reset() }
+ for peer in state?.peers ?? [] where peer.peer != state?.peer && !isMuted(peer.peer) {
+ levels.peer(peer.peer).glow.showFixture(level: level)
+ }
+ levels.othersGlow.showFixture(level: level)
+ levels.anyoneSpeaking.set(levels.othersGlow.glow.lit)
+ }
}
diff --git a/native/apple/Sources/CallsKit/CallFixtures.swift b/native/apple/Sources/CallsKit/CallFixtures.swift
index 3754da1..26ab720 100644
--- a/native/apple/Sources/CallsKit/CallFixtures.swift
+++ b/native/apple/Sources/CallsKit/CallFixtures.swift
@@ -45,6 +45,25 @@ import SwiftUI
}
}
+/// How loudly everyone is speaking, for the snapshots of the glow behind
+/// the names: silent, and low, middling and loud speech.
+@_spi(Fixtures) public enum FixtureSpeaking: String, CaseIterable, Sendable {
+ case silent, low, mid, high
+
+ public var decibels: Float {
+ switch self {
+ case .silent: -60
+ case .low: -29
+ case .mid: -21
+ case .high: -12
+ }
+ }
+
+ @MainActor public func apply(to call: Call) {
+ call.showFixtureSpeaking(level: pow(10, decibels / 20))
+ }
+}
+
/// What the snapshots put behind the call's overlay in place of video, to
/// show that the controls read over anything: black, white, and a busy
/// frame with light and dark and colour and fine detail in it.