diff options
author | Bryan Gilbert <gilbertw1@gmail.com> | 2017-10-19 15:30:03 -0400 |
---|---|---|
committer | Joe Wilm <jwilm@users.noreply.github.com> | 2017-11-11 09:44:32 -0800 |
commit | 812208d8b5f0e9c531a2dcc767ce0f84359c5eb8 (patch) | |
tree | 589f5e08abe7070acfbcedbc6e37a559f8279ccb | |
parent | 2bda79d94cde0a2c846a0c6a62a76cebedfbf816 (diff) | |
download | alacritty-812208d8b5f0e9c531a2dcc767ce0f84359c5eb8.tar.gz alacritty-812208d8b5f0e9c531a2dcc767ce0f84359c5eb8.zip |
Don't enforce window dimensions if configured with 0 columns or lines
-rw-r--r-- | alacritty.yml | 1 | ||||
-rw-r--r-- | src/cli.rs | 2 | ||||
-rw-r--r-- | src/display.rs | 35 |
3 files changed, 22 insertions, 16 deletions
diff --git a/alacritty.yml b/alacritty.yml index d2607051..e26a816d 100644 --- a/alacritty.yml +++ b/alacritty.yml @@ -15,6 +15,7 @@ env: TERM: xterm-256color # Window dimensions in character columns and lines +# Falls back to size specified by window manager if set to 0x0. # (changes require restart) dimensions: columns: 80 @@ -74,7 +74,7 @@ impl Options { .long("dimensions") .short("d") .value_names(&["columns", "lines"]) - .help("Defines the window dimensions [default: 80x24]")) + .help("Defines the window dimensions. Falls back to size specified by window manager if set to 0x0 [default: 80x24]")) .arg(Arg::with_name("title") .long("title") .short("t") diff --git a/src/display.rs b/src/display.rs index 31576355..0d6be1e5 100644 --- a/src/display.rs +++ b/src/display.rs @@ -139,33 +139,38 @@ impl Display { // Create the window where Alacritty will be displayed let mut window = Window::new(&options.title)?; - // get window properties for initializing the other subsystems - let size = window.inner_size_pixels() + // get window properties for initializing the other subsytems + let mut viewport_size = window.inner_size_pixels() .expect("glutin returns window size"); let dpr = window.hidpi_factor(); info!("device_pixel_ratio: {}", dpr); // Create renderer - let mut renderer = QuadRenderer::new(&config, size)?; + let mut renderer = QuadRenderer::new(&config, viewport_size)?; let (glyph_cache, cell_width, cell_height) = Self::new_glyph_cache(&window, &mut renderer, config, 0)?; - // Resize window to specified dimensions + let dimensions = options.dimensions() .unwrap_or_else(|| config.dimensions()); - let width = cell_width as u32 * dimensions.columns_u32(); - let height = cell_height as u32 * dimensions.lines_u32(); - let size = Size { width: Pixels(width), height: Pixels(height) }; - info!("set_inner_size: {}", size); - - let viewport_size = Size { - width: Pixels(width + 2 * config.padding().x as u32), - height: Pixels(height + 2 * config.padding().y as u32), - }; - window.set_inner_size(&viewport_size); - renderer.resize(viewport_size.width.0 as _, viewport_size.height.0 as _); + + // Resize window to specified dimensions unless one or both dimensions are 0 + if dimensions.columns_u32() > 0 && dimensions.lines_u32() > 0 { + let width = cell_width as u32 * dimensions.columns_u32(); + let height = cell_height as u32 * dimensions.lines_u32(); + + let new_viewport_size = Size { + width: Pixels(width + 2 * config.padding().x as u32), + height: Pixels(height + 2 * config.padding().y as u32), + }; + + window.set_inner_size(&new_viewport_size); + renderer.resize(new_viewport_size.width.0 as _, new_viewport_size.height.0 as _); + viewport_size = new_viewport_size + } + info!("Cell Size: ({} x {})", cell_width, cell_height); let size_info = SizeInfo { |