From 31ab5b8e3083d66fdfd9a243029c8bfc1a7a4b40 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Mon, 23 Sep 2024 11:02:44 +0100 Subject: [PATCH] Windows: respect CONF_window_border when maximised. The code in the 'if (IsZoomed)' statement in reset_window() was failing to take account of the user-configured gap between the text and the window edge, so that the requested border was lost. Now it does take that into account. In this commit, this change of behaviour applies to both a normally maximised window (with the window frame still visible round the edge) and to a full-screen window (nothing visible on the whole monitor except PuTTY). I'm not 100% sure whether that's the right behaviour: perhaps the purpose of this configurable border is to space the text away from the window furniture, so that there's no need for it if there isn't any furniture? But on the other hand, one thing _I_ use this border for is to make space round the edge of a terminal window for the green border Zoom superimposes when sharing the window. And that's a use case that would still make sense when the window is full-screened. --- windows/window.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/windows/window.c b/windows/window.c index d5717138..14bab0ba 100644 --- a/windows/window.c +++ b/windows/window.c @@ -1805,9 +1805,14 @@ static void reset_window(WinGuiSeat *wgs, int reinit) if (resize_action != RESIZE_TERM) { if (wgs->font_width != win_width/wgs->term->cols || wgs->font_height != win_height/wgs->term->rows) { + int fw = (win_width - 2*window_border) / wgs->term->cols; + int fh = (win_height - 2*window_border) / wgs->term->rows; + /* In case that subtraction made the font size go + * negative in an edge case, bound it below by 1 */ + if (fw < 1) fw = 1; + if (fh < 1) fh = 1; deinit_fonts(wgs); - init_fonts(wgs, win_width/wgs->term->cols, - win_height/wgs->term->rows); + init_fonts(wgs, fw, fh); wgs->offset_width = (win_width - wgs->font_width*wgs->term->cols) / 2; wgs->offset_height = @@ -1824,13 +1829,14 @@ static void reset_window(WinGuiSeat *wgs, int reinit) /* Our only choice at this point is to change the * size of the terminal; Oh well. */ - term_size(wgs->term, win_height / wgs->font_height, - win_width / wgs->font_width, + term_size(wgs->term, + (win_height - 2*window_border) / wgs->font_height, + (win_width - 2*window_border) / wgs->font_width, conf_get_int(wgs->conf, CONF_savelines)); wgs->offset_width = - (win_width - wgs->font_width*wgs->term->cols) / 2; + (win_width - window_border - wgs->font_width*wgs->term->cols) / 2; wgs->offset_height = - (win_height - wgs->font_height*wgs->term->rows) / 2; + (win_height - window_border - wgs->font_height*wgs->term->rows) / 2; InvalidateRect(wgs->term_hwnd, NULL, true); #ifdef RDB_DEBUG_PATCH debug("reset_window() -> Zoomed term_size\n");