1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-23 21:32:13 +03:00

tidy up default_dpi vs DEFAULT_DPI

This commit breaks the dependency from config -> window,
which in turn breaks the dependency from mux-server -> x11 libs
on linux.
This commit is contained in:
Wez Furlong 2020-12-09 13:09:18 -08:00
parent c6334a45dd
commit 22b4e99c82
5 changed files with 6 additions and 12 deletions

1
Cargo.lock generated
View File

@ -730,7 +730,6 @@ dependencies = [
"wezterm-input-types", "wezterm-input-types",
"wezterm-term", "wezterm-term",
"winapi 0.3.9", "winapi 0.3.9",
"window",
] ]
[[package]] [[package]]

View File

@ -34,7 +34,6 @@ termwiz = { path = "../termwiz" }
toml = "0.5" toml = "0.5"
wezterm-input-types = { path = "../wezterm-input-types" } wezterm-input-types = { path = "../wezterm-input-types" }
wezterm-term = { path = "../term", features=["use_serde"] } wezterm-term = { path = "../term", features=["use_serde"] }
window = { path = "../window" }
[target."cfg(windows)".dependencies] [target."cfg(windows)".dependencies]
winapi = { version = "0.3", features = ["winuser"]} winapi = { version = "0.3", features = ["winuser"]}

View File

@ -463,8 +463,7 @@ pub struct Config {
pub color_scheme_dirs: Vec<PathBuf>, pub color_scheme_dirs: Vec<PathBuf>,
/// The DPI to assume /// The DPI to assume
#[serde(default = "default_dpi")] pub dpi: Option<f64>,
pub dpi: f64,
/// The baseline font to use /// The baseline font to use
#[serde(default)] #[serde(default)]
@ -1253,10 +1252,6 @@ fn default_font_size() -> f64 {
10.0 10.0
} }
pub fn default_dpi() -> f64 {
::window::DEFAULT_DPI
}
fn compute_runtime_dir() -> Result<PathBuf, Error> { fn compute_runtime_dir() -> Result<PathBuf, Error> {
if let Some(runtime) = dirs::runtime_dir() { if let Some(runtime) = dirs::runtime_dir() {
return Ok(runtime.join("wezterm")); return Ok(runtime.join("wezterm"));

View File

@ -288,7 +288,8 @@ impl FontConfigInner {
let config = configuration(); let config = configuration();
let font_size = config.font_size * *self.font_scale.borrow(); let font_size = config.font_size * *self.font_scale.borrow();
let dpi = *self.dpi_scale.borrow() as u32 * config.dpi as u32; let dpi =
*self.dpi_scale.borrow() as u32 * config.dpi.unwrap_or(::window::DEFAULT_DPI) as u32;
let metrics = shaper.metrics(font_size, dpi)?; let metrics = shaper.metrics(font_size, dpi)?;
let loaded = Rc::new(LoadedFont { let loaded = Rc::new(LoadedFont {

View File

@ -27,7 +27,7 @@ use anyhow::{anyhow, bail, ensure};
use config::keyassignment::{ use config::keyassignment::{
InputMap, KeyAssignment, MouseEventTrigger, SpawnCommand, SpawnTabDomain, InputMap, KeyAssignment, MouseEventTrigger, SpawnCommand, SpawnTabDomain,
}; };
use config::{configuration, default_dpi, ConfigHandle}; use config::{configuration, ConfigHandle};
use lru::LruCache; use lru::LruCache;
use mux::activity::Activity; use mux::activity::Activity;
use mux::domain::{DomainId, DomainState}; use mux::domain::{DomainId, DomainState};
@ -933,7 +933,7 @@ impl TermWindow {
pixel_height: ((rows_with_tab_bar * render_metrics.cell_size.height as u16) pixel_height: ((rows_with_tab_bar * render_metrics.cell_size.height as u16)
+ config.window_padding.top + config.window_padding.top
+ config.window_padding.bottom) as usize, + config.window_padding.bottom) as usize,
dpi: config.dpi as usize, dpi: config.dpi.unwrap_or(::window::DEFAULT_DPI) as usize,
}; };
log::info!( log::info!(
@ -2113,7 +2113,7 @@ impl TermWindow {
fn apply_scale_change(&mut self, dimensions: &Dimensions, font_scale: f64) { fn apply_scale_change(&mut self, dimensions: &Dimensions, font_scale: f64) {
self.fonts self.fonts
.change_scaling(font_scale, dimensions.dpi as f64 / default_dpi()); .change_scaling(font_scale, dimensions.dpi as f64 / ::window::DEFAULT_DPI);
self.render_metrics = RenderMetrics::new(&self.fonts); self.render_metrics = RenderMetrics::new(&self.fonts);
if self.render_state.has_opengl() { if self.render_state.has_opengl() {
self.render_state.opengl().glyph_cache.borrow_mut().clear(); self.render_state.opengl().glyph_cache.borrow_mut().clear();