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

@@ -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)),
};
}
}