Skip to content

Commit

Permalink
Merge pull request #425 from JakeStanger/fix/tray
Browse files Browse the repository at this point in the history
Tray rewrite
  • Loading branch information
JakeStanger authored Feb 1, 2024
2 parents d58d895 + 133632d commit ef41462
Show file tree
Hide file tree
Showing 9 changed files with 666 additions and 282 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ mpris = { version = "2.0.1", optional = true }
sysinfo = { version = "0.29.11", optional = true }

# tray
system-tray = { version = "0.1.4", optional = true }
system-tray = { version = "0.1.5", optional = true }

# upower
upower_dbus = { version = "0.3.2", optional = true }
Expand Down
4 changes: 2 additions & 2 deletions src/clients/system_tray.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl TrayEventReceiver {
let id = format!("ironbar-{}", Ironbar::unique_id());

let (tx, rx) = mpsc::channel(16);
let (b_tx, b_rx) = broadcast::channel(16);
let (b_tx, b_rx) = broadcast::channel(64);

let tray = StatusNotifierWatcher::new(rx).await?;
let mut host = Box::pin(tray.create_notifier_host(&id)).await?;
Expand All @@ -48,7 +48,7 @@ impl TrayEventReceiver {
item,
menu,
} => {
debug!("Adding item with address '{address}'");
debug!("Adding/updating item with address '{address}'");
tray.insert(address, (item, menu));
}
NotifierItemMessage::Remove { address } => {
Expand Down
13 changes: 11 additions & 2 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,17 @@ macro_rules! glib_recv {
glib::spawn_future_local(async move {
// re-delcare in case ie `context.subscribe()` is passed directly
let mut rx = $rx;
while let Ok($val) = rx.recv().await {
$expr
loop {
match rx.recv().await {
Ok($val) => $expr,
Err(tokio::sync::broadcast::error::RecvError::Lagged(count)) => {
tracing::warn!("Channel lagged behind by {count}, this may result in unexpected or broken behaviour");
}
Err(err) => {
tracing::error!("{err:?}");
break;
}
}
}
});
}};
Expand Down
275 changes: 0 additions & 275 deletions src/modules/tray.rs

This file was deleted.

Loading

0 comments on commit ef41462

Please sign in to comment.