From 60056fdd6121d8b63aad01b1d891bd554bf880f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Fri, 14 Feb 2020 19:03:33 +0100 Subject: [PATCH] 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. --- render.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/render.c b/render.c index f81451b8..2c48629b 100644 --- a/render.c +++ b/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->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 */ struct row **normal = calloc(new_normal_grid_rows, sizeof(normal[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; tll_free(term->normal.scroll_damage); tll_free(term->alt.scroll_damage); + +done: term->render.last_buf = NULL; term_damage_view(term); render_refresh(term);