apprt/gtk: support dark window decorations with GtkWindow

Add support for the dark GtkWindow variant when `window-theme` is
`dark` or `auto`.
This commit is contained in:
Iain H
2024-12-23 19:50:57 -05:00
parent 42cdaa4545
commit 415902fe83

View File

@ -221,6 +221,9 @@ pub fn init(core_app: *CoreApp, opts: Options) !App {
switch (config.@"window-theme") { switch (config.@"window-theme") {
.system, .light => {}, .system, .light => {},
.dark => { .dark => {
const settings = c.gtk_settings_get_default();
c.g_object_set(@ptrCast(@alignCast(settings)), "gtk-application-prefer-dark-theme", true, @as([*c]const u8, null));
c.gtk_css_provider_load_from_resource( c.gtk_css_provider_load_from_resource(
provider, provider,
"/com/mitchellh/ghostty/style-dark.css", "/com/mitchellh/ghostty/style-dark.css",
@ -234,6 +237,9 @@ pub fn init(core_app: *CoreApp, opts: Options) !App {
.auto, .ghostty => { .auto, .ghostty => {
const lum = config.background.toTerminalRGB().perceivedLuminance(); const lum = config.background.toTerminalRGB().perceivedLuminance();
if (lum <= 0.5) { if (lum <= 0.5) {
const settings = c.gtk_settings_get_default();
c.g_object_set(@ptrCast(@alignCast(settings)), "gtk-application-prefer-dark-theme", true, @as([*c]const u8, null));
c.gtk_css_provider_load_from_resource( c.gtk_css_provider_load_from_resource(
provider, provider,
"/com/mitchellh/ghostty/style-dark.css", "/com/mitchellh/ghostty/style-dark.css",