Skip to content

Commit

Permalink
fix(bar): update widgets background color properly
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
alex-ds13 authored and LGUG2Z committed Dec 21, 2024
1 parent 99353b8 commit d93b6fa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions komorebi-bar/src/bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ pub fn apply_theme(
bg_color_with_alpha: Rc<RefCell<Color32>>,
transparency_alpha: Option<u8>,
grouping: Option<Grouping>,
render_config: Rc<RefCell<RenderConfig>>,
) {
match theme {
KomobarTheme::Catppuccin {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -364,6 +368,7 @@ impl Komobar {
self.bg_color_with_alpha.clone(),
config.transparency_alpha,
config.grouping,
self.render_config.clone(),
);
}
None => {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -555,6 +561,7 @@ impl eframe::App for Komobar {
self.config.transparency_alpha,
self.config.grouping,
self.config.theme,
self.render_config.clone(),
);
}

Expand Down
4 changes: 4 additions & 0 deletions komorebi-bar/src/komorebi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ impl KomorebiNotificationState {
transparency_alpha: Option<u8>,
grouping: Option<Grouping>,
default_theme: Option<KomobarTheme>,
render_config: Rc<RefCell<RenderConfig>>,
) {
match rx_gui.try_recv() {
Err(error) => match error {
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -551,6 +554,7 @@ impl KomorebiNotificationState {
bg_color_with_alpha.clone(),
transparency_alpha,
grouping,
render_config,
);
tracing::info!("applied theme from komorebi socket message");
}
Expand Down

0 comments on commit d93b6fa

Please sign in to comment.