From 3da0b1d2851d9ab4e15bf611be157ab3a8b33e75 Mon Sep 17 00:00:00 2001 From: simon Date: Sun, 7 Jan 2001 16:27:48 +0000 Subject: [PATCH] `Change Settings' now behaves sensibly w.r.t. window size. git-svn-id: svn://svn.tartarus.org/sgt/putty@841 cda61777-01e9-0310-a592-d414129be87e --- putty.h | 1 + windlg.c | 6 ++---- window.c | 21 ++++++++++++++++----- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/putty.h b/putty.h index a2bdeb1a..033b581c 100644 --- a/putty.h +++ b/putty.h @@ -284,6 +284,7 @@ void showabout (HWND); void verify_ssh_host_key(char *host, int port, char *keytype, char *keystr, char *fingerprint); void registry_cleanup(void); +void force_normal(HWND hwnd); GLOBAL int nsessions; GLOBAL char **sessions; diff --git a/windlg.c b/windlg.c index aa483465..9dab862f 100644 --- a/windlg.c +++ b/windlg.c @@ -17,7 +17,7 @@ static HWND logbox = NULL, abtbox = NULL; static int readytogo; -static void force_normal(HWND hwnd) +void force_normal(HWND hwnd) { static int recurse = 0; @@ -27,7 +27,7 @@ static void force_normal(HWND hwnd) recurse = 1; wp.length = sizeof(wp); - if (GetWindowPlacement(hwnd, &wp)) + if (GetWindowPlacement(hwnd, &wp) && wp.showCmd == SW_SHOWMAXIMIZED) { wp.showCmd = SW_SHOWNORMAL; SetWindowPlacement(hwnd, &wp); @@ -1787,8 +1787,6 @@ int do_reconfig (HWND hwnd) { ret = DialogBox (hinst, MAKEINTRESOURCE(IDD_RECONF), hwnd, ReconfDlgProc); if (!ret) cfg = backup_cfg; /* structure copy */ - else - force_normal(hwnd); return ret; } diff --git a/window.c b/window.c index 46d9f7ee..b9f509e7 100644 --- a/window.c +++ b/window.c @@ -1169,6 +1169,9 @@ static LRESULT CALLBACK WndProc (HWND hwnd, UINT message, case IDM_RECONF: { int prev_alwaysontop = cfg.alwaysontop; + int need_setwpos = FALSE; + cfg.width = cols; + cfg.height = rows; if (!do_reconfig(hwnd)) break; just_reconfigged = TRUE; @@ -1231,6 +1234,7 @@ static LRESULT CALLBACK WndProc (HWND hwnd, UINT message, SetWindowLong(hwnd, GWL_EXSTYLE, nexflag); SendMessage (hwnd, WM_IGNORE_SIZE, 0, 0); + SetWindowPos(hwnd, NULL, 0,0,0,0, SWP_NOACTIVATE|SWP_NOCOPYBITS| SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER| @@ -1243,13 +1247,20 @@ static LRESULT CALLBACK WndProc (HWND hwnd, UINT message, } } + if (cfg.height != rows || + cfg.width != cols || + cfg.savelines != savelines) + need_setwpos = TRUE; term_size(cfg.height, cfg.width, cfg.savelines); InvalidateRect(hwnd, NULL, TRUE); - SetWindowPos (hwnd, NULL, 0, 0, - extra_width + font_width * cfg.width, - extra_height + font_height * cfg.height, - SWP_NOACTIVATE | SWP_NOCOPYBITS | - SWP_NOMOVE | SWP_NOZORDER); + if (need_setwpos) { + force_normal(hwnd); + SetWindowPos (hwnd, NULL, 0, 0, + extra_width + font_width * cfg.width, + extra_height + font_height * cfg.height, + SWP_NOACTIVATE | SWP_NOCOPYBITS | + SWP_NOMOVE | SWP_NOZORDER); + } if (IsIconic(hwnd)) { SetWindowText (hwnd, cfg.win_name_always ? window_name : icon_name); -- 2.11.0