remove the macos-background-style config

pull/8801/head
Mitchell Hashimoto 2025-12-15 10:48:20 -08:00
parent bb23071166
commit a6ddf03a2e
No known key found for this signature in database
GPG Key ID: 523D5DC389D273BC
6 changed files with 42 additions and 68 deletions

View File

@ -480,7 +480,7 @@ class TerminalWindow: NSWindow {
backgroundColor = .white.withAlphaComponent(0.001)
// Add liquid glass behind terminal content
if #available(macOS 26.0, *), derivedConfig.macosBackgroundStyle != .defaultStyle {
if #available(macOS 26.0, *), derivedConfig.backgroundBlur.isGlassStyle {
setupGlassLayer()
} else if let appDelegate = NSApp.delegate as? AppDelegate {
ghostty_set_window_background_blur(
@ -590,14 +590,13 @@ class TerminalWindow: NSWindow {
let effectView = NSGlassEffectView()
// Map Ghostty config to NSGlassEffectView style
let backgroundStyle = derivedConfig.macosBackgroundStyle
switch backgroundStyle {
case .regularGlass:
switch derivedConfig.backgroundBlur {
case .macosGlassRegular:
effectView.style = NSGlassEffectView.Style.regular
case .clearGlass:
case .macosGlassClear:
effectView.style = NSGlassEffectView.Style.clear
default:
// Should not reach here since we check for "default" before calling setupGlassLayer()
// Should not reach here since we check for glass style before calling setupGlassLayer()
return
}
@ -623,10 +622,10 @@ class TerminalWindow: NSWindow {
struct DerivedConfig {
let title: String?
let backgroundBlur: Ghostty.Config.BackgroundBlur
let backgroundColor: NSColor
let backgroundOpacity: Double
let macosWindowButtons: Ghostty.MacOSWindowButtons
let macosBackgroundStyle: Ghostty.MacBackgroundStyle
let macosTitlebarStyle: String
let windowCornerRadius: CGFloat
@ -635,7 +634,7 @@ class TerminalWindow: NSWindow {
self.backgroundColor = NSColor.windowBackgroundColor
self.backgroundOpacity = 1
self.macosWindowButtons = .visible
self.macosBackgroundStyle = .defaultStyle
self.backgroundBlur = .disabled
self.macosTitlebarStyle = "transparent"
self.windowCornerRadius = 16
}
@ -645,7 +644,7 @@ class TerminalWindow: NSWindow {
self.backgroundColor = NSColor(config.backgroundColor)
self.backgroundOpacity = config.backgroundOpacity
self.macosWindowButtons = config.macosWindowButtons
self.macosBackgroundStyle = config.macosBackgroundStyle
self.backgroundBlur = config.backgroundBlur
self.macosTitlebarStyle = config.macosTitlebarStyle
// Set corner radius based on macos-titlebar-style

View File

@ -91,8 +91,7 @@ class TransparentTitlebarTerminalWindow: TerminalWindow {
// For glass background styles, use a transparent titlebar to let the glass effect show through
// Only apply this for transparent and tabs titlebar styles
let isGlassStyle = derivedConfig.macosBackgroundStyle == .regularGlass ||
derivedConfig.macosBackgroundStyle == .clearGlass
let isGlassStyle = derivedConfig.backgroundBlur.isGlassStyle
let isTransparentTitlebar = derivedConfig.macosTitlebarStyle == "transparent" ||
derivedConfig.macosTitlebarStyle == "tabs"

View File

@ -261,17 +261,6 @@ extension Ghostty {
return MacOSWindowButtons(rawValue: str) ?? defaultValue
}
var macosBackgroundStyle: MacBackgroundStyle {
let defaultValue = MacBackgroundStyle.defaultStyle
guard let config = self.config else { return defaultValue }
var v: UnsafePointer<Int8>? = nil
let key = "macos-background-style"
guard ghostty_config_get(config, &v, key, UInt(key.count)) else { return defaultValue }
guard let ptr = v else { return defaultValue }
let str = String(cString: ptr)
return MacBackgroundStyle(rawValue: str) ?? defaultValue
}
var macosTitlebarStyle: String {
let defaultValue = "transparent"
guard let config = self.config else { return defaultValue }
@ -668,6 +657,16 @@ extension Ghostty.Config {
}
}
/// Returns true if this is a macOS glass style (regular or clear).
var isGlassStyle: Bool {
switch self {
case .macosGlassRegular, .macosGlassClear:
return true
default:
return false
}
}
/// Returns the blur radius if applicable, nil for glass effects.
var radius: Int? {
switch self {

View File

@ -352,13 +352,6 @@ extension Ghostty {
case hidden
}
/// Enum for the macos-background-style config option
enum MacBackgroundStyle: String {
case defaultStyle = "default"
case regularGlass = "regular-glass"
case clearGlass = "clear-glass"
}
/// Enum for auto-update-channel config option
enum AutoUpdateChannel: String {
case tip

View File

@ -927,6 +927,12 @@ palette: Palette = .{},
/// reasonable for a good looking blur. Higher blur intensities may
/// cause strange rendering and performance issues.
///
/// On macOS 26.0 and later, there are additional special values that
/// can be set to use the native macOS glass effects:
///
/// * `macos-glass-regular` - Standard glass effect with some opacity
/// * `macos-glass-clear` - Highly transparent glass effect
///
/// Supported on macOS and on some Linux desktop environments, including:
///
/// * KDE Plasma (Wayland and X11)
@ -3106,22 +3112,6 @@ keybind: Keybinds = .{},
/// Available since: 1.2.0
@"macos-shortcuts": MacShortcuts = .ask,
/// The background style for macOS windows when `background-opacity` is less
/// than 1. This controls the visual effect applied behind the terminal
/// background.
///
/// Valid values are:
///
/// * `default` - Uses the standard background behavior. The `background-blur`
/// configuration will control whether blur is applied (available on
/// all macOS versions)
/// * `regular-glass` - Standard glass effect with some opacity (macOS
/// 26.0+ only)
/// * `clear-glass` - Highly transparent glass effect (macOS 26.0+ only)
///
/// Available since: 1.3.0
@"macos-background-style": MacBackgroundStyle = .default,
/// Put every surface (tab, split, window) into a dedicated Linux cgroup.
///
/// This makes it so that resource management can be done on a per-surface
@ -7706,13 +7696,6 @@ pub const MacShortcuts = enum {
ask,
};
/// See macos-background-style
pub const MacBackgroundStyle = enum {
default,
@"regular-glass",
@"clear-glass",
};
/// See gtk-single-instance
pub const GtkSingleInstance = enum {
false,

View File

@ -561,7 +561,7 @@ pub fn Renderer(comptime GraphicsAPI: type) type {
vsync: bool,
colorspace: configpkg.Config.WindowColorspace,
blending: configpkg.Config.AlphaBlending,
macos_background_style: configpkg.Config.MacBackgroundStyle,
background_blur: configpkg.Config.BackgroundBlur,
pub fn init(
alloc_gpa: Allocator,
@ -634,7 +634,7 @@ pub fn Renderer(comptime GraphicsAPI: type) type {
.vsync = config.@"window-vsync",
.colorspace = config.@"window-colorspace",
.blending = config.@"alpha-blending",
.macos_background_style = config.@"macos-background-style",
.background_blur = config.@"background-blur",
.arena = arena,
};
}
@ -646,16 +646,6 @@ pub fn Renderer(comptime GraphicsAPI: type) type {
}
};
/// Determines if the terminal background should be disabled based on platform and config.
/// On macOS, when background effects are enabled (background style != default), the effect
/// layer handles the background rendering instead of the terminal renderer.
fn shouldDisableBackground(config: DerivedConfig) bool {
return switch (builtin.os.tag) {
.macos => config.macos_background_style != .default,
else => false,
};
}
pub fn init(alloc: Allocator, options: renderer.Options) !Self {
// Initialize our graphics API wrapper, this will prepare the
// surface provided by the apprt and set up any API-specific
@ -728,6 +718,9 @@ pub fn Renderer(comptime GraphicsAPI: type) type {
options.config.background.r,
options.config.background.g,
options.config.background.b,
// Note that if we're on macOS with glass effects
// we'll disable background opacity but we handle
// that in updateFrame.
@intFromFloat(@round(options.config.background_opacity * 255.0)),
},
.bools = .{
@ -1305,10 +1298,18 @@ pub fn Renderer(comptime GraphicsAPI: type) type {
self.terminal_state.colors.background.r,
self.terminal_state.colors.background.g,
self.terminal_state.colors.background.b,
if (shouldDisableBackground(self.config))
0
else
@intFromFloat(@round(self.config.background_opacity * 255.0)),
@intFromFloat(@round(self.config.background_opacity * 255.0)),
};
// If we're on macOS and have glass styles, we remove
// the background opacity because the glass effect handles
// it.
if (comptime builtin.os.tag == .macos) switch (self.config.background_blur) {
.@"macos-glass-regular",
.@"macos-glass-clear",
=> self.uniforms.bg_color[3] = 0,
else => {},
};
}
}