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/src/event.rs | 7 ++----- alacritty/src/main.rs | 23 ++--------------------- 2 files changed, 4 insertions(+), 26 deletions(-) (limited to 'alacritty/src') diff --git a/alacritty/src/event.rs b/alacritty/src/event.rs index 4cfc2152..4b1fe892 100644 --- a/alacritty/src/event.rs +++ b/alacritty/src/event.rs @@ -308,20 +308,18 @@ pub struct Processor { suppress_chars: bool, modifiers: ModifiersState, config: Config, - pty_resize_handle: Box, message_buffer: MessageBuffer, display: Display, font_size: Size, } -impl Processor { +impl Processor { /// Create a new event processor /// /// Takes a writer which is expected to be hooked up to the write end of a /// pty. pub fn new( notifier: N, - pty_resize_handle: Box, message_buffer: MessageBuffer, config: Config, display: Display, @@ -334,7 +332,6 @@ impl Processor { modifiers: Default::default(), font_size: config.font.size, config, - pty_resize_handle, message_buffer, display, } @@ -405,7 +402,7 @@ impl Processor { if !display_update_pending.is_empty() { self.display.handle_update( &mut terminal, - self.pty_resize_handle.as_mut(), + &mut self.notifier, &self.message_buffer, &self.config, display_update_pending, diff --git a/alacritty/src/main.rs b/alacritty/src/main.rs index 9b5b8eb8..64e0b9cf 100644 --- a/alacritty/src/main.rs +++ b/alacritty/src/main.rs @@ -27,8 +27,6 @@ use std::env; use std::error::Error; use std::fs; use std::io::{self, Write}; -#[cfg(not(windows))] -use std::os::unix::io::AsRawFd; use std::sync::Arc; #[cfg(target_os = "macos")] @@ -170,16 +168,6 @@ fn run(window_event_loop: GlutinEventLoop, config: Config) -> Result<(), #[cfg(any(target_os = "macos", windows))] let pty = tty::new(&config, &display.size_info, None); - // Create PTY resize handle - // - // This exists because rust doesn't know the interface is thread-safe - // and we need to be able to resize the PTY from the main thread while the IO - // thread owns the EventedRW object. - #[cfg(windows)] - let resize_handle = pty.resize_handle(); - #[cfg(not(windows))] - let resize_handle = pty.fd.as_raw_fd(); - // Create the pseudoterminal I/O loop // // pty I/O is ran on another thread as to not occupy cycles used by the @@ -204,15 +192,8 @@ fn run(window_event_loop: GlutinEventLoop, config: Config) -> Result<(), let message_buffer = MessageBuffer::new(); // Event processor - // - // Need the Rc> here since a ref is shared in the resize callback - let mut processor = Processor::new( - event_loop::Notifier(loop_tx.clone()), - Box::new(resize_handle), - message_buffer, - config, - display, - ); + let mut processor = + Processor::new(event_loop::Notifier(loop_tx.clone()), message_buffer, config, display); // Kick off the I/O thread let io_thread = event_loop.spawn(); -- cgit