f5eae24c87
ci / rust (push) Failing after 42s
apple / swift (push) Successful in 54s
ci / web (push) Successful in 29s
ci / docs-site (push) Successful in 32s
android / android (push) Successful in 1m47s
ci / bench (push) Successful in 1m35s
decky / build-publish (push) Successful in 11s
docker / build-push (--build-arg FEDORA_VERSION=44, ci, ci/fedora-rpm.Dockerfile, punktfunk-fedora44-rpm) (push) Successful in 4s
docker / build-push (., web/Dockerfile, punktfunk-web) (push) Successful in 5s
docker / build-push (ci, ci/fedora-rpm.Dockerfile, punktfunk-fedora-rpm) (push) Successful in 4s
docker / build-push (ci, ci/rust-ci.Dockerfile, punktfunk-rust-ci) (push) Successful in 4s
docker / build-push (docs-site, docs-site/Dockerfile, punktfunk-docs) (push) Successful in 4s
deb / build-publish (push) Successful in 2m21s
rpm / build-publish (bazzite, punktfunk-fedora-rpm) (push) Successful in 5m27s
rpm / build-publish (fedora-44, punktfunk-fedora44-rpm) (push) Successful in 5m28s
docker / deploy-docs (push) Successful in 20s
The macOS Settings window had outgrown one scrolling pane — split it into a tabbed preferences window (General / Display / Audio / Controllers / Advanced). Each settings group is now a shared @ViewBuilder section, so iOS keeps its single grouped Form and tvOS its pushed-picker layout, each defined once. No setting moved or dropped. New statistics-overlay controls (Settings → Display → Statistics): a show/hide toggle (DefaultsKey.hudEnabled) and a corner picker (HUDPlacement / DefaultsKey.hudPlacement) — the HUD moves to the chosen corner and aligns its text to that edge. A Scene-level "Stream" menu (StreamCommands) carries Show/Hide Statistics (⌘⇧S) and Disconnect (⌘D). Disconnect moved off the HUD button into the menu so it survives the overlay being hidden, wired via .focusedSceneValue. On iOS a material-backed exit chip appears when the HUD is hidden (touch users have no menu/⌘D); tvOS disconnect is unchanged (Siri-Remote Menu button). Builds on macOS/iOS/tvOS; swift test green. Adversarially reviewed (8 findings refuted, 2 minor — the iOS exit-chip contrast fix is included here). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
106 lines
5.0 KiB
Swift
106 lines
5.0 KiB
Swift
// The streaming overlay HUD: mode + fps/throughput, the capture→client (and, under the stage-2
|
||
// presenter, capture→present) latency lines, the platform input hint, and disconnect.
|
||
|
||
import PunktfunkKit
|
||
import SwiftUI
|
||
|
||
/// Which corner the HUD overlay occupies (persisted as `DefaultsKey.hudPlacement`). The raw
|
||
/// values are stable on disk — rename the cases freely, never the strings.
|
||
enum HUDPlacement: String, CaseIterable, Identifiable {
|
||
case topLeading, topTrailing, bottomLeading, bottomTrailing
|
||
|
||
var id: String { rawValue }
|
||
|
||
/// SwiftUI overlay alignment for `.overlay(alignment:)`.
|
||
var alignment: Alignment {
|
||
switch self {
|
||
case .topLeading: return .topLeading
|
||
case .topTrailing: return .topTrailing
|
||
case .bottomLeading: return .bottomLeading
|
||
case .bottomTrailing: return .bottomTrailing
|
||
}
|
||
}
|
||
|
||
/// The HUD's own stack hugs the screen edge it sits against, so its text aligns outward.
|
||
var isTrailing: Bool { self == .topTrailing || self == .bottomTrailing }
|
||
|
||
/// User-facing corner label.
|
||
var label: String {
|
||
switch self {
|
||
case .topLeading: return "Top Left"
|
||
case .topTrailing: return "Top Right"
|
||
case .bottomLeading: return "Bottom Left"
|
||
case .bottomTrailing: return "Bottom Right"
|
||
}
|
||
}
|
||
}
|
||
|
||
struct StreamHUDView: View {
|
||
@ObservedObject var model: SessionModel
|
||
let connection: PunktfunkConnection
|
||
var placement: HUDPlacement = .topTrailing
|
||
|
||
var body: some View {
|
||
VStack(alignment: placement.isTrailing ? .trailing : .leading, spacing: 4) {
|
||
HStack(spacing: 6) {
|
||
Circle()
|
||
.fill(Color.accentColor)
|
||
.frame(width: 7, height: 7)
|
||
Text("\(connection.width)×\(connection.height)@\(connection.refreshHz) \(model.fps) fps \(model.mbps, specifier: "%.1f") Mb/s")
|
||
.font(.system(.caption, design: .monospaced))
|
||
}
|
||
if model.latencyValid {
|
||
// Capture→client-receipt (skew-corrected); excludes the layer's decode+present —
|
||
// see LatencyMeter. "(same-host)" when the host didn't answer the skew handshake.
|
||
Text("capture→client \(model.latencyP50Ms, specifier: "%.1f")/\(model.latencyP95Ms, specifier: "%.1f") ms p50/p95\(model.latencySkewCorrected ? "" : " (same-host)")")
|
||
.font(.system(.caption2, design: .monospaced))
|
||
.foregroundStyle(.secondary)
|
||
}
|
||
if model.presentLatencyValid {
|
||
// Capture→present (glass-to-glass, modulo host render→capture) — stage-2 presenter
|
||
// only; stage-1's layer presents internally with no per-frame stamp.
|
||
Text("capture→present \(model.presentLatencyP50Ms, specifier: "%.1f")/\(model.presentLatencyP95Ms, specifier: "%.1f") ms p50/p95\(model.presentLatencySkewCorrected ? "" : " (same-host)")")
|
||
.font(.system(.caption2, design: .monospaced))
|
||
.foregroundStyle(.secondary)
|
||
}
|
||
// While captured the cursor is hidden+frozen, so the button is keyboard-only
|
||
// (⌘⎋ or Cmd+Tab release the cursor; released, it's clickable again).
|
||
#if os(macOS)
|
||
Text(model.mouseCaptured
|
||
? "⌘⎋ releases the mouse"
|
||
: "Click the stream to capture input")
|
||
.font(.caption2)
|
||
.foregroundStyle(.secondary)
|
||
// The client-side cursor (⌘⇧C) draws the local cursor over the stream instead of
|
||
// capturing it — the only accurate cursor for gamescope, whose capture has none.
|
||
Text("⌘⇧C toggles the on-screen cursor")
|
||
.font(.caption2)
|
||
.foregroundStyle(.secondary)
|
||
#elseif os(iOS)
|
||
// Touch always plays directly; ⌘⎋ (hardware keyboard) toggles kb/mouse.
|
||
Text(model.mouseCaptured
|
||
? "⌘⎋ releases keyboard & mouse"
|
||
: "⌘⎋ captures keyboard & mouse")
|
||
.font(.caption2)
|
||
.foregroundStyle(.secondary)
|
||
#endif
|
||
#if os(tvOS)
|
||
// No focusable control during play: a focusable button steals the controller's
|
||
// A press (the focus engine consumes it before the host sees it). Disconnect is
|
||
// the Siri Remote's Menu button (.onExitCommand on the stream) — just hint it.
|
||
Text("Press Menu to disconnect")
|
||
.font(.caption)
|
||
.foregroundStyle(.secondary)
|
||
#else
|
||
// ⌘D lives on the app's Stream menu (so it still works when the HUD is hidden);
|
||
// this button is the in-overlay, click-to-disconnect affordance.
|
||
Button("Disconnect (⌘D)") { model.disconnect() }
|
||
.font(.caption)
|
||
#endif
|
||
}
|
||
.padding(10)
|
||
.background(.regularMaterial, in: RoundedRectangle(cornerRadius: 10))
|
||
.padding(10)
|
||
}
|
||
}
|