create gui when attach to exist session
This commit is contained in:
1 parent
a26f190c7c
commit
b899c81d19
2 files changed
+17
-12
No files matched your search
+13
-10
@@ -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 {
|
||||
|
||||
@@ -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(())
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user