From 445a216e90d4107feff804e83cf330a718d91977 Mon Sep 17 00:00:00 2001 From: Alex Ehlke Date: Fri, 28 Apr 2023 12:28:00 -0400 Subject: [PATCH 1/2] macOS 12 --- Package.swift | 2 +- .../TranslucentWindowStyle.swift | 12 +++--------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/Package.swift b/Package.swift index 721e612..f87a845 100644 --- a/Package.swift +++ b/Package.swift @@ -5,7 +5,7 @@ import PackageDescription let package = Package( name: "TranslucentWindowStyle", - platforms: [.macOS(.v13)], + platforms: [.macOS(.v12)], products: [ // Products define the executables and libraries a package produces, and make them visible to other packages. .library( diff --git a/Sources/TranslucentWindowStyle/TranslucentWindowStyle.swift b/Sources/TranslucentWindowStyle/TranslucentWindowStyle.swift index 3686ec6..789da90 100644 --- a/Sources/TranslucentWindowStyle/TranslucentWindowStyle.swift +++ b/Sources/TranslucentWindowStyle/TranslucentWindowStyle.swift @@ -1,5 +1,6 @@ +#if os(macOS) import SwiftUI - +import AppKit public protocol WindowBackgroundStyle { associatedtype Body : View @@ -17,15 +18,12 @@ public struct TranslucentBackgroundStyle: WindowBackgroundStyle { } extension View { - @MainActor public func presentedWindowBackgroundStyle(_ style: S) -> some View where S : WindowBackgroundStyle { self.background(style.backgroud) } - } struct TranslucentWindowBackground: NSViewRepresentable { - enum ContentViewConfiguration { case embed(NSView?) case replace(NSView?) @@ -107,12 +105,10 @@ struct TranslucentWindowBackground: NSViewRepresentable { } } - func makeCoordinator() -> Coordinator { Coordinator() } - class Coordinator: NSObject { private var _originalWindowConfiguration: WindowConfiguration? @@ -157,7 +153,6 @@ struct TranslucentWindowBackground: NSViewRepresentable { } func updateNSView(_ nsView: NSView, context: Context) { - } static func dismantleNSView(_ nsView: NSView, coordinator: Coordinator) { @@ -167,5 +162,4 @@ struct TranslucentWindowBackground: NSViewRepresentable { coordinator.resetWindow(window: window) } } - - +#endif From 4adc0a9e5892de65110f54937ad589770ecbc840 Mon Sep 17 00:00:00 2001 From: Alex Ehlke Date: Sat, 29 Apr 2023 15:07:45 -0400 Subject: [PATCH 2/2] wip --- .../TranslucentWindowStyle/TranslucentWindowStyle.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sources/TranslucentWindowStyle/TranslucentWindowStyle.swift b/Sources/TranslucentWindowStyle/TranslucentWindowStyle.swift index 789da90..f93a397 100644 --- a/Sources/TranslucentWindowStyle/TranslucentWindowStyle.swift +++ b/Sources/TranslucentWindowStyle/TranslucentWindowStyle.swift @@ -64,11 +64,11 @@ struct TranslucentWindowBackground: NSViewRepresentable { contentViewCofiguration: .embed(getTranlucentBackground()), styleMaskConfiguration: .insert(.titled), titlebarAppearsTransparent: true, - titleVisibility: .hidden, + titleVisibility: .visible, standardWindowButtonConfig: StandardWindowButtonConfiguration( - miniaturizeButtonIsHidden: true, - closeButtonIsHidden: true, - zoomButtonIsHidden: true + miniaturizeButtonIsHidden: false, + closeButtonIsHidden: false, + zoomButtonIsHidden: false ), isMovableByWindowBackground: true )