Skip to content

Commit

Permalink
Focused did actually matter for our purpose
Browse files Browse the repository at this point in the history
  • Loading branch information
vilhalmer committed Nov 18, 2024
1 parent 585847e commit e138186
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/wm_info_provider/niri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ fn niri_cb(conn: &mut Connection<State>, state: &mut State) -> io::Result<()> {
niri.workspaces.sort_by_key(|w| w.idx);
updated = true;
}
Ok(IpcEvent::WorkspaceActivated { id }) => {
Ok(IpcEvent::WorkspaceActivated { id, focused }) => {
if let Some(new_active) = niri.workspaces.iter().position(|ws| ws.id == id) {
// Clear the previous active workspace and apply it to the new one.
if let Some(previous_active) = niri.workspaces.iter().position(|ws| {
Expand All @@ -134,6 +134,15 @@ fn niri_cb(conn: &mut Connection<State>, state: &mut State) -> io::Result<()> {
niri.workspaces[new_active].is_active = true;
updated = true;
}
if focused {
if let Some(previous_focused) =
niri.workspaces.iter().position(|ws| ws.is_focused)
{
niri.workspaces[previous_focused].is_focused = false;
niri.workspaces[new_active].is_focused = true;
updated = true;
}
}
}
}
Ok(IpcEvent::Ok(_)) => continue,
Expand Down Expand Up @@ -210,7 +219,7 @@ enum IpcEvent {
},
WorkspaceActivated {
id: u32,
// focused doesn't matter for our purpose.
focused: bool,
},
#[serde(untagged)]
Ignored(IgnoredAny),
Expand Down

0 comments on commit e138186

Please sign in to comment.