Merge branch 'strict-workspaces'
This commit is contained in:
commit
983c12cb34
@ -16,6 +16,7 @@ use std::collections::HashMap;
|
||||
pub struct NiriTag {
|
||||
tags: HashMap<u8, bool>,
|
||||
windows: HashMap<u64, u8>,
|
||||
active_ws: Vec<u64>,
|
||||
state: EventStreamState,
|
||||
socket: BufReader<UnixStream>,
|
||||
ev_tx: channel::Sender<TagEvent>,
|
||||
@ -33,6 +34,7 @@ impl NiriTag {
|
||||
windows: HashMap::new(),
|
||||
state: EventStreamState::default(),
|
||||
socket: create_niri_socket().await?,
|
||||
active_ws: Vec::new(),
|
||||
ev_tx,
|
||||
})
|
||||
}
|
||||
@ -327,8 +329,45 @@ impl NiriTag {
|
||||
self.windows.remove(&id);
|
||||
Ok(())
|
||||
}
|
||||
// WorkspaceActivated { .. } => (),
|
||||
// WorkspacesChanged { .. } => (),
|
||||
WorkspaceActivated { id, .. } => {
|
||||
if !self.active_ws.contains(&id) {
|
||||
let q = query(&mut self.socket, Request::Workspaces).await?;
|
||||
let wsid = if let Reply::Ok(Response::Workspaces(workspaces)) = q {
|
||||
let new_ws = workspaces
|
||||
.iter()
|
||||
.find(|ws| ws.id == id)
|
||||
.expect("Activated workspace not found in workspace query");
|
||||
workspaces
|
||||
.iter()
|
||||
.find(|ws| {
|
||||
ws.output == new_ws.output
|
||||
&& ws.id != new_ws.id
|
||||
&& self.active_ws.contains(&ws.id)
|
||||
})
|
||||
.expect("Could not find a valid niri-tag workspace to return to")
|
||||
.id
|
||||
} else {
|
||||
return Err(anyhow!("Invalid response to workspace query"));
|
||||
};
|
||||
tell(
|
||||
&mut self.socket,
|
||||
Request::Action(Action::FocusWorkspace {
|
||||
reference: WorkspaceReferenceArg::Id(wsid),
|
||||
}),
|
||||
)
|
||||
.await
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
WorkspacesChanged { workspaces } => {
|
||||
self.active_ws = workspaces
|
||||
.into_iter()
|
||||
.filter(|ws| ws.is_active)
|
||||
.map(|ws| ws.id)
|
||||
.collect();
|
||||
Ok(())
|
||||
}
|
||||
// WorkspaceUrgencyChanged { .. } => (),
|
||||
WindowsChanged { windows } => {
|
||||
for w in windows {
|
||||
|
Loading…
Reference in New Issue
Block a user