spawned windows no longer inherit scaling

On hidpi displays we'd end up with a window twice the size; whoops!
This commit is contained in:
Wez Furlong committed 2019-02-23 17:11:23 -08:00
1 parent 9bc54da406
commit aa9942e6d4
4 files changed
+21 -7

No files matched your search

+12
View File
@@ -131,6 +131,18 @@ impl FontConfiguration {
}
}
/// Used when spawning a window to start with an unscaled font configuration
pub fn clone_unscaled(&self) -> Rc<Self> {
Rc::new(Self {
config: Rc::clone(&self.config),
fonts: RefCell::new(HashMap::new()),
system: Rc::clone(&self.system),
metrics: RefCell::new(None),
font_scale: RefCell::new(1.0),
dpi_scale: RefCell::new(1.0),
})
}
/// Given a text style, load (with caching) the font that best
/// matches according to the fontconfig pattern.
pub fn cached_font(&self, style: &TextStyle) -> Result<Rc<RefCell<Box<NamedFont>>>, Error> {
+1 -1
View File
@@ -134,7 +134,7 @@ impl<'a> term::TerminalHost for TabHost<'a> {
let config = Rc::clone(&self.host.config);
let fonts = Rc::clone(&self.host.fonts);
self.host.event_loop.spawn_fn(move || {
let (terminal, master, child) = spawn_window_impl(None, &config, &fonts)?;
let (terminal, master, child, fonts) = spawn_window_impl(None, &config, &fonts)?;
let window =
TerminalWindow::new(&event_loop, terminal, master, child, &fonts, &config)?;
+2 -2
View File
@@ -244,9 +244,9 @@ impl GuiEventLoop {
config: &Rc<Config>,
fontconfig: &Rc<FontConfiguration>,
) -> Result<(), Error> {
let (terminal, master, child) = spawn_window_impl(None, config, fontconfig)?;
let (terminal, master, child, fontconfig) = spawn_window_impl(None, config, fontconfig)?;
let window = TerminalWindow::new(event_loop, terminal, master, child, fontconfig, config)?;
let window = TerminalWindow::new(event_loop, terminal, master, child, &fontconfig, config)?;
self.add_window(window)
}
+6 -4
View File
@@ -127,9 +127,11 @@ fn spawn_window_impl(
cmd: Option<Vec<&std::ffi::OsStr>>,
config: &Rc<config::Config>,
fontconfig: &Rc<FontConfiguration>,
) -> Result<(term::Terminal, MasterPty, Child), Error> {
) -> Result<(term::Terminal, MasterPty, Child, Rc<FontConfiguration>), Error> {
let cmd = config.build_prog(cmd)?;
let fontconfig = fontconfig.clone_unscaled();
// First step is to figure out the font metrics so that we know how
// big things are going to be.
// we always load the cell_height for font 0,
@@ -159,7 +161,7 @@ fn spawn_window_impl(
config.hyperlink_rules.clone(),
);
Ok((terminal, master, child))
Ok((terminal, master, child, fontconfig))
}
fn spawn_window(
@@ -168,7 +170,7 @@ fn spawn_window(
config: &Rc<config::Config>,
fontconfig: &Rc<FontConfiguration>,
) -> Result<(), Error> {
let (terminal, master, child) = spawn_window_impl(cmd, config, fontconfig)?;
let (terminal, master, child, fontconfig) = spawn_window_impl(cmd, config, fontconfig)?;
gui.spawn_new_window(terminal, master, child, config, fontconfig)
gui.spawn_new_window(terminal, master, child, config, &fontconfig)
}