From 335b68282c5b6f4e4a7f6c529bde52d15a711ec5 Mon Sep 17 00:00:00 2001 From: onevcat Date: Sun, 28 Jun 2026 11:54:17 +0900 Subject: [PATCH] Prevent fullscreen close-window black screen --- supacode/App/WindowTabbingDisabler.swift | 8 +++++++- supacodeTests/WindowTabbingDisablerTests.swift | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 supacodeTests/WindowTabbingDisablerTests.swift diff --git a/supacode/App/WindowTabbingDisabler.swift b/supacode/App/WindowTabbingDisabler.swift index 9c70b35b..17e8ac1d 100644 --- a/supacode/App/WindowTabbingDisabler.swift +++ b/supacode/App/WindowTabbingDisabler.swift @@ -31,7 +31,13 @@ final class WindowTabbingView: NSView, NSWindowDelegate { } func windowShouldClose(_ sender: NSWindow) -> Bool { - sender.orderOut(nil) + if Self.shouldOrderOutOnClose(styleMask: sender.styleMask) { + sender.orderOut(nil) + } return false } + + static func shouldOrderOutOnClose(styleMask: NSWindow.StyleMask) -> Bool { + !styleMask.contains(.fullScreen) + } } diff --git a/supacodeTests/WindowTabbingDisablerTests.swift b/supacodeTests/WindowTabbingDisablerTests.swift new file mode 100644 index 00000000..e1165da0 --- /dev/null +++ b/supacodeTests/WindowTabbingDisablerTests.swift @@ -0,0 +1,14 @@ +import AppKit +import Testing + +@testable import supacode + +struct WindowTabbingDisablerTests { + @Test func shouldNotOrderOutFullscreenWindowOnClose() { + #expect(WindowTabbingView.shouldOrderOutOnClose(styleMask: [.titled, .fullScreen]) == false) + } + + @Test func shouldOrderOutNonFullscreenWindowOnClose() { + #expect(WindowTabbingView.shouldOrderOutOnClose(styleMask: [.titled, .closable]) == true) + } +} -- 2.51.2