Skip to content

Commit ef41462

Browse files
authored
Merge pull request #425 from JakeStanger/fix/tray
Tray rewrite
2 parents d58d895 + 133632d commit ef41462

File tree

9 files changed

+666
-282
lines changed

9 files changed

+666
-282
lines changed

Cargo.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ mpris = { version = "2.0.1", optional = true }
125125
sysinfo = { version = "0.29.11", optional = true }
126126

127127
# tray
128-
system-tray = { version = "0.1.4", optional = true }
128+
system-tray = { version = "0.1.5", optional = true }
129129

130130
# upower
131131
upower_dbus = { version = "0.3.2", optional = true }

src/clients/system_tray.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ impl TrayEventReceiver {
2525
let id = format!("ironbar-{}", Ironbar::unique_id());
2626

2727
let (tx, rx) = mpsc::channel(16);
28-
let (b_tx, b_rx) = broadcast::channel(16);
28+
let (b_tx, b_rx) = broadcast::channel(64);
2929

3030
let tray = StatusNotifierWatcher::new(rx).await?;
3131
let mut host = Box::pin(tray.create_notifier_host(&id)).await?;
@@ -48,7 +48,7 @@ impl TrayEventReceiver {
4848
item,
4949
menu,
5050
} => {
51-
debug!("Adding item with address '{address}'");
51+
debug!("Adding/updating item with address '{address}'");
5252
tray.insert(address, (item, menu));
5353
}
5454
NotifierItemMessage::Remove { address } => {

src/macros.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,17 @@ macro_rules! glib_recv {
6262
glib::spawn_future_local(async move {
6363
// re-delcare in case ie `context.subscribe()` is passed directly
6464
let mut rx = $rx;
65-
while let Ok($val) = rx.recv().await {
66-
$expr
65+
loop {
66+
match rx.recv().await {
67+
Ok($val) => $expr,
68+
Err(tokio::sync::broadcast::error::RecvError::Lagged(count)) => {
69+
tracing::warn!("Channel lagged behind by {count}, this may result in unexpected or broken behaviour");
70+
}
71+
Err(err) => {
72+
tracing::error!("{err:?}");
73+
break;
74+
}
75+
}
6776
}
6877
});
6978
}};

src/modules/tray.rs

-275
This file was deleted.

0 commit comments

Comments
 (0)