1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-10 15:04:32 +03:00

tidy up window/tab closing and quitting for software frontend

This commit is contained in:
Wez Furlong 2019-09-22 08:38:35 -07:00
parent 88d15e18af
commit 4de30373b6
2 changed files with 22 additions and 5 deletions

View File

@ -43,6 +43,15 @@ impl FrontEnd for SoftwareFrontEnd {
}
fn run_forever(&self) -> Fallible<()> {
self.connection
.schedule_timer(std::time::Duration::from_millis(200), move || {
let mux = Mux::get().unwrap();
mux.prune_dead_windows();
if mux.is_empty() {
Connection::get().unwrap().terminate_message_loop();
}
});
self.connection.run_message_loop()
}

View File

@ -59,14 +59,22 @@ impl WindowCallbacks for TermWindow {
}
fn can_close(&mut self) -> bool {
// self.host.close_current_tab();
// can_close triggers the current tab to be closed.
// If we have no tabs left then we can close the whole window.
// If we're in a weird state, then we allow the window to close too.
let mux = Mux::get().unwrap();
let tab = match mux.get_active_tab_for_window(self.mux_window_id) {
Some(tab) => tab,
None => return true,
};
mux.remove_tab(tab.tab_id());
if let Some(mut win) = mux.get_window_mut(self.mux_window_id) {
win.remove_by_id(tab.tab_id());
return win.is_empty();
};
true
}
fn destroy(&mut self) {
Connection::get().unwrap().terminate_message_loop();
}
fn as_any(&mut self) -> &mut dyn Any {
self
}