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:
parent
a26f190c7c
commit
b899c81d19
@ -98,16 +98,7 @@ impl TmuxDomainState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Event::WindowAdd { window: _ } => {
|
Event::WindowAdd { window: _ } => {
|
||||||
if self.gui_window.borrow().is_none() {
|
self.create_gui_window();
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Event::SessionChanged { session, name: _ } => {
|
Event::SessionChanged { session, name: _ } => {
|
||||||
*self.tmux_session.borrow_mut() = Some(*session);
|
*self.tmux_session.borrow_mut() = Some(*session);
|
||||||
@ -147,6 +138,18 @@ impl TmuxDomainState {
|
|||||||
*self.state.borrow_mut() = State::WaitingForResponse;
|
*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 {
|
impl TmuxDomain {
|
||||||
|
@ -146,11 +146,12 @@ impl TmuxDomainState {
|
|||||||
let tab = Rc::new(Tab::new(&size));
|
let tab = Rc::new(Tab::new(&size));
|
||||||
tab.assign_pane(&local_pane);
|
tab.assign_pane(&local_pane);
|
||||||
|
|
||||||
|
self.create_gui_window();
|
||||||
let mut gui_window = self.gui_window.borrow_mut();
|
let mut gui_window = self.gui_window.borrow_mut();
|
||||||
let gui_window_id = match gui_window.as_mut() {
|
let gui_window_id = match gui_window.as_mut() {
|
||||||
Some(x) => &mut *x,
|
Some(x) => x,
|
||||||
None => {
|
None => {
|
||||||
anyhow::bail!("None tmux GUI window created")
|
anyhow::bail!("No tmux gui created");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -159,6 +160,7 @@ impl TmuxDomainState {
|
|||||||
gui_window_id.notify();
|
gui_window_id.notify();
|
||||||
|
|
||||||
self.add_attached_pane(&pane, &tab.tab_id())?;
|
self.add_attached_pane(&pane, &tab.tab_id())?;
|
||||||
|
log::info!("new pane attached");
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user