mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-14 05:33:59 -04:00
render: resize: don't reflow text if grid layout hasn't changed
A window resize doesn't necessarily mean the grid layout changes. When it doesn't, don't reflow text. This fixes a slowness issue on Sway, when swapping positions of two ~equally sized windows.
This commit is contained in:
parent
ec63a24c80
commit
60056fdd61
1 changed files with 7 additions and 0 deletions
7
render.c
7
render.c
|
|
@ -1130,6 +1130,11 @@ maybe_resize(struct terminal *term, int width, int height, bool force)
|
||||||
term->x_margin = (term->width - new_cols * term->cell_width) / 2;
|
term->x_margin = (term->width - new_cols * term->cell_width) / 2;
|
||||||
term->y_margin = (term->height - new_rows * term->cell_height) / 2;
|
term->y_margin = (term->height - new_rows * term->cell_height) / 2;
|
||||||
|
|
||||||
|
if (old_rows == new_rows && old_cols == new_cols) {
|
||||||
|
/* Skip reflow if grid layout hasn't changed */
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
/* Allocate new 'normal' and 'alt' grids */
|
/* Allocate new 'normal' and 'alt' grids */
|
||||||
struct row **normal = calloc(new_normal_grid_rows, sizeof(normal[0]));
|
struct row **normal = calloc(new_normal_grid_rows, sizeof(normal[0]));
|
||||||
struct row **alt = calloc(new_alt_grid_rows, sizeof(alt[0]));
|
struct row **alt = calloc(new_alt_grid_rows, sizeof(alt[0]));
|
||||||
|
|
@ -1250,6 +1255,8 @@ maybe_resize(struct terminal *term, int width, int height, bool force)
|
||||||
term->render.last_cursor.cell = NULL;
|
term->render.last_cursor.cell = NULL;
|
||||||
tll_free(term->normal.scroll_damage);
|
tll_free(term->normal.scroll_damage);
|
||||||
tll_free(term->alt.scroll_damage);
|
tll_free(term->alt.scroll_damage);
|
||||||
|
|
||||||
|
done:
|
||||||
term->render.last_buf = NULL;
|
term->render.last_buf = NULL;
|
||||||
term_damage_view(term);
|
term_damage_view(term);
|
||||||
render_refresh(term);
|
render_refresh(term);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue