Rotate but keep urgent windows on top in switch-window

timeout_old
Tassilo Horn 3 years ago
parent b9cecab9a3
commit 37a87f89ce
  1. 26
      src/tree.rs

@ -257,12 +257,26 @@ impl<'a> Tree<'a> {
pub fn get_windows(&self) -> Vec<DisplayNode> { pub fn get_windows(&self) -> Vec<DisplayNode> {
let mut v = self.sorted_nodes_of_type(Type::Window); let mut v = self.sorted_nodes_of_type(Type::Window);
// Don't rotate if there's an urgent window because that should be the // Rotate, but only non-urgent windows. Those should stay at the front
// first in the list because it's the most likely switch candidate. // as they are the most likely switch candidates.
if !v.is_empty() && !v[0].urgent { let mut x;
v.rotate_left(1); if !v.is_empty() {
x = vec![];
loop {
if !v.is_empty() && v[0].urgent {
x.push(v.remove(0));
} else {
break;
}
}
if !v.is_empty() {
v.rotate_left(1);
}
x.append(&mut v);
} else {
x = v;
} }
self.as_display_nodes(&v, IndentLevel::Fixed(0)) self.as_display_nodes(&x, IndentLevel::Fixed(0))
} }
pub fn get_workspaces_and_windows(&self) -> Vec<DisplayNode> { pub fn get_workspaces_and_windows(&self) -> Vec<DisplayNode> {
@ -395,7 +409,7 @@ fn maybe_html_escape(do_it: bool, text: &str) -> String {
} }
} }
fn format_marks(marks: &Vec<String>) -> String { fn format_marks(marks: &[String]) -> String {
if marks.is_empty() { if marks.is_empty() {
"".to_string() "".to_string()
} else { } else {

Loading…
Cancel
Save