From 402e5b7382c3194bdea878c427bbcd85c13fc03f Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Fri, 3 Jun 2022 09:28:24 -0700 Subject: [PATCH] background: round down fractional pixels when tiling --- wezterm-gui/src/termwindow/background.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/wezterm-gui/src/termwindow/background.rs b/wezterm-gui/src/termwindow/background.rs index eb9361535..c2752142f 100644 --- a/wezterm-gui/src/termwindow/background.rs +++ b/wezterm-gui/src/termwindow/background.rs @@ -429,7 +429,10 @@ impl crate::TermWindow { // Width is the longest side let target_height = pixel_width / aspect; if target_height > pixel_height { - (pixel_width * pixel_height / target_height, pixel_height) + ( + (pixel_width * pixel_height / target_height).floor(), + pixel_height, + ) } else { (pixel_width, target_height) } @@ -437,7 +440,10 @@ impl crate::TermWindow { // Height is the longest side let target_width = pixel_height / aspect; if target_width > pixel_width { - (pixel_width, pixel_height * pixel_width / target_width) + ( + pixel_width, + (pixel_height * pixel_width / target_width).floor(), + ) } else { (target_width, pixel_height) } @@ -447,14 +453,17 @@ impl crate::TermWindow { let (min_aspect_width, min_aspect_height) = if aspect >= 1.0 { // Width is the longest side if tex_height > pixel_height { - (tex_width * pixel_height / tex_height, pixel_height) + ( + (tex_width * pixel_height / tex_height).floor(), + pixel_height, + ) } else { (tex_width, tex_height) } } else { // Height is the longest side if tex_width > pixel_width { - (pixel_width, tex_height * pixel_width / tex_width) + (pixel_width, (tex_height * pixel_width / tex_width).floor()) } else { (tex_width, tex_height) }