From 08a122574880d299181c59bec186c0f9e8bef77c Mon Sep 17 00:00:00 2001 From: David Hewitt <1939362+davidhewitt@users.noreply.github.com> Date: Sat, 14 Dec 2019 21:32:24 +0000 Subject: Send PTY resize messages through event loop This allows us to clean up the Arcs on windows, as well as tidy up the code on unix a little too. Fixes #3086. --- alacritty_terminal/src/tty/windows/mod.rs | 40 ++++++++++++------------------- 1 file changed, 15 insertions(+), 25 deletions(-) (limited to 'alacritty_terminal/src/tty/windows/mod.rs') diff --git a/alacritty_terminal/src/tty/windows/mod.rs b/alacritty_terminal/src/tty/windows/mod.rs index e112d305..9e2f722b 100644 --- a/alacritty_terminal/src/tty/windows/mod.rs +++ b/alacritty_terminal/src/tty/windows/mod.rs @@ -38,16 +38,15 @@ pub fn is_conpty() -> bool { IS_CONPTY.load(Ordering::Relaxed) } -#[derive(Clone)] -pub enum PtyHandle { - Winpty(winpty::WinptyHandle), - Conpty(conpty::ConptyHandle), +enum PtyBackend { + Winpty(winpty::Agent), + Conpty(conpty::Conpty), } pub struct Pty { - // XXX: Handle is required to be the first field, to ensure correct drop order. Dropping - // `conout` before `handle` will cause a deadlock. - handle: PtyHandle, + // XXX: Backend is required to be the first field, to ensure correct drop order. Dropping + // `conout` before `backend` will cause a deadlock. + backend: PtyBackend, // TODO: It's on the roadmap for the Conpty API to support Overlapped I/O. // See https://github.com/Microsoft/console/issues/262 // When support for that lands then it should be possible to use @@ -60,12 +59,6 @@ pub struct Pty { child_watcher: ChildExitWatcher, } -impl Pty { - pub fn resize_handle(&self) -> impl OnResize { - self.handle.clone() - } -} - pub fn new(config: &Config, size: &SizeInfo, window_id: Option) -> Pty { if let Some(pty) = conpty::new(config, size, window_id) { info!("Using Conpty agent"); @@ -189,18 +182,6 @@ impl Write for EventedWritablePipe { } } -impl OnResize for PtyHandle { - fn on_resize(&mut self, sizeinfo: &SizeInfo) { - match self { - PtyHandle::Winpty(w) => w.resize(sizeinfo), - PtyHandle::Conpty(c) => { - let mut handle = c.clone(); - handle.on_resize(sizeinfo) - }, - } - } -} - impl EventedReadWrite for Pty { type Reader = EventedReadablePipe; type Writer = EventedWritablePipe; @@ -308,3 +289,12 @@ impl EventedPty for Pty { } } } + +impl OnResize for Pty { + fn on_resize(&mut self, size: &SizeInfo) { + match &mut self.backend { + PtyBackend::Winpty(w) => w.on_resize(size), + PtyBackend::Conpty(c) => c.on_resize(size), + } + } +} -- cgit