From 418f4990418ad806005977e03a6ef39386fb6656 Mon Sep 17 00:00:00 2001 From: Bill Doyle Date: Mon, 18 Nov 2024 16:17:23 -0500 Subject: [PATCH] Check last workspace per output, not globally --- src/wm_info_provider/niri.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/wm_info_provider/niri.rs b/src/wm_info_provider/niri.rs index 3fcf05d..9f37c3b 100644 --- a/src/wm_info_provider/niri.rs +++ b/src/wm_info_provider/niri.rs @@ -49,11 +49,17 @@ impl WmInfoProvider for NiriInfoProvider { fn get_tags(&self, output: &Output) -> Vec { // Niri always generates an empty workspace rather than having an explicit workspace // creation command, so we make the last workspace active only if the user is looking at - // it. This makes the behavior of `hide_inactive_tags` useful for Niri. - self.workspaces + // it. This makes the behavior of `hide_inactive_tags` useful for Niri. Because we're + // looking for the last element, we have to create an intermediate vector to get the + // length. + let output_workspaces: Vec<_> = self + .workspaces + .iter() + .filter(|ws| ws.output == output.name) + .collect(); + output_workspaces .iter() .enumerate() - .filter(|(_, ws)| ws.output == output.name) .map(|(i, ws)| Tag { id: ws.idx, name: ws.name.clone().map_or_else( @@ -61,7 +67,7 @@ impl WmInfoProvider for NiriInfoProvider { |name| format!("{0} / {1}", ws.idx, name), ), is_focused: ws.is_active, - is_active: i < self.workspaces.len() - 1 || ws.is_focused, + is_active: i < output_workspaces.len() - 1 || ws.is_focused, is_urgent: false, }) .collect()