mirror of
https://github.com/alacritty/alacritty.git
synced 2024-11-25 14:05:41 -05:00
Fix specifying 0 lines/columns in config file
The logic during the initial spawning of the window was a bit twisted up. This has been resolved and it should all work properly now, even without a resize event at startup. This fixes #1781.
This commit is contained in:
parent
d05d16f023
commit
a68ce7a0e4
1 changed files with 20 additions and 14 deletions
|
@ -152,16 +152,14 @@ impl Display {
|
||||||
let dimensions = options.dimensions()
|
let dimensions = options.dimensions()
|
||||||
.unwrap_or_else(|| config.dimensions());
|
.unwrap_or_else(|| config.dimensions());
|
||||||
|
|
||||||
debug_assert!(dimensions.columns_u32() > 0);
|
let mut padding_x = f64::from(config.padding().x) * dpr;
|
||||||
debug_assert!(dimensions.lines_u32() > 0);
|
let mut padding_y = f64::from(config.padding().y) * dpr;
|
||||||
|
|
||||||
|
if dimensions.columns_u32() > 0 && dimensions.lines_u32() > 0 {
|
||||||
|
// Calculate new size based on cols/lines specified in config
|
||||||
let width = cell_width as u32 * dimensions.columns_u32();
|
let width = cell_width as u32 * dimensions.columns_u32();
|
||||||
let height = cell_height as u32 * dimensions.lines_u32();
|
let height = cell_height as u32 * dimensions.lines_u32();
|
||||||
|
|
||||||
let mut padding_x = f64::from(config.padding().x) * dpr;
|
|
||||||
let mut padding_y = f64::from(config.padding().y) * dpr;
|
|
||||||
padding_x = padding_x + (f64::from(width) - 2. * padding_x) % f64::from(cell_width) / 2.;
|
|
||||||
padding_y = padding_y + (f64::from(height) - 2. * padding_y) % f64::from(cell_height) / 2.;
|
|
||||||
padding_x = padding_x.floor();
|
padding_x = padding_x.floor();
|
||||||
padding_y = padding_y.floor();
|
padding_y = padding_y.floor();
|
||||||
|
|
||||||
|
@ -169,11 +167,19 @@ impl Display {
|
||||||
f64::from(width) + 2. * padding_x,
|
f64::from(width) + 2. * padding_x,
|
||||||
f64::from(height) + 2. * padding_y,
|
f64::from(height) + 2. * padding_y,
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
// Make sure additional padding is spread evenly
|
||||||
|
let cw = f64::from(cell_width);
|
||||||
|
let ch = f64::from(cell_height);
|
||||||
|
padding_x = (padding_x + (viewport_size.width - 2. * padding_x) % cw / 2.).floor();
|
||||||
|
padding_y = (padding_y + (viewport_size.height - 2. * padding_y) % ch / 2.).floor();
|
||||||
|
}
|
||||||
|
|
||||||
window.set_inner_size(viewport_size.to_logical(dpr));
|
window.set_inner_size(viewport_size.to_logical(dpr));
|
||||||
renderer.resize(viewport_size, padding_x as f32, padding_y as f32);
|
renderer.resize(viewport_size, padding_x as f32, padding_y as f32);
|
||||||
|
|
||||||
info!("Cell Size: ({} x {})", cell_width, cell_height);
|
info!("Cell Size: ({} x {})", cell_width, cell_height);
|
||||||
|
info!("Padding: ({} x {})", padding_x, padding_y);
|
||||||
|
|
||||||
let size_info = SizeInfo {
|
let size_info = SizeInfo {
|
||||||
dpr,
|
dpr,
|
||||||
|
|
Loading…
Reference in a new issue