From 1af0277564f6347caa85fda4b46071c0cf03234c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sun, 30 Jul 2023 07:53:33 +0200 Subject: [PATCH] --window-size-chars: ensure width/height are valid for current scaling factor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this patch, we didn’t ensure width and height were valid for the current scaling factor, when fractional scaling _is_ available. That is, we didn’t ensure the width/height values multiplied back to their original values after dividing with the scaling factor. Closes #1446 --- CHANGELOG.md | 4 ++++ render.c | 19 +++---------------- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a5bd8be..916880c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -72,12 +72,16 @@ * Crash when compositor does not implement the _viewporter_ interface ([#1444][1444]). * CSD rendering with fractional scaling ([#1441][1441]). +* Regression: crash with certain combinations of + `--window-size-chars=NxM` and desktop scaling factors + ([#1446][1446]). [1423]: https://codeberg.org/dnkl/foot/issues/1423 [1431]: https://codeberg.org/dnkl/foot/issues/1431 [1430]: https://codeberg.org/dnkl/foot/issues/1430 [1444]: https://codeberg.org/dnkl/foot/issues/1444 [1441]: https://codeberg.org/dnkl/foot/issues/1441 +[1446]: https://codeberg.org/dnkl/foot/issues/1446 ### Security diff --git a/render.c b/render.c index 893b461a..5c6eeb92 100644 --- a/render.c +++ b/render.c @@ -3933,22 +3933,9 @@ maybe_resize(struct terminal *term, int width, int height, bool force) width += 2 * term->conf->pad_x * scale; height += 2 * term->conf->pad_y * scale; - /* - * Ensure we can scale to logical size, and back to - * pixels without truncating. - */ - if (!term_fractional_scaling(term)) { - xassert((int)ceilf(scale) == (int)scale); - - int iscale = scale; - if (width % iscale) - width += iscale - width % iscale; - if (height % iscale) - height += iscale - height % iscale; - - xassert(width % iscale == 0); - xassert(height % iscale == 0); - } + /* Ensure width/height is a valid multiple of scale */ + width = roundf(scale * roundf(width / scale)); + height = roundf(scale * roundf(height / scale)); break; } }