aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRonan Pigott <ronan@rjp.ie>2023-07-14 23:53:50 +0000
committerRonan Pigott <ronan@rjp.ie>2023-07-16 03:03:16 +0000
commitb7100d57160d2ae7a38d5517f1c2cd7155737d88 (patch)
tree94562102e5982602d8dcdd02b777134ee5a1db71
parentchangelog: add new ‘unreleased’ section (diff)
render: use rounding for fractional scale
If we truncate the buffer dimensions we may accidentally submit a buffer with inappropriate size.
-rw-r--r--CHANGELOG.md3
-rw-r--r--render.c4
-rw-r--r--terminal.c5
-rw-r--r--wayland.c4
4 files changed, 12 insertions, 4 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b5d21bd6..5a1eaaa5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -49,6 +49,9 @@
### Deprecated
### Removed
### Fixed
+
+* Use appropriate rounding when applying fractional scales.
+
### Security
### Contributors
diff --git a/render.c b/render.c
index 677856d8..d084a859 100644
--- a/render.c
+++ b/render.c
@@ -3856,8 +3856,8 @@ maybe_resize(struct terminal *term, int width, int height, bool force)
scale = term->scale;
}
- width *= scale;
- height *= scale;
+ width = round(width * scale);
+ height = round(height * scale);
if (width == 0 && height == 0) {
/*
diff --git a/terminal.c b/terminal.c
index fff55019..485e8ca3 100644
--- a/terminal.c
+++ b/terminal.c
@@ -778,7 +778,10 @@ term_set_fonts(struct terminal *term, struct fcft_font *fonts[static 4])
sixel_cell_size_changed(term);
/* Use force, since cell-width/height may have changed */
- render_resize_force(term, term->width / term->scale, term->height / term->scale);
+ render_resize_force(
+ term,
+ round(term->width / term->scale),
+ round(term->height / term->scale));
return true;
}
diff --git a/wayland.c b/wayland.c
index a25ec0f6..9195797e 100644
--- a/wayland.c
+++ b/wayland.c
@@ -401,7 +401,9 @@ update_term_for_output_change(struct terminal *term)
float old_scale = term->scale;
- render_resize(term, term->width / term->scale, term->height / term->scale);
+ render_resize(term,
+ round(term->width / term->scale),
+ round(term->height / term->scale));
term_font_dpi_changed(term, old_scale);
term_font_subpixel_changed(term);
csd_reload_font(term->window, old_scale);