mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-08-17 14:51:04 +02:00
fix(keyboard): panic when layout update channel lags behind (#869)
Fixes #866
This commit is contained in:
parent
452e85f5f6
commit
551e1ce691
3 changed files with 16 additions and 5 deletions
|
@ -25,7 +25,7 @@ pub struct Client {
|
||||||
impl Client {
|
impl Client {
|
||||||
pub(crate) fn new() -> Self {
|
pub(crate) fn new() -> Self {
|
||||||
let (workspace_tx, workspace_rx) = channel(16);
|
let (workspace_tx, workspace_rx) = channel(16);
|
||||||
let (keyboard_layout_tx, keyboard_layout_rx) = channel(4);
|
let (keyboard_layout_tx, keyboard_layout_rx) = channel(16);
|
||||||
|
|
||||||
let instance = Self {
|
let instance = Self {
|
||||||
workspace_tx,
|
workspace_tx,
|
||||||
|
|
|
@ -166,7 +166,7 @@ impl KeyboardLayoutClient for Client {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn subscribe(&self) -> Receiver<KeyboardLayoutUpdate> {
|
fn subscribe(&self) -> Receiver<KeyboardLayoutUpdate> {
|
||||||
let (tx, rx) = channel(4);
|
let (tx, rx) = channel(16);
|
||||||
|
|
||||||
let client = self.connection().clone();
|
let client = self.connection().clone();
|
||||||
|
|
||||||
|
|
|
@ -210,10 +210,21 @@ impl Module<gtk::Box> for KeyboardModule {
|
||||||
|
|
||||||
trace!("Set up keyboard_layout subscription");
|
trace!("Set up keyboard_layout subscription");
|
||||||
|
|
||||||
while let Ok(payload) = srx.recv().await {
|
loop {
|
||||||
|
match srx.recv().await {
|
||||||
|
Ok(payload) => {
|
||||||
debug!("Received update: {payload:?}");
|
debug!("Received update: {payload:?}");
|
||||||
module_update!(tx, KeyboardUpdate::Layout(payload));
|
module_update!(tx, KeyboardUpdate::Layout(payload));
|
||||||
}
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue