Skip to content

Commit

Permalink
fix: lock the hiddenid
Browse files Browse the repository at this point in the history
since update and set_id_info is not in the same thread, so here need to
lock
  • Loading branch information
Decodetalkers committed Sep 20, 2024
1 parent 9374df2 commit 64dde48
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lala_bar/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ struct LalaMusicBar {
launcher: Option<launcher::Launcher>,
launcherid: Option<iced::window::Id>,
hiddenid: Option<iced::window::Id>,
hiddenid_lock: bool,
right_panel: Option<iced::window::Id>,
notifications: HashMap<u32, NotifyUnitWidgetInfo>,
showned_notifications: HashMap<iced::window::Id, u32>,
Expand Down Expand Up @@ -776,6 +777,7 @@ impl MultiApplication for LalaMusicBar {
launcherid: None,
right_panel: None,
hiddenid: None,
hiddenid_lock: false,
notifications: HashMap::new(),
showned_notifications: HashMap::new(),
cached_notifications: HashMap::new(),
Expand Down Expand Up @@ -826,6 +828,7 @@ impl MultiApplication for LalaMusicBar {
self.showned_notifications.insert(id, notify.unit.id);
}
LaLaInfo::HiddenInfo => {
self.hiddenid_lock = false;
self.hiddenid = Some(id);
}
LaLaInfo::RightPanel => self.right_panel = Some(id),
Expand Down Expand Up @@ -1081,10 +1084,13 @@ impl MultiApplication for LalaMusicBar {
}
}

if self.notifications.len() > MAX_SHOWN_NOTIFICATIONS_COUNT
self.update_hidden_notification();

if !self.hidden_notification().is_empty()
&& self.hiddenid.is_none()
&& !self.quite_mode
&& !self.hiddenid_lock
{
self.hiddenid_lock = true;
commands.push(Command::done(Message::NewLayerShell {
settings: NewLayerShellSettings {
size: Some((300, 25)),
Expand All @@ -1098,7 +1104,7 @@ impl MultiApplication for LalaMusicBar {
info: LaLaInfo::HiddenInfo,
}));
}
self.update_hidden_notification();

return Command::batch(commands);
}

Expand Down

0 comments on commit 64dde48

Please sign in to comment.