From b60230dbb8a55da4a29a31c1787a6926010aa901 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sun, 8 Sep 2019 13:40:14 +0100 Subject: [PATCH] Windows: fix resizing of a maximised window. The RESIZE_EITHER resizing mode responds to a window resize by changing the logical terminal size if the window is shown normally, or by changing the font size to keep the terminal size the same if the resize is a transition between normal and maximised state. But a user pointed out that it's also possible for a window to receive a WM_SIZE message while _remaining_ in maximised state, and that PuTTY's resize logic didn't allow for that possibility. It occurs when there's a change in the amount of available screen space for the window to be maximised _in_: e.g. when the video resolution is reconfigured, or when you reconnect to a Remote Desktop session using a client window of a different size, or even when you toggle the 'Automatically hide the taskbar' option in the Windows taskbar settings. In that situation, the right thing seems to be for PuTTY to continue to go with the policy of changing the font size rather than the logical terminal size. In other words, we prefer to change the font size when the resize is _from_ maximised state, _to_ maximised state, _or both_. That's easily implemented by removing the check of the 'was_zoomed' flag, in the case where we've received a WM_SIZE message with the state SIZE_MAXIMIZED: once we know the transition is _to_ maximised state, it doesn't matter whether or not it was also _from_ it. (But we still set the was_zoomed flag to the most recent maximised status, so that we can recognise transitions _out_ of maximised mode.) --- windows/window.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/windows/window.c b/windows/window.c index 26ef3bbf..cf1d0e88 100644 --- a/windows/window.c +++ b/windows/window.c @@ -3072,7 +3072,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, width = LOWORD(lParam); height = HIWORD(lParam); - if (wParam == SIZE_MAXIMIZED && !was_zoomed) { + if (wParam == SIZE_MAXIMIZED) { was_zoomed = true; prev_rows = term->rows; prev_cols = term->cols;