summaryrefslogtreecommitdiff
path: root/alacritty_terminal/src/tty/unix.rs
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2019-10-05 02:29:26 +0200
committerGitHub <noreply@github.com>2019-10-05 02:29:26 +0200
commit729eef0c933831bccfeac6a355bdb410787fbe5f (patch)
tree35cdf2e6427ad18bc53efbab4cab34a0af2054d7 /alacritty_terminal/src/tty/unix.rs
parentb0c6fdff763f7271506d26d7e768e6377fdc691b (diff)
downloadalacritty-729eef0c933831bccfeac6a355bdb410787fbe5f.tar.gz
alacritty-729eef0c933831bccfeac6a355bdb410787fbe5f.zip
Update to winit/glutin EventLoop 2.0
This takes the latest glutin master to port Alacritty to the EventLoop 2.0 rework. This changes a big part of the event loop handling by pushing the event loop in a separate thread from the renderer and running both in parallel. Fixes #2796. Fixes #2694. Fixes #2643. Fixes #2625. Fixes #2618. Fixes #2601. Fixes #2564. Fixes #2456. Fixes #2438. Fixes #2334. Fixes #2254. Fixes #2217. Fixes #1789. Fixes #1750. Fixes #1125.
Diffstat (limited to 'alacritty_terminal/src/tty/unix.rs')
-rw-r--r--alacritty_terminal/src/tty/unix.rs38
1 files changed, 16 insertions, 22 deletions
diff --git a/alacritty_terminal/src/tty/unix.rs b/alacritty_terminal/src/tty/unix.rs
index 77b5db43..a2a277a6 100644
--- a/alacritty_terminal/src/tty/unix.rs
+++ b/alacritty_terminal/src/tty/unix.rs
@@ -15,12 +15,13 @@
//! tty related functionality
use crate::config::{Config, Shell};
-use crate::display::OnResize;
+use crate::event::OnResize;
use crate::term::SizeInfo;
use crate::tty::{ChildEvent, EventedPty, EventedReadWrite};
use mio;
use libc::{self, c_int, pid_t, winsize, TIOCSCTTY};
+use log::error;
use nix::pty::openpty;
use signal_hook::{self as sighook, iterator::Signals};
@@ -42,6 +43,13 @@ use std::sync::atomic::{AtomicUsize, Ordering};
/// Necessary to put this in static storage for `sigchld` to have access
static PID: AtomicUsize = AtomicUsize::new(0);
+macro_rules! die {
+ ($($arg:tt)*) => {{
+ error!($($arg)*);
+ ::std::process::exit(1);
+ }}
+}
+
pub fn child_pid() -> pid_t {
PID.load(Ordering::Relaxed) as pid_t
}
@@ -133,24 +141,8 @@ pub struct Pty {
signals_token: mio::Token,
}
-impl Pty {
- /// Resize the pty
- ///
- /// Tells the kernel that the window size changed with the new pixel
- /// dimensions and line/column counts.
- pub fn resize<T: ToWinsize>(&self, size: &T) {
- let win = size.to_winsize();
-
- let res = unsafe { libc::ioctl(self.fd.as_raw_fd(), libc::TIOCSWINSZ, &win as *const _) };
-
- if res < 0 {
- die!("ioctl TIOCSWINSZ failed: {}", io::Error::last_os_error());
- }
- }
-}
-
/// Create a new tty and return a handle to interact with it.
-pub fn new<T: ToWinsize>(config: &Config, size: &T, window_id: Option<usize>) -> Pty {
+pub fn new<C>(config: &Config<C>, size: &SizeInfo, window_id: Option<usize>) -> Pty {
let win_size = size.to_winsize();
let mut buf = [0; 1024];
let pw = get_pw_entry(&mut buf);
@@ -241,12 +233,10 @@ pub fn new<T: ToWinsize>(config: &Config, size: &T, window_id: Option<usize>) ->
signals,
signals_token: mio::Token::from(0),
};
- pty.resize(size);
+ pty.fd.as_raw_fd().on_resize(size);
pty
},
- Err(err) => {
- die!("Failed to spawn command: {}", err);
- },
+ Err(err) => die!("Failed to spawn command: {}", err),
}
}
@@ -365,6 +355,10 @@ impl<'a> ToWinsize for &'a SizeInfo {
}
impl OnResize for i32 {
+ /// Resize the pty
+ ///
+ /// Tells the kernel that the window size changed with the new pixel
+ /// dimensions and line/column counts.
fn on_resize(&mut self, size: &SizeInfo) {
let win = size.to_winsize();