oficina / meet Public

Clone
git clone https://amadan.net/oficina/meet

Plain git — no account needed to clone.

Download

Download this file

1import AppKit
2@_spi(Fixtures) import CallsKit
3import SwiftUI
4
5/// The real full-window call, live, in a window off screen, for the
6/// portrait gate (test/browser/native-portrait.mjs): where each picture is
7/// placed, read back from the video views themselves (VideoPlacementProbe),
8/// not from a fixture. Opened by the `stage-open` command.
9@MainActor final class StagePreview {
10 let window: NSWindow
11 let view: NSHostingView<AnyView>
12 init(call: Call, size: NSSize) {
13 NSApplication.shared.setActivationPolicy(.prohibited)
14 view = NSHostingView(
15 rootView: AnyView(
16 MacCallView(call: call, grid: false, style: .fullWindow, controlsShown: false, leave: {}, rejoin: {})
17 .environment(\.colorScheme, .dark)))
18 window = NSWindow(
19 contentRect: NSRect(x: -4000, y: -4000, width: size.width, height: size.height),
20 styleMask: [.borderless], backing: .buffered, defer: false)
21 window.isReleasedWhenClosed = false
22 window.contentView = view
23 window.orderFront(nil)
24 }
25
26 /// Every picture's placement, after a layout pass, as one JSON line.
27 func placements() -> String {
28 view.layoutSubtreeIfNeeded()
29 let report: [String: Any] = [
30 "placements": VideoPlacementProbe.placements, "backdrops": VideoPlacementProbe.backdrops,
31 ]
32 guard let data = try? JSONSerialization.data(withJSONObject: report),
33 let line = String(data: data, encoding: .utf8)
34 else { return "{}" }
35 return line
36 }
37
38 func resize(_ size: NSSize) { window.setContentSize(size) }
39}
40