1
1
mirror of https://github.com/wez/wezterm.git synced 2024-09-20 03:09:06 +03:00

create gui when attach to exist session

This commit is contained in:
g4c 2021-08-30 16:12:59 +08:00 committed by Wez Furlong
parent a26f190c7c
commit b899c81d19
2 changed files with 17 additions and 12 deletions

View File

@ -98,16 +98,7 @@ impl TmuxDomainState {
}
}
Event::WindowAdd { window: _ } => {
if self.gui_window.borrow().is_none() {
if let Some(mux) = Mux::get() {
let window_builder = mux.new_empty_window();
log::info!("Tmux create window id {}", window_builder.window_id);
{
let mut window_id = self.gui_window.borrow_mut();
*window_id = Some(window_builder); // keep the builder so it won't be purged
}
}
}
self.create_gui_window();
}
Event::SessionChanged { session, name: _ } => {
*self.tmux_session.borrow_mut() = Some(*session);
@ -147,6 +138,18 @@ impl TmuxDomainState {
*self.state.borrow_mut() = State::WaitingForResponse;
}
}
pub fn create_gui_window(&self) {
if self.gui_window.borrow().is_none() {
let mux = Mux::get().expect("should be call at main thread");
let window_builder = mux.new_empty_window();
log::info!("Tmux create window id {}", window_builder.window_id);
{
let mut window_id = self.gui_window.borrow_mut();
*window_id = Some(window_builder); // keep the builder so it won't be purged
}
};
}
}
impl TmuxDomain {

View File

@ -146,11 +146,12 @@ impl TmuxDomainState {
let tab = Rc::new(Tab::new(&size));
tab.assign_pane(&local_pane);
self.create_gui_window();
let mut gui_window = self.gui_window.borrow_mut();
let gui_window_id = match gui_window.as_mut() {
Some(x) => &mut *x,
Some(x) => x,
None => {
anyhow::bail!("None tmux GUI window created")
anyhow::bail!("No tmux gui created");
}
};
@ -159,6 +160,7 @@ impl TmuxDomainState {
gui_window_id.notify();
self.add_attached_pane(&pane, &tab.tab_id())?;
log::info!("new pane attached");
}
Ok(())
}