|
|
@ -1,17 +1,22 @@ |
|
|
|
use crate::con; |
|
|
|
use crate::con; |
|
|
|
|
|
|
|
use crate::ipc; |
|
|
|
use crate::util; |
|
|
|
use crate::util; |
|
|
|
use std::fmt; |
|
|
|
use std::fmt; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn focus_window_by_id(id: &ipc::Id) { |
|
|
|
|
|
|
|
util::swaymsg(&[format!("[con_id={}]", id).as_str(), "focus"]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn quit_window_by_id(id: &ipc::Id) { |
|
|
|
|
|
|
|
util::swaymsg(&[format!("[con_id={}]", id).as_str(), "kill"]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pub fn switch_window() { |
|
|
|
pub fn switch_window() { |
|
|
|
let root = con::get_tree(); |
|
|
|
let root = con::get_tree(); |
|
|
|
let mut windows = con::get_windows(&root); |
|
|
|
let windows = con::get_windows(&root); |
|
|
|
windows.sort(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if let Some(window) = con::select_window("Switch to window", &windows) { |
|
|
|
if let Some(window) = con::select_window("Switch to window", &windows) { |
|
|
|
util::swaymsg(&[ |
|
|
|
focus_window_by_id(&window.get_id()) |
|
|
|
format!("[con_id={}]", window.get_id()).as_str(), |
|
|
|
|
|
|
|
"focus", |
|
|
|
|
|
|
|
]); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -38,26 +43,35 @@ pub fn switch_workspace_or_window() { |
|
|
|
con::WsOrWin::Ws { ws } => { |
|
|
|
con::WsOrWin::Ws { ws } => { |
|
|
|
util::swaymsg(&["workspace", "number", ws.get_name()]); |
|
|
|
util::swaymsg(&["workspace", "number", ws.get_name()]); |
|
|
|
} |
|
|
|
} |
|
|
|
con::WsOrWin::Win { win } => { |
|
|
|
con::WsOrWin::Win { win } => focus_window_by_id(&win.get_id()), |
|
|
|
util::swaymsg(&[ |
|
|
|
|
|
|
|
format!("[con_id={}]", win.get_id()).as_str(), |
|
|
|
|
|
|
|
"focus", |
|
|
|
|
|
|
|
]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pub fn quit_window() { |
|
|
|
pub fn quit_window() { |
|
|
|
let root = con::get_tree(); |
|
|
|
let root = con::get_tree(); |
|
|
|
let mut windows = con::get_windows(&root); |
|
|
|
let windows = con::get_windows(&root); |
|
|
|
windows.sort_by(|a, b| a.cmp(b).reverse()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if let Some(window) = con::select_window("Quit window", &windows) { |
|
|
|
if let Some(window) = con::select_window("Quit window", &windows) { |
|
|
|
util::swaymsg(&[ |
|
|
|
quit_window_by_id(window.get_id()) |
|
|
|
format!("[con_id={}]", window.get_id()).as_str(), |
|
|
|
} |
|
|
|
"kill", |
|
|
|
} |
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
pub fn quit_workspace_or_window() { |
|
|
|
|
|
|
|
let root = con::get_tree(); |
|
|
|
|
|
|
|
let workspaces = con::get_workspaces(&root, false); |
|
|
|
|
|
|
|
let ws_or_wins = con::WsOrWin::from_workspaces(&workspaces); |
|
|
|
|
|
|
|
if let Some(ws_or_win) = |
|
|
|
|
|
|
|
con::select_workspace_or_window("Quit workspace or window", &ws_or_wins) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
match ws_or_win { |
|
|
|
|
|
|
|
con::WsOrWin::Ws { ws } => { |
|
|
|
|
|
|
|
for win in &ws.windows { |
|
|
|
|
|
|
|
quit_window_by_id(win.get_id()) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
con::WsOrWin::Win { win } => quit_window_by_id(win.get_id()), |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|