diff --git a/src/gliumwindows.rs b/src/gliumwindows.rs index 4bbe864e7..1dd961402 100644 --- a/src/gliumwindows.rs +++ b/src/gliumwindows.rs @@ -80,11 +80,8 @@ pub struct TerminalWindow { } impl TerminalWindow { - #[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))] pub fn new( event_loop: &super::GuiEventLoop, - width: u16, - height: u16, terminal: Terminal, pty: MasterPty, process: Child, @@ -98,6 +95,10 @@ impl TerminalWindow { (metrics.cell_height, metrics.cell_width) }; + let size = pty.get_size()?; + let width = size.ws_xpixel; + let height = size.ws_ypixel; + let window = glutin::WindowBuilder::new() .with_dimensions(width.into(), height.into()) .with_title("wezterm"); diff --git a/src/main.rs b/src/main.rs index 300919e4e..1214fbb45 100644 --- a/src/main.rs +++ b/src/main.rs @@ -460,8 +460,6 @@ fn spawn_window( let window = gliumwindows::TerminalWindow::new( event_loop, - initial_pixel_width, - initial_pixel_height, terminal, master, child, diff --git a/src/pty.rs b/src/pty.rs index e5ff35640..bf868ec3c 100644 --- a/src/pty.rs +++ b/src/pty.rs @@ -6,6 +6,7 @@ use mio::{Poll, PollOpt, Ready, Token}; use mio::event::Evented; use mio::unix::EventedFd; use std::io; +use std::mem; use std::os::unix::io::{AsRawFd, FromRawFd, RawFd}; use std::os::unix::process::CommandExt; use std::process::{Child, Command, Stdio}; @@ -237,6 +238,17 @@ impl MasterPty { Ok(()) } + + pub fn get_size(&self) -> Result { + let mut size: winsize = unsafe { mem::zeroed() }; + if unsafe { libc::ioctl(self.fd, libc::TIOCGWINSZ, &mut size as *mut _) } != 0 { + bail!( + "failed to ioctl(TIOCGWINSZ): {:?}", + io::Error::last_os_error() + ); + } + Ok(size) + } } impl AsRawFd for MasterPty {