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.
This commit is contained in:
2026-08-14 02:26:30 +01:00
parent f6852897b9
commit 8888865b44
2 changed files with 40 additions and 0 deletions
+2
View File
@@ -54,11 +54,13 @@ struct OutpostApp: App {
#if os(macOS) #if os(macOS)
Window("About Outpost", id: "about") { Window("About Outpost", id: "about") {
AboutView() AboutView()
.disablesFullScreen()
} }
.windowResizability(.contentSize) .windowResizability(.contentSize)
Window("Keyboard Shortcuts", id: "keyboard-shortcuts") { Window("Keyboard Shortcuts", id: "keyboard-shortcuts") {
KeyboardShortcutsView() KeyboardShortcutsView()
.disablesFullScreen()
} }
.windowResizability(.contentSize) .windowResizability(.contentSize)
+38
View File
@@ -0,0 +1,38 @@
#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