Files
Outpost/Outpost/Support/WindowConfigurator.swift
T
Puranjay Savar Mattas 8888865b44 fix(app): drop fullscreen control from About/Keyboard Shortcuts windows
SwiftUI's Window scene defaults to a full titlebar with a fullscreen
button even for small fixed-size reference panels that have no reason
to support it, matching neither platform convention nor how the main
app window is styled.
2026-08-14 02:26:30 +01:00

39 lines
1.2 KiB
Swift

#if os(macOS)
import SwiftUI
import AppKit
/// Grabs the hosting `NSWindow` once it's attached to a screen, for the
/// handful of things SwiftUI's `Window` scene doesn't expose a modifier for.
private struct WindowConfigurator: NSViewRepresentable {
let configure: (NSWindow) -> Void
func makeNSView(context: Context) -> NSView {
let view = NSView()
DispatchQueue.main.async {
if let window = view.window {
configure(window)
}
}
return view
}
func updateNSView(_ nsView: NSView, context: Context) {}
}
extension View {
/// `Window` scenes default to a full standard titlebar, fullscreen
/// (green) button included — not appropriate for fixed-size reference
/// panels like About or Keyboard Shortcuts, which have no reason to
/// support fullscreen at all.
func disablesFullScreen() -> some View {
background(
WindowConfigurator { window in
window.collectionBehavior.remove(.fullScreenPrimary)
window.collectionBehavior.insert(.fullScreenNone)
window.standardWindowButton(.zoomButton)?.isHidden = true
}
)
}
}
#endif