From 4bd62b10058c626cecb5eb15c9c44aee58bf547a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Thu, 22 Jun 2023 15:01:59 +0200 Subject: [PATCH] =?UTF-8?q?render:=20maybe=5Fresize():=20convert=20local?= =?UTF-8?q?=20variable=20=E2=80=98scale=E2=80=99=20to=20float?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- render.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/render.c b/render.c index 25249218..3c2e6f18 100644 --- a/render.c +++ b/render.c @@ -3868,13 +3868,13 @@ maybe_resize(struct terminal *term, int width, int height, bool force) if (term->cell_width == 0 && term->cell_height == 0) return false; - int scale = -1; + float scale = -1; tll_foreach(term->window->on_outputs, it) { if (it->item->scale > scale) scale = it->item->scale; } - if (scale < 0) { + if (scale < 0.) { /* Haven't 'entered' an output yet? */ scale = term->scale; } @@ -3922,13 +3922,18 @@ maybe_resize(struct terminal *term, int width, int height, bool force) * Ensure we can scale to logical size, and back to * pixels without truncating. */ - if (width % scale) - width += scale - width % scale; - if (height % scale) - height += scale - height % scale; + if (wayl_fractional_scaling(term->wl)) { + xassert((int)round(scale) == (int)scale); - xassert(width % scale == 0); - xassert(height % scale == 0); + 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); + } break; } }