From 520915c641ae14bbcdb25a257d854b24e9be700e Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sat, 8 Jan 2022 13:48:41 +0000 Subject: [PATCH] Windows: make 'resize by changing font' work again. It looks as if I broke this some time around commit cfc902361633915, when I stopped proactively calling term_size() in advance of resizing the window. A side effect was that I also stopped calling it at all in the case where we're _not_ resizing the window (because changing the size of the terminal means adapting the font size to fit a different amount of stuff in the existing window). Fixed by moving all the new machinery inside the 'actually resize the window' branch of the if statement, and restoring the previous behaviour in the other branch, this time with a comment that will hopefully stop me making the same mistake again. --- windows/window.c | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/windows/window.c b/windows/window.c index f3ca5936..c1cd0c4c 100644 --- a/windows/window.c +++ b/windows/window.c @@ -1639,32 +1639,39 @@ static void wintw_request_resize(TermWin *tw, int w, int h) } } - /* - * We want to send exactly one term_size() to the terminal, - * telling it what size it ended up after this operation. - * - * If we don't get the size we asked for in SetWindowPos, then - * we'll be sent a WM_SIZE message, whose handler will make that - * call, all before SetWindowPos even returns to here. - * - * But if that _didn't_ happen, we'll need to call term_size - * ourselves afterwards. - */ - sent_term_size = false; - if (conf_get_int(conf, CONF_resize_action) != RESIZE_FONT && !IsZoomed(wgs.term_hwnd)) { + /* + * We want to send exactly one term_size() to the terminal, + * telling it what size it ended up after this operation. + * + * If we don't get the size we asked for in SetWindowPos, then + * we'll be sent a WM_SIZE message, whose handler will make + * that call, all before SetWindowPos even returns to here. + * + * But if that _didn't_ happen, we'll need to call term_size + * ourselves afterwards. + */ + sent_term_size = false; + width = extra_width + font_width * w; height = extra_height + font_height * h; SetWindowPos(wgs.term_hwnd, NULL, 0, 0, width, height, SWP_NOACTIVATE | SWP_NOCOPYBITS | SWP_NOMOVE | SWP_NOZORDER); - } else - reset_window(0); - if (!sent_term_size) + if (!sent_term_size) + term_size(term, h, w, conf_get_int(conf, CONF_savelines)); + } else { + /* + * If we're resizing by changing the font, we must tell the + * terminal the new size immediately, so that reset_window + * will know what to do. + */ term_size(term, h, w, conf_get_int(conf, CONF_savelines)); + reset_window(0); + } InvalidateRect(wgs.term_hwnd, NULL, true); }