fix: avoid setting the terminal background color until we know what the system color scheme is

This was in the hope that it might fix kitty's behavior with
enable_terminal_color_scheme enabled. Unfortunately it makes no
difference to kitty (kitty stops sending color scheme updates). I
am commiting these changes anyway as it seems a little cleaner to
avoid setting the background color twice on startup.
This commit is contained in:
CJ van den Berg 2025-11-28 15:20:50 +01:00
parent f99e10652c
commit 11d6770913
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
2 changed files with 11 additions and 1 deletions

View file

@ -385,6 +385,8 @@ pub fn process_renderer_event(self: *Self, msg: []const u8) Error!void {
self.queries_done = true;
self.vx.enableDetectedFeatures(self.tty.writer()) catch |e| self.logger.err("enable features", e);
self.vx.setMouseMode(self.tty.writer(), true) catch return error.TtyWriteError;
self.logger.print("capability queries complete", .{});
if (self.dispatch_event) |f| f(self.handler_ctx, try self.fmtmsg(.{"capability_detection_complete"}));
},
.cap_kitty_keyboard => {
self.logger.print("kitty keyboard capability detected", .{});

View file

@ -207,7 +207,6 @@ fn init(allocator: Allocator) InitError!*Self {
}
self.mainview_ = try MainView.create(allocator);
resize();
self.set_terminal_style(self.current_theme());
try save_config();
try self.init_input_namespace();
if (tp.env.get().is("restore-session")) {
@ -516,15 +515,23 @@ fn receive_safe(self: *Self, from: tp.pid_ref, m: tp.message) !void {
}
if (try m.match(.{ "color_scheme", "dark" })) {
self.logger.print("system color scheme event: dark", .{});
self.set_color_scheme(.dark);
return;
}
if (try m.match(.{ "color_scheme", "light" })) {
self.logger.print("system color scheme event: light", .{});
self.set_color_scheme(.light);
return;
}
if (try m.match(.{"capability_detection_complete"})) {
if (!self.rdr_.vx.caps.color_scheme_updates)
self.set_terminal_style(self.current_theme());
return;
}
return tp.unexpected(m);
}
@ -1769,6 +1776,7 @@ pub const fallbacks: []const FallBack = &[_]FallBack{
};
fn set_terminal_style(self: *Self, theme_: *const Widget.Theme) void {
self.logger.print("set terminal style {s}", .{theme_.name});
self.rdr_.set_terminal_cursor_color(theme_.editor_cursor.bg.?);
if (self.rdr_.vx.caps.multi_cursor)
self.rdr_.set_terminal_secondary_cursor_color(theme_.editor_cursor_secondary.bg orelse theme_.editor_cursor.bg.?);