|
|
|
@ -140,10 +140,7 @@ fn build_workspaces( |
|
|
|
|
) -> Vec<Workspace> { |
|
|
|
|
let mut v = vec![]; |
|
|
|
|
for workspace in root.workspaces() { |
|
|
|
|
v.push(Workspace { |
|
|
|
|
node: &workspace, |
|
|
|
|
con_props: con_props.remove(&workspace.id), |
|
|
|
|
windows: workspace |
|
|
|
|
let mut wins: Vec<Window> = workspace |
|
|
|
|
.windows() |
|
|
|
|
.iter() |
|
|
|
|
.map(|w| Window { |
|
|
|
@ -151,7 +148,12 @@ fn build_workspaces( |
|
|
|
|
con_props: con_props.remove(&w.id), |
|
|
|
|
workspace: &workspace, |
|
|
|
|
}) |
|
|
|
|
.collect(), |
|
|
|
|
.collect(); |
|
|
|
|
wins.sort(); |
|
|
|
|
v.push(Workspace { |
|
|
|
|
node: &workspace, |
|
|
|
|
con_props: con_props.remove(&workspace.id), |
|
|
|
|
windows: wins, |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
v |
|
|
|
@ -246,6 +248,45 @@ pub fn select_workspace<'a>( |
|
|
|
|
util::wofi_select(prompt, workspaces) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pub enum WsOrWin<'a> { |
|
|
|
|
Ws { ws: &'a Workspace<'a> }, |
|
|
|
|
Win { win: &'a Window<'a> }, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
impl<'a> fmt::Display for WsOrWin<'a> { |
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { |
|
|
|
|
match self { |
|
|
|
|
WsOrWin::Ws { ws } => ws.fmt(f), |
|
|
|
|
WsOrWin::Win { win } => match f.write_str("\t") { |
|
|
|
|
Ok(()) => win.fmt(f), |
|
|
|
|
Err(e) => Err(e), |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
impl WsOrWin<'_> { |
|
|
|
|
pub fn from_workspaces<'a>( |
|
|
|
|
workspaces: &'a [Workspace], |
|
|
|
|
) -> Vec<WsOrWin<'a>> { |
|
|
|
|
let mut v = vec![]; |
|
|
|
|
for ws in workspaces { |
|
|
|
|
v.push(WsOrWin::Ws { ws }); |
|
|
|
|
for win in &ws.windows { |
|
|
|
|
v.push(WsOrWin::Win { win: &win }); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
v |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pub fn select_workspace_or_window<'a>( |
|
|
|
|
prompt: &'a str, |
|
|
|
|
ws_or_wins: &'a [WsOrWin<'a>], |
|
|
|
|
) -> Option<&'a WsOrWin<'a>> { |
|
|
|
|
util::wofi_select(prompt, ws_or_wins) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pub struct Workspace<'a> { |
|
|
|
|
node: &'a ipc::Node, |
|
|
|
|
con_props: Option<ipc::ConProps>, |
|
|
|
|