diff --git a/Cargo.lock b/Cargo.lock index 68927549..97e1b3e8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1220,9 +1220,9 @@ dependencies = [ [[package]] name = "glib" -version = "0.18.4" +version = "0.18.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "951bbd7fdc5c044ede9f05170f05a3ae9479239c3afdfe2d22d537a3add15c4e" +checksum = "233daaf6e83ae6a12a52055f568f9d7cf4671dabb78ff9560ab6da230ce00ee5" dependencies = [ "bitflags 2.4.0", "futures-channel", diff --git a/Cargo.toml b/Cargo.toml index beaa7cf5..6fb9dca8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -65,7 +65,7 @@ workspaces = ["futures-util"] # core gtk = "0.18.1" gtk-layer-shell = "0.8.0" -glib = "0.18.4" +glib = "0.18.5" tokio = { version = "1.35.1", features = [ "macros", "rt-multi-thread", diff --git a/src/clients/compositor/hyprland.rs b/src/clients/compositor/hyprland.rs index f0f1ccf0..74f0d85e 100644 --- a/src/clients/compositor/hyprland.rs +++ b/src/clients/compositor/hyprland.rs @@ -84,7 +84,6 @@ impl EventClient { }, |workspace| { // there may be another type of update so dispatch that regardless of focus change - send!(tx, WorkspaceUpdate::Update(workspace.clone())); if !workspace.visibility.is_focused() { Self::send_focus_change(&mut prev_workspace, workspace, &tx); } diff --git a/src/clients/compositor/mod.rs b/src/clients/compositor/mod.rs index 484d3602..c703ff50 100644 --- a/src/clients/compositor/mod.rs +++ b/src/clients/compositor/mod.rs @@ -116,13 +116,17 @@ pub enum WorkspaceUpdate { Init(Vec), Add(Workspace), Remove(String), - Update(Workspace), Move(Workspace), /// Declares focus moved from the old workspace to the new. Focus { old: Option, new: Workspace, }, + /// An update was triggered by the compositor but this was not mapped by Ironbar. + /// + /// This is purely used for ergonomics within the compositor clients + /// and should be ignored by consumers. + Unknown, } pub trait WorkspaceClient { diff --git a/src/clients/compositor/sway.rs b/src/clients/compositor/sway.rs index 40f1b24e..7906ab16 100644 --- a/src/clients/compositor/sway.rs +++ b/src/clients/compositor/sway.rs @@ -31,8 +31,11 @@ impl SwayEventClient { while let Some(event) = events.next().await { trace!("event: {:?}", event); - if let Event::Workspace(ev) = event? { - workspace_tx.send(WorkspaceUpdate::from(*ev))?; + if let Event::Workspace(event) = event? { + let event = WorkspaceUpdate::from(*event); + if !matches!(event, WorkspaceUpdate::Unknown) { + workspace_tx.send(event)?; + } }; } @@ -172,7 +175,7 @@ impl From for WorkspaceUpdate { WorkspaceChange::Move => { Self::Move(event.current.expect("Missing current workspace").into()) } - _ => Self::Update(event.current.expect("Missing current workspace").into()), + _ => Self::Unknown, } } } diff --git a/src/config/mod.rs b/src/config/mod.rs index 357fb2c7..faa5ecaf 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -26,7 +26,7 @@ use serde::Deserialize; use std::collections::HashMap; pub use self::common::{CommonConfig, TransitionType}; -pub use self::truncate::{EllipsizeMode, TruncateMode}; +pub use self::truncate::TruncateMode; #[derive(Debug, Deserialize, Clone)] #[serde(tag = "type", rename_all = "snake_case")] diff --git a/src/dynamic_value/dynamic_bool.rs b/src/dynamic_value/dynamic_bool.rs index 711a92a4..31e149ab 100644 --- a/src/dynamic_value/dynamic_bool.rs +++ b/src/dynamic_value/dynamic_bool.rs @@ -39,7 +39,7 @@ impl DynamicBool { _ => self, }; - let (tx, mut rx) = mpsc::channel(32); + let (tx, rx) = mpsc::channel(32); glib_recv_mpsc!(rx, val => f(val)); diff --git a/src/dynamic_value/dynamic_string.rs b/src/dynamic_value/dynamic_string.rs index 7654f97e..ea2eb39b 100644 --- a/src/dynamic_value/dynamic_string.rs +++ b/src/dynamic_value/dynamic_string.rs @@ -32,7 +32,7 @@ where let tokens = parse_input(input); let label_parts = arc_mut!(vec![]); - let (tx, mut rx) = mpsc::channel(32); + let (tx, rx) = mpsc::channel(32); for (i, segment) in tokens.into_iter().enumerate() { match segment { diff --git a/src/image/provider.rs b/src/image/provider.rs index defefb61..a23debfe 100644 --- a/src/image/provider.rs +++ b/src/image/provider.rs @@ -145,7 +145,7 @@ impl<'a> ImageProvider<'a> { #[cfg(feature = "http")] if let ImageLocation::Remote(url) = &self.location { let url = url.clone(); - let (tx, mut rx) = mpsc::channel(64); + let (tx, rx) = mpsc::channel(64); spawn(async move { let bytes = Self::get_bytes_from_http(url).await; diff --git a/src/ipc/server.rs b/src/ipc/server.rs index 26c76b32..9bf7379b 100644 --- a/src/ipc/server.rs +++ b/src/ipc/server.rs @@ -22,7 +22,7 @@ impl Ipc { /// /// Once started, the server will begin accepting connections. pub fn start(&self, application: &Application, ironbar: Rc) { - let (cmd_tx, mut cmd_rx) = mpsc::channel(32); + let (cmd_tx, cmd_rx) = mpsc::channel(32); let (res_tx, mut res_rx) = mpsc::channel(32); let path = self.path.clone(); diff --git a/src/macros.rs b/src/macros.rs index deb8975f..e71a5934 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -58,13 +58,15 @@ macro_rules! try_send { /// ``` #[macro_export] macro_rules! glib_recv { - ($rx:expr, $val:ident => $expr:expr) => { + ($rx:expr, $val:ident => $expr:expr) => {{ glib::spawn_future_local(async move { - while let Ok($val) = $rx.recv().await { + // re-delcare in case ie `context.subscribe()` is passed directly + let mut rx = $rx; + while let Ok($val) = rx.recv().await { $expr } }); - }; + }}; } /// Spawns a `GLib` future on the local thread, and calls `rx.recv()` @@ -83,13 +85,15 @@ macro_rules! glib_recv { /// ``` #[macro_export] macro_rules! glib_recv_mpsc { - ($rx:expr, $val:ident => $expr:expr) => { + ($rx:expr, $val:ident => $expr:expr) => {{ glib::spawn_future_local(async move { - while let Some($val) = $rx.recv().await { + // re-delcare in case ie `context.subscribe()` is passed directly + let mut rx = $rx; + while let Some($val) = rx.recv().await { $expr } }); - }; + }}; } /// Locks a `Mutex`. diff --git a/src/modules/clipboard.rs b/src/modules/clipboard.rs index cdc72fb8..c7ef2bf4 100644 --- a/src/modules/clipboard.rs +++ b/src/modules/clipboard.rs @@ -145,7 +145,7 @@ impl Module