simplify the TerminalWindow constructor a little more
This commit is contained in:
1 parent
b1a5ebd06f
commit
4089649d8c
3 files changed
+16
-5
No files matched your search
+4
-3
@@ -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");
|
||||
|
||||
@@ -460,8 +460,6 @@ fn spawn_window(
|
||||
|
||||
let window = gliumwindows::TerminalWindow::new(
|
||||
event_loop,
|
||||
initial_pixel_width,
|
||||
initial_pixel_height,
|
||||
terminal,
|
||||
master,
|
||||
child,
|
||||
|
||||
+12
@@ -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<winsize, Error> {
|
||||
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 {
|
||||
|
||||
Reference in new issue
Block a user