diff options
author | David Hewitt <1939362+davidhewitt@users.noreply.github.com> | 2019-12-14 21:32:24 +0000 |
---|---|---|
committer | Christian Duerr <contact@christianduerr.com> | 2019-12-14 22:32:24 +0100 |
commit | 08a122574880d299181c59bec186c0f9e8bef77c (patch) | |
tree | c9dc6350869f89f08b35ca1e3a40a983bb1b53f1 /alacritty_terminal/src/tty/windows/mod.rs | |
parent | cb99fd4e4c16e8fe5c36e8be6062658842794ac3 (diff) | |
download | alacritty-08a122574880d299181c59bec186c0f9e8bef77c.tar.gz alacritty-08a122574880d299181c59bec186c0f9e8bef77c.zip |
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.
Diffstat (limited to 'alacritty_terminal/src/tty/windows/mod.rs')
-rw-r--r-- | alacritty_terminal/src/tty/windows/mod.rs | 40 |
1 files changed, 15 insertions, 25 deletions
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<C>(config: &Config<C>, size: &SizeInfo, window_id: Option<usize>) -> 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), + } + } +} |