From 8888865b447a21760d3533563902607ec728390b Mon Sep 17 00:00:00 2001 From: psavarmattas Date: Fri, 14 Aug 2026 02:26:30 +0100 Subject: [PATCH] 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. --- Outpost/OutpostApp.swift | 2 ++ Outpost/Support/WindowConfigurator.swift | 38 ++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 Outpost/Support/WindowConfigurator.swift diff --git a/Outpost/OutpostApp.swift b/Outpost/OutpostApp.swift index 59cb668..49caa0c 100644 --- a/Outpost/OutpostApp.swift +++ b/Outpost/OutpostApp.swift @@ -54,11 +54,13 @@ struct OutpostApp: App { #if os(macOS) Window("About Outpost", id: "about") { AboutView() + .disablesFullScreen() } .windowResizability(.contentSize) Window("Keyboard Shortcuts", id: "keyboard-shortcuts") { KeyboardShortcutsView() + .disablesFullScreen() } .windowResizability(.contentSize) diff --git a/Outpost/Support/WindowConfigurator.swift b/Outpost/Support/WindowConfigurator.swift new file mode 100644 index 0000000..412325a --- /dev/null +++ b/Outpost/Support/WindowConfigurator.swift @@ -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