Skip to content

Commit

Permalink
Check last workspace per output, not globally
Browse files Browse the repository at this point in the history
  • Loading branch information
vilhalmer committed Nov 18, 2024
1 parent e138186 commit 418f499
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/wm_info_provider/niri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,25 @@ impl WmInfoProvider for NiriInfoProvider {
fn get_tags(&self, output: &Output) -> Vec<Tag> {
// 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(
|| ws.idx.to_string(),
|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()
Expand Down

0 comments on commit 418f499

Please sign in to comment.