diff --git a/src/frontend/glium/glutinloop.rs b/src/frontend/glium/glutinloop.rs index f6b98f226..09bad0577 100644 --- a/src/frontend/glium/glutinloop.rs +++ b/src/frontend/glium/glutinloop.rs @@ -206,17 +206,12 @@ impl GuiEventLoop { }) } - pub fn register_tab(&self, tab: &Rc) -> Result<(), Error> { - self.mux.add_tab(self.gui_executor(), tab) - } - fn do_spawn_new_window( &self, config: &Arc, fonts: &Rc, ) -> Result<(), Error> { let tab = self.mux.default_domain().spawn(PtySize::default(), None)?; - self.mux.add_tab(self.gui_executor(), &tab)?; let events = Self::get().expect("to be called on gui thread"); let window = GliumTerminalWindow::new(&events, &fonts, &config, &tab)?; diff --git a/src/frontend/glium/window.rs b/src/frontend/glium/window.rs index 38467cf5e..11019f97c 100644 --- a/src/frontend/glium/window.rs +++ b/src/frontend/glium/window.rs @@ -5,7 +5,7 @@ use crate::font::FontConfiguration; use crate::frontend::glium::glutinloop::GuiEventLoop; use crate::frontend::guicommon::host::{HostHelper, HostImpl, TabHost}; use crate::frontend::guicommon::window::{Dimensions, TerminalWindow}; -use crate::mux::tab::{Tab, TabId}; +use crate::mux::tab::Tab; use crate::mux::window::WindowId; use crate::mux::{Mux, SessionTerminated}; use crate::opengl::render::Renderer; @@ -114,13 +114,6 @@ impl TerminalWindow for GliumTerminalWindow { self.renderer.recreate_atlas(&self.host.display, size) } - fn tab_was_created(&mut self, tab: &Rc) -> Result<(), Error> { - self.event_loop.register_tab(tab) - } - fn deregister_tab(&mut self, _tab_id: TabId) -> Result<(), Error> { - Ok(()) - } - fn get_dimensions(&self) -> Dimensions { Dimensions { width: self.width, diff --git a/src/frontend/guicommon/window.rs b/src/frontend/guicommon/window.rs index b18486e94..425e72977 100644 --- a/src/frontend/guicommon/window.rs +++ b/src/frontend/guicommon/window.rs @@ -37,8 +37,6 @@ pub trait TerminalWindow { cell_height: usize, ) -> Result<(), Error>; fn advise_renderer_of_resize(&mut self, width: u16, height: u16) -> Result<(), Error>; - fn tab_was_created(&mut self, tab: &Rc) -> Result<(), Error>; - fn deregister_tab(&mut self, tab_id: TabId) -> Result<(), Error>; fn config(&self) -> &Arc; fn fonts(&self) -> &Rc; fn get_dimensions(&self) -> Dimensions; @@ -179,9 +177,6 @@ pub trait TerminalWindow { window.len() }; self.activate_tab(len - 1)?; - - self.tab_was_created(&tab)?; - Ok(tab_id) } @@ -273,7 +268,6 @@ pub trait TerminalWindow { } drop(window); self.update_title(); - self.deregister_tab(tab_id).ok(); } // let_and_return is needed here to satisfy the borrow checker diff --git a/src/frontend/xwindows/x11loop.rs b/src/frontend/xwindows/x11loop.rs index eb3d021da..c45d83a2a 100644 --- a/src/frontend/xwindows/x11loop.rs +++ b/src/frontend/xwindows/x11loop.rs @@ -135,10 +135,6 @@ impl GuiEventLoop { }) } - pub fn register_tab(&self, tab: &Rc) -> Result<(), Error> { - self.mux.add_tab(self.gui_executor(), tab) - } - fn run(&self) -> Result<(), Error> { let mut events = Events::with_capacity(8); @@ -216,7 +212,6 @@ impl GuiEventLoop { fonts: &Rc, ) -> Result<(), Error> { let tab = self.mux.default_domain().spawn(PtySize::default(), None)?; - self.mux.add_tab(self.gui_executor(), &tab)?; let events = Self::get().expect("to be called on gui thread"); let window = X11TerminalWindow::new(&events, &fonts, &config, &tab)?; events.add_window(window) diff --git a/src/frontend/xwindows/xwin.rs b/src/frontend/xwindows/xwin.rs index 4e8970a6a..74318955c 100644 --- a/src/frontend/xwindows/xwin.rs +++ b/src/frontend/xwindows/xwin.rs @@ -72,12 +72,6 @@ impl TerminalWindow for X11TerminalWindow { fn recreate_texture_atlas(&mut self, size: u32) -> Result<(), Error> { self.renderer.recreate_atlas(&self.host.window, size) } - fn tab_was_created(&mut self, tab: &Rc) -> Result<(), Error> { - self.host.event_loop.register_tab(tab) - } - fn deregister_tab(&mut self, _tab_id: TabId) -> Result<(), Error> { - Ok(()) - } fn get_dimensions(&self) -> Dimensions { Dimensions { width: self.width, diff --git a/src/main.rs b/src/main.rs index 24f02e9b3..c3d6ada73 100644 --- a/src/main.rs +++ b/src/main.rs @@ -197,7 +197,5 @@ fn spawn_window( fontconfig: &Rc, ) -> Result<(), Error> { let tab = mux.default_domain().spawn(PtySize::default(), cmd)?; - mux.add_tab(gui.gui_executor(), &tab)?; - gui.spawn_new_window(mux.config(), &fontconfig, &tab) } diff --git a/src/mux/domain.rs b/src/mux/domain.rs index e4fbdc3f3..244cf8ae1 100644 --- a/src/mux/domain.rs +++ b/src/mux/domain.rs @@ -8,6 +8,7 @@ use crate::config::Config; use crate::frontend::guicommon::localtab::LocalTab; use crate::mux::tab::Tab; +use crate::mux::Mux; use failure::Error; use portable_pty::cmdbuilder::CommandBuilder; use portable_pty::{PtySize, PtySystem}; @@ -49,6 +50,10 @@ impl Domain for LocalDomain { self.config.hyperlink_rules.clone(), ); - Ok(Rc::new(LocalTab::new(terminal, child, master))) + let tab: Rc = Rc::new(LocalTab::new(terminal, child, master)); + + Mux::get().unwrap().add_tab(&tab)?; + + Ok(tab) } } diff --git a/src/mux/mod.rs b/src/mux/mod.rs index 49d6c4eaa..88c4dd1db 100644 --- a/src/mux/mod.rs +++ b/src/mux/mod.rs @@ -1,4 +1,5 @@ use crate::config::Config; +use crate::frontend::gui_executor; use failure::Error; use failure_derive::*; use portable_pty::ExitStatus; @@ -28,7 +29,8 @@ pub struct Mux { default_domain: Arc, } -fn read_from_tab_pty(executor: Box, tab_id: TabId, mut reader: Box) { +fn read_from_tab_pty(tab_id: TabId, mut reader: Box) { + let executor = gui_executor().expect("gui_executor was not registered yet!?"); const BUFSIZE: usize = 32 * 1024; let mut buf = [0; BUFSIZE]; loop { @@ -139,12 +141,12 @@ impl Mux { self.tabs.borrow().get(&tab_id).map(Rc::clone) } - pub fn add_tab(&self, executor: Box, tab: &Rc) -> Result<(), Error> { + pub fn add_tab(&self, tab: &Rc) -> Result<(), Error> { self.tabs.borrow_mut().insert(tab.tab_id(), Rc::clone(tab)); let reader = tab.reader()?; let tab_id = tab.tab_id(); - thread::spawn(move || read_from_tab_pty(executor, tab_id, reader)); + thread::spawn(move || read_from_tab_pty(tab_id, reader)); Ok(()) }