1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-23 15:04:36 +03:00

fix surface size for newly spawned tabs

Problem scenario was:

* spawn a window
* resize it larger
* spawn a new tab

When working with a mux client tab, the surface size in the new tab
didn't reflect the size of the remote surface, so the rendering was
messed up.

Arrange to know the size up front.
This commit is contained in:
Wez Furlong 2019-06-20 08:46:58 -07:00
parent 7bff509540
commit 4171ad3aa3
4 changed files with 13 additions and 4 deletions

View File

@ -332,6 +332,7 @@ pub struct WindowAndTabEntry {
pub window_id: WindowId,
pub tab_id: TabId,
pub title: String,
pub size: PtySize,
}
#[derive(Deserialize, Serialize, PartialEq, Debug)]

View File

@ -107,7 +107,7 @@ impl Domain for ClientDomain {
result.tab_id
};
let tab: Rc<dyn Tab> = Rc::new(ClientTab::new(&self.inner, remote_tab_id));
let tab: Rc<dyn Tab> = Rc::new(ClientTab::new(&self.inner, remote_tab_id, size));
let mux = Mux::get().unwrap();
mux.add_tab(&tab)?;
mux.add_tab_to_window(&tab, window)?;
@ -127,7 +127,7 @@ impl Domain for ClientDomain {
entry.window_id,
entry.title
);
let tab: Rc<dyn Tab> = Rc::new(ClientTab::new(&self.inner, entry.tab_id));
let tab: Rc<dyn Tab> = Rc::new(ClientTab::new(&self.inner, entry.tab_id, entry.size));
mux.add_tab(&tab)?;
if let Some(local_window_id) = self.inner.remote_to_local_window(entry.window_id) {

View File

@ -10,6 +10,7 @@ use failure::{bail, err_msg, format_err, Error, Fallible};
use libc::{mode_t, umask};
use log::{debug, error};
use native_tls::{Identity, TlsAcceptor};
use portable_pty::PtySize;
use promise::{Executor, Future};
use std::collections::HashMap;
use std::convert::{TryFrom, TryInto};
@ -454,10 +455,17 @@ impl<S: ReadAndWrite> ClientSession<S> {
for window_id in mux.iter_windows().into_iter() {
let window = mux.get_window(window_id).unwrap();
for tab in window.iter() {
let (rows, cols) = tab.renderer().physical_dimensions();
tabs.push(WindowAndTabEntry {
window_id,
tab_id: tab.tab_id(),
title: tab.get_title(),
size: PtySize {
cols: cols as u16,
rows: rows as u16,
pixel_height: 0,
pixel_width: 0,
},
});
}
}

View File

@ -132,7 +132,7 @@ pub struct ClientTab {
}
impl ClientTab {
pub fn new(client: &Arc<ClientInner>, remote_tab_id: TabId) -> Self {
pub fn new(client: &Arc<ClientInner>, remote_tab_id: TabId, size: PtySize) -> Self {
let local_tab_id = alloc_tab_id();
let writer = TabWriter {
client: Arc::clone(client),
@ -155,7 +155,7 @@ impl ClientTab {
dead: RefCell::new(false),
poll_future: RefCell::new(None),
poll_interval: RefCell::new(BASE_POLL_INTERVAL),
surface: RefCell::new(Surface::new(80, 24)),
surface: RefCell::new(Surface::new(size.cols as usize, size.rows as usize)),
remote_sequence: RefCell::new(0),
local_sequence: RefCell::new(0),
selection_range,