mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
config: need to apply window-theme for light/dark after loading theme
This commit is contained in:
@ -1554,10 +1554,10 @@ keybind: Keybinds = .{},
|
|||||||
/// The proxy icon is only visible with the native macOS titlebar style.
|
/// The proxy icon is only visible with the native macOS titlebar style.
|
||||||
///
|
///
|
||||||
/// Valid values are:
|
/// Valid values are:
|
||||||
///
|
///
|
||||||
/// * `visible` - Show the proxy icon.
|
/// * `visible` - Show the proxy icon.
|
||||||
/// * `hidden` - Hide the proxy icon.
|
/// * `hidden` - Hide the proxy icon.
|
||||||
///
|
///
|
||||||
/// The default value is `visible`.
|
/// The default value is `visible`.
|
||||||
///
|
///
|
||||||
/// This setting can be changed at runtime and will affect all currently
|
/// This setting can be changed at runtime and will affect all currently
|
||||||
@ -2752,17 +2752,19 @@ pub fn finalize(self: *Config) !void {
|
|||||||
// We always load the theme first because it may set other fields
|
// We always load the theme first because it may set other fields
|
||||||
// in our config.
|
// in our config.
|
||||||
if (self.theme) |theme| {
|
if (self.theme) |theme| {
|
||||||
// If we have different light vs dark mode themes, disable
|
const different = !std.mem.eql(u8, theme.light, theme.dark);
|
||||||
// window-theme = auto since that breaks it.
|
|
||||||
if (!std.mem.eql(u8, theme.light, theme.dark)) {
|
|
||||||
// This setting doesn't make sense with different light/dark themes
|
|
||||||
// because it'll force the theme based on the Ghostty theme.
|
|
||||||
if (self.@"window-theme" == .auto) self.@"window-theme" = .system;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Warning: loadTheme will deinit our existing config and replace
|
// Warning: loadTheme will deinit our existing config and replace
|
||||||
// it so all memory from self prior to this point will be freed.
|
// it so all memory from self prior to this point will be freed.
|
||||||
try self.loadTheme(theme);
|
try self.loadTheme(theme);
|
||||||
|
|
||||||
|
// If we have different light vs dark mode themes, disable
|
||||||
|
// window-theme = auto since that breaks it.
|
||||||
|
if (different) {
|
||||||
|
// This setting doesn't make sense with different light/dark themes
|
||||||
|
// because it'll force the theme based on the Ghostty theme.
|
||||||
|
if (self.@"window-theme" == .auto) self.@"window-theme" = .system;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const alloc = self._arena.?.allocator();
|
const alloc = self._arena.?.allocator();
|
||||||
@ -5380,3 +5382,21 @@ test "theme loading correct light/dark" {
|
|||||||
}, new.background);
|
}, new.background);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "theme specifying light/dark changes window-theme from auto" {
|
||||||
|
const testing = std.testing;
|
||||||
|
const alloc = testing.allocator;
|
||||||
|
|
||||||
|
{
|
||||||
|
var cfg = try Config.default(alloc);
|
||||||
|
defer cfg.deinit();
|
||||||
|
var it: TestIterator = .{ .data = &.{
|
||||||
|
"--theme=light:foo,dark:bar",
|
||||||
|
"--window-theme=auto",
|
||||||
|
} };
|
||||||
|
try cfg.loadIter(alloc, &it);
|
||||||
|
try cfg.finalize();
|
||||||
|
|
||||||
|
try testing.expect(cfg.@"window-theme" == .system);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user