Terminal opacity fix

This commit is contained in:
Soham Sharma 2026-04-24 09:14:41 +08:00
commit 9c9f68399e
6 changed files with 161 additions and 21 deletions

View file

@ -86,9 +86,39 @@ struct NotchTerminalView: View {
@ObservedObject var terminalManager = TerminalManager.shared
@EnvironmentObject var vm: DynamicIslandViewModel
@Default(.enableTerminalFeature) var enableTerminalFeature
@Default(.cornerRadiusScaling) var cornerRadiusScaling
@Default(.enableMinimalisticUI) var enableMinimalisticUI
@State private var suppressionToken = UUID()
@State private var isSuppressing = false
/// Top corners stay mild; bottom follows shell − padding (see `notchTerminalBottomCornerRadii`).
private static let terminalClipTopCornerRadius: CGFloat = 6
private var currentScreenName: String {
vm.screen ?? DynamicIslandViewCoordinator.shared.selectedScreen
}
private var isDynamicIslandMode: Bool {
shouldUseDynamicIslandMode(for: currentScreenName)
}
private var terminalClipShape: UnevenRoundedRectangle {
let innerBottom = notchTerminalBottomCornerRadii(
isDynamicIslandMode: isDynamicIslandMode,
notchState: vm.notchState,
cornerRadiusScaling: cornerRadiusScaling,
enableMinimalisticUI: enableMinimalisticUI,
closedNotchHeight: vm.closedNotchSize.height
).innerBottom
return UnevenRoundedRectangle(
topLeadingRadius: Self.terminalClipTopCornerRadius,
bottomLeadingRadius: innerBottom,
bottomTrailingRadius: innerBottom,
topTrailingRadius: Self.terminalClipTopCornerRadius,
style: .continuous
)
}
var body: some View {
VStack(spacing: 0) {
if enableTerminalFeature {
@ -121,15 +151,15 @@ struct NotchTerminalView: View {
.padding(.bottom, 4)
Divider()
.padding(.horizontal, 8)
.padding(.horizontal, notchTerminalContentEdgePadding.horizontal)
// Terminal content — the containerView is stable across
// notch close/open cycles; updateNSView handles restart.
TerminalNSViewRepresentable(terminalManager: terminalManager)
.clipShape(RoundedRectangle(cornerRadius: 6, style: .continuous))
.padding(.horizontal, 8)
.padding(.bottom, 8)
.padding(.top, 4)
.clipShape(terminalClipShape)
.padding(.horizontal, notchTerminalContentEdgePadding.horizontal)
.padding(.bottom, notchTerminalContentEdgePadding.bottom)
.padding(.top, notchTerminalContentEdgePadding.top)
.onHover { hovering in
updateSuppression(for: hovering)
}

View file

@ -897,7 +897,7 @@ struct SettingsView: View {
SettingsSearchEntry(tab: .terminal, title: "Enable terminal", keywords: ["terminal", "guake", "shell"], highlightID: SettingsTab.terminal.highlightID(for: "Enable terminal")),
SettingsSearchEntry(tab: .terminal, title: "Shell path", keywords: ["shell", "zsh", "bash", "terminal"], highlightID: SettingsTab.terminal.highlightID(for: "Shell path")),
SettingsSearchEntry(tab: .terminal, title: "Font size", keywords: ["terminal", "font", "text size"], highlightID: SettingsTab.terminal.highlightID(for: "Font size")),
SettingsSearchEntry(tab: .terminal, title: "Terminal opacity", keywords: ["terminal", "opacity", "transparency"], highlightID: SettingsTab.terminal.highlightID(for: "Terminal opacity")),
SettingsSearchEntry(tab: .terminal, title: "Terminal opacity", keywords: ["terminal", "opacity", "transparency", "blur", "background"], highlightID: SettingsTab.terminal.highlightID(for: "Terminal opacity")),
SettingsSearchEntry(tab: .terminal, title: "Maximum height", keywords: ["terminal", "height", "size"], highlightID: SettingsTab.terminal.highlightID(for: "Maximum height")),
SettingsSearchEntry(tab: .terminal, title: "Background color", keywords: ["terminal", "background", "color", "theme"], highlightID: SettingsTab.terminal.highlightID(for: "Background color")),
SettingsSearchEntry(tab: .terminal, title: "Foreground color", keywords: ["terminal", "foreground", "text color", "theme"], highlightID: SettingsTab.terminal.highlightID(for: "Foreground color")),
@ -7862,6 +7862,10 @@ struct TerminalSettings: View {
.settingsHighlight(id: highlightID("Maximum height"))
} header: {
Text("Appearance")
} footer: {
Text("Terminal opacity only affects the terminal backdrop; text stays fully opaque. Blur uses the system material behind the window.")
.font(.caption)
.foregroundStyle(.secondary)
}
// MARK: Colors