anvil: split `bring_nth_window_to_top` to separate fn
This commit is contained in:
parent
3721b515f7
commit
524501b2e8
|
@ -300,26 +300,29 @@ impl WindowMap {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn bring_nth_window_to_top(&mut self, id: usize) {
|
||||||
|
let winner = self.windows.remove(id);
|
||||||
|
|
||||||
|
// Take activation away from all the windows
|
||||||
|
for window in self.windows.iter() {
|
||||||
|
window.toplevel.set_activated(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Give activation to our winner
|
||||||
|
winner.toplevel.set_activated(true);
|
||||||
|
self.windows.insert(0, winner);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn bring_surface_to_top(&mut self, surface: &WlSurface) {
|
pub fn bring_surface_to_top(&mut self, surface: &WlSurface) {
|
||||||
let found = self.windows.iter().enumerate().find(|(_, w)| {
|
let found = self.windows.iter().enumerate().find(|(_, w)| {
|
||||||
if let Some(s) = w.toplevel.get_surface() {
|
w.toplevel
|
||||||
s.as_ref().equals(surface.as_ref())
|
.get_surface()
|
||||||
} else {
|
.map(|s| s.as_ref().equals(surface.as_ref()))
|
||||||
false
|
.unwrap_or(false)
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if let Some((i, _)) = found {
|
if let Some((id, _)) = found {
|
||||||
let winner = self.windows.remove(i);
|
self.bring_nth_window_to_top(id);
|
||||||
|
|
||||||
// Take activation away from all the windows
|
|
||||||
for window in self.windows.iter() {
|
|
||||||
window.toplevel.set_activated(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Give activation to our winner
|
|
||||||
winner.toplevel.set_activated(true);
|
|
||||||
self.windows.insert(0, winner);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -334,18 +337,8 @@ impl WindowMap {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some((i, surface)) = found {
|
if let Some((id, surface)) = found {
|
||||||
let winner = self.windows.remove(i);
|
self.bring_nth_window_to_top(id);
|
||||||
|
|
||||||
// Take activation away from all the windows
|
|
||||||
for window in self.windows.iter() {
|
|
||||||
window.toplevel.set_activated(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Give activation to our winner
|
|
||||||
winner.toplevel.set_activated(true);
|
|
||||||
|
|
||||||
self.windows.insert(0, winner);
|
|
||||||
Some(surface)
|
Some(surface)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
|
Loading…
Reference in New Issue