From 232c6eacfb0a777d55172e80c494d2623bdea47f Mon Sep 17 00:00:00 2001 From: simon Date: Wed, 22 Dec 2010 15:49:33 +0000 Subject: [PATCH] Reorganise handling of WM_SIZE to fix two generality problems. Firstly, maximise and restore events were expected never to occur during an interactive resize process (i.e. between WM_ENTERSIZEMOVE and WM_EXITSIZEMOVE), but in fact Aero now allows this to happen if you move the pointer to the top of the screen while dragging the window. Secondly, plain old WM_SIZE events were expected never to occur _outside_ interactive resizes, but Aero permits that too (e.g. Windows-left and Windows-right), and also third-party window repositioning tools will send these. git-svn-id: svn://svn.tartarus.org/sgt/putty@9040 cda61777-01e9-0310-a592-d414129be87e --- windows/window.c | 87 ++++++++++++++++++++++++++------------------------------ 1 file changed, 41 insertions(+), 46 deletions(-) diff --git a/windows/window.c b/windows/window.c index 2b80430d..b00865ad 100644 --- a/windows/window.c +++ b/windows/window.c @@ -2750,55 +2750,50 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, width = LOWORD(lParam); height = HIWORD(lParam); - if (!resizing) { - if (wParam == SIZE_MAXIMIZED && !was_zoomed) { - was_zoomed = 1; - prev_rows = term->rows; - prev_cols = term->cols; - if (cfg.resize_action == RESIZE_TERM) { - w = width / font_width; - if (w < 1) w = 1; - h = height / font_height; - if (h < 1) h = 1; - - term_size(term, h, w, cfg.savelines); - } - reset_window(0); - } else if (wParam == SIZE_RESTORED && was_zoomed) { - was_zoomed = 0; - if (cfg.resize_action == RESIZE_TERM) - term_size(term, prev_rows, prev_cols, cfg.savelines); - if (cfg.resize_action != RESIZE_FONT) - reset_window(2); - else - reset_window(0); - } - /* This is an unexpected resize, these will normally happen - * if the window is too large. Probably either the user - * selected a huge font or the screen size has changed. - * - * This is also called with minimize. - */ - else reset_window(-1); - } - - /* - * Don't call back->size in mid-resize. (To prevent - * massive numbers of resize events getting sent - * down the connection during an NT opaque drag.) - */ - if (resizing) { - if (cfg.resize_action != RESIZE_FONT && !is_alt_pressed()) { + if (wParam == SIZE_MAXIMIZED && !was_zoomed) { + was_zoomed = 1; + prev_rows = term->rows; + prev_cols = term->cols; + if (cfg.resize_action == RESIZE_TERM) { + w = width / font_width; + if (w < 1) w = 1; + h = height / font_height; + if (h < 1) h = 1; + + term_size(term, h, w, cfg.savelines); + } + reset_window(0); + } else if (wParam == SIZE_RESTORED && was_zoomed) { + was_zoomed = 0; + if (cfg.resize_action == RESIZE_TERM) + term_size(term, prev_rows, prev_cols, cfg.savelines); + if (cfg.resize_action != RESIZE_FONT) + reset_window(2); + else + reset_window(0); + } else if (wParam == SIZE_MINIMIZED) { + /* do nothing */ + } else if (cfg.resize_action != RESIZE_FONT && !is_alt_pressed()) { + w = (width-cfg.window_border*2) / font_width; + if (w < 1) w = 1; + h = (height-cfg.window_border*2) / font_height; + if (h < 1) h = 1; + + if (resizing) { + /* + * Don't call back->size in mid-resize. (To + * prevent massive numbers of resize events + * getting sent down the connection during an NT + * opaque drag.) + */ need_backend_resize = TRUE; - w = (width-cfg.window_border*2) / font_width; - if (w < 1) w = 1; - h = (height-cfg.window_border*2) / font_height; - if (h < 1) h = 1; - cfg.height = h; cfg.width = w; - } else - reset_window(0); + } else { + term_size(term, h, w, cfg.savelines); + } + } else { + reset_window(0); } } sys_cursor_update(); -- 2.11.0