From cd90821b937ce4f9619eac2e5606012b155cefe0 Mon Sep 17 00:00:00 2001 From: Leah Amelia Chen Date: Thu, 2 Jan 2025 21:44:16 +0800 Subject: [PATCH] fix(gtk): adjust `background` CSS class dynamically on config reload Currently the `background` CSS class is added once on startup and never removed or re-added. This is problematic as that if Ghostty was started with an opaque window but then its config was reloaded with a `background-opacity` less than 1, the window won't actually become translucent, and it would only appear as if the background colors had become faded (because the window is still styled to be opaque). --- src/apprt/gtk/Window.zig | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/apprt/gtk/Window.zig b/src/apprt/gtk/Window.zig index 26598d03a..554584127 100644 --- a/src/apprt/gtk/Window.zig +++ b/src/apprt/gtk/Window.zig @@ -119,11 +119,6 @@ pub fn init(self: *Window, app: *App) !void { c.gtk_widget_add_css_class(@ptrCast(gtk_window), "window-theme-ghostty"); } - // Remove the window's background if any of the widgets need to be transparent - if (app.config.@"background-opacity" < 1) { - c.gtk_widget_remove_css_class(@ptrCast(window), "background"); - } - // Create our box which will hold our widgets in the main content area. const box = c.gtk_box_new(c.GTK_ORIENTATION_VERTICAL, 0); @@ -398,6 +393,12 @@ pub fn init(self: *Window, app: *App) !void { /// TODO: Many of the initial style settings in `create` could possibly be made /// reactive by moving them here. pub fn syncAppearance(self: *Window, config: *const configpkg.Config) !void { + if (config.@"background-opacity" < 1) { + c.gtk_widget_remove_css_class(@ptrCast(self.window), "background"); + } else { + c.gtk_widget_add_css_class(@ptrCast(self.window), "background"); + } + if (self.wayland) |*wl| { try wl.setBlur(config.@"background-blur-radius" > 0); }