fix: disable renderer background when macOS effects are enabled

This commit is contained in:
Justy Null
2025-09-20 16:05:05 -07:00
committed by Mitchell Hashimoto
parent d40af61960
commit 45aceace72
5 changed files with 27 additions and 18 deletions

View File

@@ -3111,22 +3111,13 @@ keybind: Keybinds = .{},
///
/// Valid values are:
///
/// * `blur` - Uses the standard background behavior. The `background-blur`
/// * `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)
///
/// The `blur` option does not force any blur effect - it simply respects the
/// `background-blur` configuration. The glass options override `background-blur`
/// and apply their own visual effects.
///
/// On macOS versions prior to 26.0, only `blur` has an effect. The glass
/// options will fall back to `blur` behavior on older versions.
///
/// The default value is `blur`.
///
/// Available since: 1.2.2
@"macos-background-style": MacBackgroundStyle = .blur,
@"macos-background-style": MacBackgroundStyle = .default,
/// Put every surface (tab, split, window) into a dedicated Linux cgroup.
///
@@ -7714,7 +7705,7 @@ pub const MacShortcuts = enum {
/// See macos-background-style
pub const MacBackgroundStyle = enum {
blur,
default,
@"regular-glass",
@"clear-glass",
};

View File

@@ -561,6 +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,
pub fn init(
alloc_gpa: Allocator,
@@ -633,6 +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",
.arena = arena,
};
}
@@ -644,6 +646,16 @@ 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
@@ -716,7 +728,10 @@ pub fn Renderer(comptime GraphicsAPI: type) type {
options.config.background.r,
options.config.background.g,
options.config.background.b,
@intFromFloat(@round(options.config.background_opacity * 255.0)),
if (shouldDisableBackground(options.config))
0
else
@intFromFloat(@round(options.config.background_opacity * 255.0)),
},
.bools = .{
.cursor_wide = false,
@@ -1293,7 +1308,10 @@ 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,
@intFromFloat(@round(self.config.background_opacity * 255.0)),
if (shouldDisableBackground(self.config))
0
else
@intFromFloat(@round(self.config.background_opacity * 255.0)),
};
}
}