terminal: Avoid too large character grid when resized

When resizing the terminal, the row/columns would end up potentially too tall
and/or wide, meaning the widget would grow each time the window was configured
with a size.

Fix this by making sure the calculated rows and columns don't loose too much
precision, and if they do, shrink instead of grow, as that is expected by the
xdg_toplevel configure event.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
This commit is contained in:
Jonas Ådahl 2024-05-14 14:34:52 +02:00 committed by Marius Vlad
parent d4fe0a42fd
commit 6975cf4265

View file

@ -868,8 +868,8 @@ resize_handler(struct widget *widget,
terminal->pace_pipe = -1;
}
m = 2 * terminal->margin;
columns = (width - m) / (int32_t) terminal->average_width;
rows = (height - m) / (int32_t) terminal->extents.height;
columns = (int32_t) round((width - m) / terminal->average_width);
rows = (int32_t) round((height - m) / terminal->extents.height);
if (!window_is_fullscreen(terminal->window) &&
!window_is_maximized(terminal->window)) {