Skip to content

Commit 325a56c

Browse files
committed
Update package
1 parent b989cec commit 325a56c

File tree

4 files changed

+46
-10
lines changed

4 files changed

+46
-10
lines changed

Sources/SwiftUIX/Intermodular/Helpers/AppKit or UIKit/AppKitOrUIKitHostingWindow.swift

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,32 @@ extension AppKitOrUIKitHostingWindowProtocol {
6262
#endif
6363

6464
@_documentation(visibility: internal)
65-
public struct _AppKitOrUIKitHostingWindowConfiguration: Equatable {
66-
public var style: _WindowStyle = .default
65+
public struct _AppKitOrUIKitHostingWindowConfiguration: Hashable, Sendable {
66+
public var style: _WindowStyle
6767
public var canBecomeKey: Bool?
6868
public var allowTouchesToPassThrough: Bool?
6969
public var windowPosition: _CoordinateSpaceRelative<CGPoint>?
7070
public var isTitleBarHidden: Bool?
7171
public var backgroundColor: Color?
7272
public var preferredColorScheme: ColorScheme?
73+
74+
public init(
75+
style: _WindowStyle = .default,
76+
canBecomeKey: Bool? = nil,
77+
allowTouchesToPassThrough: Bool? = nil,
78+
windowPosition: _CoordinateSpaceRelative<CGPoint>? = nil,
79+
isTitleBarHidden: Bool? = nil,
80+
backgroundColor: Color? = nil,
81+
preferredColorScheme: ColorScheme? = nil
82+
) {
83+
self.style = style
84+
self.canBecomeKey = canBecomeKey
85+
self.allowTouchesToPassThrough = allowTouchesToPassThrough
86+
self.windowPosition = windowPosition
87+
self.isTitleBarHidden = isTitleBarHidden
88+
self.backgroundColor = backgroundColor
89+
self.preferredColorScheme = preferredColorScheme
90+
}
7391

7492
public mutating func mergeInPlace(with other: Self) {
7593
self.canBecomeKey = other.canBecomeKey ?? self.canBecomeKey
@@ -392,8 +410,12 @@ open class AppKitOrUIKitHostingWindow<Content: View>: AppKitOrUIKitWindow, AppKi
392410
hasShadow = false
393411
case .titleBar:
394412
self.init(contentViewController: contentViewController)
413+
414+
self._SwiftUIX_windowConfiguration.style = style
395415
case ._transparent:
396416
self.init(contentViewController: contentViewController)
417+
418+
self._SwiftUIX_windowConfiguration.style = style
397419
}
398420

399421
Task.detached { @MainActor in
@@ -406,6 +428,8 @@ open class AppKitOrUIKitHostingWindow<Content: View>: AppKitOrUIKitWindow, AppKi
406428
self.contentViewController = contentViewController
407429
}
408430

431+
assert(self._SwiftUIX_windowConfiguration.style == style)
432+
409433
performSetUp()
410434

411435
delegate = self
@@ -455,15 +479,17 @@ open class AppKitOrUIKitHostingWindow<Content: View>: AppKitOrUIKitWindow, AppKi
455479
}
456480
}
457481
case ._transparent:
482+
styleMask = [.borderless, .fullSizeContentView]
458483
collectionBehavior = [.fullScreenPrimary]
459484
level = .floating
460-
isMovable = false
461485
titleVisibility = .hidden
462486
titlebarAppearsTransparent = true
463-
487+
isMovable = true
488+
isMovableByWindowBackground = true
489+
ignoresMouseEvents = false
490+
464491
standardWindowButton(.closeButton)?.isHidden = true
465492
standardWindowButton(.miniaturizeButton)?.isHidden = true
466-
467493
standardWindowButton(.zoomButton)?.isHidden = true
468494

469495
hasShadow = false

Sources/SwiftUIX/Intramodular/Screen/_CoordinateSpaceRelative.swift

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ import UIKit
1616

1717
/// A value relative to one or multiple coordinate spaces.
1818
@_documentation(visibility: internal)
19-
public struct _CoordinateSpaceRelative<Value: Equatable>: Equatable {
20-
private weak var __sourceAppKitOrUIKitWindow: NSObject?
19+
public struct _CoordinateSpaceRelative<Value: Equatable & Sendable>: Equatable, Sendable {
2120
private var storage: [_ScreenOrCoordinateSpace: Value] = [:]
2221

22+
private weak var __sourceAppKitOrUIKitWindow: (NSObject & Sendable)?
23+
2324
init(
2425
storage: [_ScreenOrCoordinateSpace: Value],
2526
_sourceAppKitOrUIKitWindow: NSObject?
@@ -148,6 +149,15 @@ extension _CoordinateSpaceRelative where Value == CGRect {
148149
}
149150
#endif
150151

152+
// MARK: - Conformances
153+
154+
extension _CoordinateSpaceRelative: Hashable where Value: Hashable {
155+
public func hash(into hasher: inout Hasher) {
156+
hasher.combine(storage)
157+
hasher.combine(__sourceAppKitOrUIKitWindow)
158+
}
159+
}
160+
151161
// MARK: - Supplementary
152162

153163
#if os(iOS) || os(macOS) || os(tvOS) || os(visionOS)

Sources/SwiftUIX/Intramodular/Screen/_ScreenOrCoordinateSpace.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import SwiftUI
88

99
/// An enumeration that represents either a screen or a SwiftUI `CoordinateSpace`.
1010
@_documentation(visibility: internal)
11-
public enum _ScreenOrCoordinateSpace: Hashable {
11+
public enum _ScreenOrCoordinateSpace: Hashable, @unchecked Sendable {
1212
case cocoa(Screen?)
1313
case coordinateSpace(CoordinateSpace)
14-
14+
1515
public var _cocoaScreen: Screen? {
1616
guard case .cocoa(let screen) = self else {
1717
return nil

Sources/SwiftUIX/Intramodular/Window/_WindowStyle.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import SwiftUI
77
#if os(iOS) || os(macOS) || os(tvOS) || os(visionOS) || targetEnvironment(macCatalyst)
88

99
@_documentation(visibility: internal)
10-
public enum _WindowStyle {
10+
public enum _WindowStyle: Sendable {
1111
case `default`
1212
case hiddenTitleBar
1313
case plain

0 commit comments

Comments
 (0)