Skip to content

Commit

Permalink
fix(bar): fix background color clobbering
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-ds13 authored and LGUG2Z committed Dec 20, 2024
1 parent 0e2a55b commit eb8a988
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
16 changes: 12 additions & 4 deletions komorebi-bar/src/bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,15 @@ pub struct Komobar {
pub rx_gui: Receiver<komorebi_client::Notification>,
pub rx_config: Receiver<KomobarConfig>,
pub bg_color: Rc<RefCell<Color32>>,
pub bg_color_with_alpha: Rc<RefCell<Color32>>,
pub scale_factor: f32,
}

pub fn apply_theme(
ctx: &Context,
theme: KomobarTheme,
bg_color: Rc<RefCell<Color32>>,
bg_color_with_alpha: Rc<RefCell<Color32>>,
transparency_alpha: Option<u8>,
grouping: Option<Grouping>,
) {
Expand Down Expand Up @@ -150,7 +152,7 @@ pub fn apply_theme(
// Apply transparency_alpha
let theme_color = *bg_color.borrow();

bg_color.replace(theme_color.try_apply_alpha(transparency_alpha));
bg_color_with_alpha.replace(theme_color.try_apply_alpha(transparency_alpha));

// apply rounding to the widgets
if let Some(Grouping::Bar(config) | Grouping::Alignment(config) | Grouping::Widget(config)) =
Expand Down Expand Up @@ -236,6 +238,7 @@ impl Komobar {
ctx,
theme,
self.bg_color.clone(),
self.bg_color_with_alpha.clone(),
config.transparency_alpha,
config.grouping,
);
Expand Down Expand Up @@ -264,6 +267,7 @@ impl Komobar {
ctx,
KomobarTheme::from(theme),
self.bg_color.clone(),
self.bg_color_with_alpha.clone(),
bar_transparency_alpha,
bar_grouping,
);
Expand All @@ -290,7 +294,9 @@ impl Komobar {

// apply rounding to the widgets since we didn't call `apply_theme`
if let Some(
Grouping::Bar(config) | Grouping::Alignment(config) | Grouping::Widget(config),
Grouping::Bar(config)
| Grouping::Alignment(config)
| Grouping::Widget(config),
) = &bar_grouping
{
if let Some(rounding) = config.rounding {
Expand Down Expand Up @@ -440,6 +446,7 @@ impl Komobar {
rx_gui,
rx_config,
bg_color: Rc::new(RefCell::new(Style::default().visuals.panel_fill)),
bg_color_with_alpha: Rc::new(RefCell::new(Style::default().visuals.panel_fill)),
scale_factor: cc.egui_ctx.native_pixels_per_point().unwrap_or(1.0),
};

Expand Down Expand Up @@ -535,6 +542,7 @@ impl eframe::App for Komobar {
self.config.monitor.index,
self.rx_gui.clone(),
self.bg_color.clone(),
self.bg_color_with_alpha.clone(),
self.config.transparency_alpha,
self.config.grouping,
self.config.theme,
Expand All @@ -547,9 +555,9 @@ impl eframe::App for Komobar {
frame.inner_margin.x,
frame.inner_margin.y,
))
.fill(*self.bg_color.borrow())
.fill(*self.bg_color_with_alpha.borrow())
} else {
Frame::none().fill(*self.bg_color.borrow())
Frame::none().fill(*self.bg_color_with_alpha.borrow())
};

let mut render_config = self.render_config.borrow_mut();
Expand Down
5 changes: 5 additions & 0 deletions komorebi-bar/src/komorebi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,12 +491,14 @@ impl KomorebiNotificationState {
self.hide_empty_workspaces = config.hide_empty_workspaces;
}

#[allow(clippy::too_many_arguments)]
pub fn handle_notification(
&mut self,
ctx: &Context,
monitor_index: usize,
rx_gui: Receiver<komorebi_client::Notification>,
bg_color: Rc<RefCell<Color32>>,
bg_color_with_alpha: Rc<RefCell<Color32>>,
transparency_alpha: Option<u8>,
grouping: Option<Grouping>,
default_theme: Option<KomobarTheme>,
Expand All @@ -521,6 +523,7 @@ impl KomorebiNotificationState {
ctx,
KomobarTheme::from(theme),
bg_color.clone(),
bg_color_with_alpha.clone(),
transparency_alpha,
grouping,
);
Expand All @@ -530,6 +533,7 @@ impl KomorebiNotificationState {
ctx,
default_theme,
bg_color.clone(),
bg_color_with_alpha.clone(),
transparency_alpha,
grouping,
);
Expand All @@ -544,6 +548,7 @@ impl KomorebiNotificationState {
ctx,
KomobarTheme::from(theme),
bg_color,
bg_color_with_alpha.clone(),
transparency_alpha,
grouping,
);
Expand Down

0 comments on commit eb8a988

Please sign in to comment.