From d93b6fa1b3d66b3abb05682ce4f1e1fb6855dfa4 Mon Sep 17 00:00:00 2001 From: alex-ds13 <145657253+alex-ds13@users.noreply.github.com> Date: Sat, 21 Dec 2024 10:17:36 +0000 Subject: [PATCH] fix(bar): update widgets background color properly Previously when changing between themes with different backgrounds the widget's background color was not updating because they take the bg color from the `RenderConfig` which was only being updated on `apply_config`, now we also pass the `RenderConfig` to the `apply_theme` function and update it's `background_color` there as well. --- komorebi-bar/src/bar.rs | 7 +++++++ komorebi-bar/src/komorebi.rs | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/komorebi-bar/src/bar.rs b/komorebi-bar/src/bar.rs index 8ba7f661..0f26e1e4 100644 --- a/komorebi-bar/src/bar.rs +++ b/komorebi-bar/src/bar.rs @@ -71,6 +71,7 @@ pub fn apply_theme( bg_color_with_alpha: Rc>, transparency_alpha: Option, grouping: Option, + render_config: Rc>, ) { match theme { KomobarTheme::Catppuccin { @@ -171,6 +172,9 @@ pub fn apply_theme( }); } } + + // Update RenderConfig's background_color so that widgets will have the new color + render_config.borrow_mut().background_color = *bg_color.borrow(); } impl Komobar { @@ -364,6 +368,7 @@ impl Komobar { self.bg_color_with_alpha.clone(), config.transparency_alpha, config.grouping, + self.render_config.clone(), ); } None => { @@ -393,6 +398,7 @@ impl Komobar { self.bg_color_with_alpha.clone(), bar_transparency_alpha, bar_grouping, + self.render_config.clone(), ); let stack_accent = match theme { @@ -555,6 +561,7 @@ impl eframe::App for Komobar { self.config.transparency_alpha, self.config.grouping, self.config.theme, + self.render_config.clone(), ); } diff --git a/komorebi-bar/src/komorebi.rs b/komorebi-bar/src/komorebi.rs index 33ae67c6..f0adc581 100644 --- a/komorebi-bar/src/komorebi.rs +++ b/komorebi-bar/src/komorebi.rs @@ -502,6 +502,7 @@ impl KomorebiNotificationState { transparency_alpha: Option, grouping: Option, default_theme: Option, + render_config: Rc>, ) { match rx_gui.try_recv() { Err(error) => match error { @@ -526,6 +527,7 @@ impl KomorebiNotificationState { bg_color_with_alpha.clone(), transparency_alpha, grouping, + render_config, ); tracing::info!("applied theme from updated komorebi.json"); } else if let Some(default_theme) = default_theme { @@ -536,6 +538,7 @@ impl KomorebiNotificationState { bg_color_with_alpha.clone(), transparency_alpha, grouping, + render_config, ); tracing::info!("removed theme from updated komorebi.json and applied default theme"); } else { @@ -551,6 +554,7 @@ impl KomorebiNotificationState { bg_color_with_alpha.clone(), transparency_alpha, grouping, + render_config, ); tracing::info!("applied theme from komorebi socket message"); }