Skip to content

Commit 2ece09c

Browse files
committed
✨ Use default corner radius if corners become sharp after inset
1 parent c09b18a commit 2ece09c

3 files changed

Lines changed: 20 additions & 10 deletions

File tree

Loop/Extensions/RectangleCornerRadii+Extensions.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88
import SwiftUI
99

1010
extension RectangleCornerRadii {
11+
static let zero: RectangleCornerRadii = RectangleCornerRadii(
12+
topLeading: 0,
13+
bottomLeading: 0,
14+
bottomTrailing: 0,
15+
topTrailing: 0
16+
)
17+
1118
func inset(by amount: CGFloat, minRadius: CGFloat = 0) -> RectangleCornerRadii {
1219
RectangleCornerRadii(
1320
topLeading: max(topLeading - amount, minRadius),

Loop/Private APIs/SLSWindowTags.swift

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import Foundation
1010
/// Tags returned by `SLSWindowIteratorGetTags`.
1111
///
1212
/// Bit positions and names are sourced from SkyLight's internal short-name debug table
13-
/// at `__cstring 0x1871fa9a2+`, which is the main bit-position-ordered list
13+
/// at `__cstring 0x1871fa9a2+` on 26.3.1 (25D771280a), which is the main bit-position-ordered list
1414
/// the binary itself uses. Older NUIKit headers (https://github.com/NUIKit/CGSInternal)
15-
/// describe a partly-stale layout, and the current SkyLight has inserted/renamed several Hi
16-
/// bits since NUIKit was last updated.
15+
/// were also used as reference, however it describes a partly-stale layout, and the current
16+
/// SkyLight has inserted/renamed several Hi bits since NUIKit was last updated.
1717
struct SLSWindowTags: OptionSet {
1818
let rawValue: UInt64
1919

@@ -124,12 +124,8 @@ struct SLSWindowTags: OptionSet {
124124

125125
// MARK: - Hi bits (UInt64 bits 32...63)
126126

127-
// NOTE: these positions are different from NUIKit's `CGSWindow.h`. Apple has inserted
128-
// new bits at the start of the Hi range and shifted/added several others. Names here
129-
// come from SkyLight's internal short-debug-name table.
130-
131-
/// The window's owning application is "window-manager-aware", i.e. it participates in
132-
/// WindowServer's window management protocol. Set on virtually every modern Cocoa app.
127+
/// Likely relates to the system's built-in window management (Stage Manager and the built-in WM);
128+
/// probably marks windows whose owning app cooperates with those features?
133129
static let windowManagerAware = Self(rawValue: 1 << 32)
134130

135131
/// The window follows the user across the currently-focused document space. Disqualified

Loop/Window Action Indicators/Preview Window/PreviewView.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,14 @@ struct PreviewView: View {
2424
}
2525

2626
private var cornerRadii: RectangleCornerRadii {
27-
viewModel.overrideCornerRadii?.inset(by: previewPadding) ?? RectangleCornerRadii(
27+
// Prefer the window's own radii, but skip if the padded inset would be sharp.
28+
if let inset = viewModel.overrideCornerRadii?.inset(by: previewPadding),
29+
inset != .zero {
30+
return inset
31+
}
32+
33+
// Fall back to the user's default radius
34+
return RectangleCornerRadii(
2835
topLeading: previewCornerRadius,
2936
bottomLeading: previewCornerRadius,
3037
bottomTrailing: previewCornerRadius,

0 commit comments

Comments
 (0)