From: simon Date: Fri, 12 Oct 2001 21:10:56 +0000 (+0000) Subject: Revamp the window-resize behaviour UI so there are only three states X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/commitdiff_plain/ad5c93cc19001ef3e9f3ccb0fb63d34140481c05 Revamp the window-resize behaviour UI so there are only three states rather than four. Should fix all sorts of bugs, since the fourth (and default!) state was behaving weirdly and nobody liked it. git-svn-id: svn://svn.tartarus.org/sgt/putty@1307 cda61777-01e9-0310-a592-d414129be87e --- diff --git a/putty.h b/putty.h index 755e69e0..b9300431 100644 --- a/putty.h +++ b/putty.h @@ -303,8 +303,7 @@ typedef struct { int bellovl_s; /* period of silence to re-enable bell (s) */ char bell_wavefile[FILENAME_MAX]; int scrollbar; - int locksize; - int lockfont; + enum { RESIZE_TERM, RESIZE_DISABLED, RESIZE_FONT } resize_action; int bce; int blinktext; int win_name_always; diff --git a/settings.c b/settings.c index b81b7c93..06919050 100644 --- a/settings.c +++ b/settings.c @@ -252,8 +252,7 @@ void save_settings(char *section, int do_host, Config * cfg) write_setting_i(sesskey, "ScrollBar", cfg->scrollbar); write_setting_i(sesskey, "ScrollOnKey", cfg->scroll_on_key); write_setting_i(sesskey, "ScrollOnDisp", cfg->scroll_on_disp); - write_setting_i(sesskey, "LockSize", cfg->locksize); - write_setting_i(sesskey, "LockFont", cfg->lockfont); + write_setting_i(sesskey, "LockSize", cfg->resize_action); write_setting_i(sesskey, "BCE", cfg->bce); write_setting_i(sesskey, "BlinkText", cfg->blinktext); write_setting_i(sesskey, "X11Forward", cfg->x11_forward); @@ -476,8 +475,7 @@ void load_settings(char *section, int do_host, Config * cfg) gppi(sesskey, "ScrollBar", 1, &cfg->scrollbar); gppi(sesskey, "ScrollOnKey", 0, &cfg->scroll_on_key); gppi(sesskey, "ScrollOnDisp", 1, &cfg->scroll_on_disp); - gppi(sesskey, "LockSize", 0, &cfg->locksize); - gppi(sesskey, "LockFont", cfg->locksize, &cfg->lockfont); + gppi(sesskey, "LockSize", 0, &cfg->resize_action); gppi(sesskey, "BCE", 0, &cfg->bce); gppi(sesskey, "BlinkText", 0, &cfg->blinktext); gppi(sesskey, "X11Forward", 0, &cfg->x11_forward); diff --git a/windlg.c b/windlg.c index aee98547..91a2e27e 100644 --- a/windlg.c +++ b/windlg.c @@ -354,8 +354,10 @@ enum { IDCX_ABOUT = IDC_ROWSEDIT, IDC_COLSSTATIC, IDC_COLSEDIT, - IDC_LOCKSIZE, - IDC_LOCKFONT, + IDC_RESIZESTATIC, + IDC_RESIZETERM, + IDC_RESIZEFONT, + IDC_RESIZENONE, IDC_SCROLLBAR, IDC_CLOSEWARN, IDC_SAVESTATIC, @@ -673,8 +675,10 @@ static void init_dlg_ctrls(HWND hwnd, int keepsess) cfg.cursor_type == 1 ? IDC_CURUNDER : IDC_CURVERT); CheckDlgButton(hwnd, IDC_BLINKCUR, cfg.blink_cur); CheckDlgButton(hwnd, IDC_SCROLLBAR, cfg.scrollbar); - CheckDlgButton(hwnd, IDC_LOCKSIZE, cfg.locksize); - CheckDlgButton(hwnd, IDC_LOCKFONT, cfg.lockfont); + CheckRadioButton(hwnd, IDC_RESIZETERM, IDC_RESIZENONE, + cfg.resize_action == RESIZE_TERM ? IDC_RESIZETERM : + cfg.resize_action == RESIZE_FONT ? IDC_RESIZEFONT : + IDC_RESIZENONE); CheckRadioButton(hwnd, IDC_COEALWAYS, IDC_COENORMAL, cfg.close_on_exit == COE_NORMAL ? IDC_COENORMAL : cfg.close_on_exit == @@ -1045,8 +1049,10 @@ static void create_controls(HWND hwnd, int dlgtype, int panel) multiedit(&cp, "&Rows", IDC_ROWSSTATIC, IDC_ROWSEDIT, 50, "Colu&mns", IDC_COLSSTATIC, IDC_COLSEDIT, 50, NULL); - checkbox(&cp, "Lock terminal size against resi&zing", IDC_LOCKSIZE); - checkbox(&cp, "Lock font size against resi&zing", IDC_LOCKFONT); + radioline(&cp, "Action when the window is resized:", IDC_RESIZESTATIC, + 3, "Resi&ze terminal", IDC_RESIZETERM, + "Change fo&nt", IDC_RESIZEFONT, + "Forb&id resizing", IDC_RESIZENONE, NULL); endbox(&cp); beginbox(&cp, "Control the scrollback in the window", IDC_BOX_WINDOW2); @@ -2108,17 +2114,18 @@ static int GenericMainDlgProc(HWND hwnd, UINT msg, cfg.scrollbar = IsDlgButtonChecked(hwnd, IDC_SCROLLBAR); break; - case IDC_LOCKSIZE: + case IDC_RESIZETERM: + case IDC_RESIZEFONT: + case IDC_RESIZENONE: if (HIWORD(wParam) == BN_CLICKED || - HIWORD(wParam) == BN_DOUBLECLICKED) - cfg.locksize = - IsDlgButtonChecked(hwnd, IDC_LOCKSIZE); - break; - case IDC_LOCKFONT: - if (HIWORD(wParam) == BN_CLICKED || - HIWORD(wParam) == BN_DOUBLECLICKED) - cfg.lockfont = - IsDlgButtonChecked(hwnd, IDC_LOCKFONT); + HIWORD(wParam) == BN_DOUBLECLICKED) { + cfg.resize_action = + IsDlgButtonChecked(hwnd, + IDC_RESIZETERM) ? RESIZE_TERM : + IsDlgButtonChecked(hwnd, + IDC_RESIZEFONT) ? RESIZE_FONT : + RESIZE_DISABLED; + } break; case IDC_WINEDIT: if (HIWORD(wParam) == EN_CHANGE) diff --git a/window.c b/window.c index b887aca7..8e576bf3 100644 --- a/window.c +++ b/window.c @@ -429,7 +429,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) int exwinmode = 0; if (!cfg.scrollbar) winmode &= ~(WS_VSCROLL); - if (cfg.locksize && cfg.lockfont) + if (cfg.resize_action == RESIZE_DISABLED) winmode &= ~(WS_THICKFRAME | WS_MAXIMIZEBOX); if (cfg.alwaysontop) exwinmode |= WS_EX_TOPMOST; @@ -1092,11 +1092,11 @@ void request_resize(int w, int h) /* If the window is maximized supress resizing attempts */ if (IsZoomed(hwnd)) { - if (cfg.lockfont) + if (cfg.resize_action != RESIZE_FONT) return; } - if (cfg.lockfont && cfg.locksize) return; + if (cfg.resize_action == RESIZE_DISABLED) return; if (h == rows && w == cols) return; /* Sanity checks ... */ @@ -1129,7 +1129,7 @@ void request_resize(int w, int h) term_size(h, w, cfg.savelines); - if (cfg.lockfont) { + if (cfg.resize_action != RESIZE_FONT) { width = extra_width + font_width * w; height = extra_height + font_height * h; @@ -1197,7 +1197,7 @@ static void reset_window(int reinit) { extra_width = wr.right - wr.left - cr.right + cr.left; extra_height = wr.bottom - wr.top - cr.bottom + cr.top; - if (!cfg.lockfont) { + if (cfg.resize_action == RESIZE_FONT) { if ( font_width != win_width/cols || font_height != win_height/rows) { deinit_fonts(); @@ -1260,7 +1260,7 @@ static void reset_window(int reinit) { * window. But that may be too big for the screen which forces us * to change the terminal. */ - if ((cfg.lockfont && reinit==0) || reinit>0) { + if ((cfg.resize_action != RESIZE_FONT && reinit==0) || reinit>0) { offset_width = offset_height = cfg.window_border; extra_width = wr.right - wr.left - cr.right + cr.left + offset_width*2; extra_height = wr.bottom - wr.top - cr.bottom + cr.top +offset_height*2; @@ -1520,7 +1520,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, if (cfg.height != prev_cfg.height || cfg.width != prev_cfg.width || cfg.savelines != prev_cfg.savelines || - cfg.locksize ) + cfg.resize_action != RESIZE_TERM) term_size(cfg.height, cfg.width, cfg.savelines); /* Enable or disable the scroll bar, etc */ @@ -1551,7 +1551,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, nflg |= WS_VSCROLL; else nflg &= ~WS_VSCROLL; - if (cfg.locksize && cfg.lockfont) + if (cfg.resize_action == RESIZE_DISABLED) nflg &= ~(WS_THICKFRAME | WS_MAXIMIZEBOX); else nflg |= (WS_THICKFRAME | WS_MAXIMIZEBOX); @@ -1572,7 +1572,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, } /* Oops */ - if (cfg.locksize && cfg.lockfont && IsZoomed(hwnd)) { + if (cfg.resize_action == RESIZE_DISABLED && IsZoomed(hwnd)) { force_normal(hwnd); init_lvl = 2; } @@ -1591,7 +1591,8 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, cfg.fontcharset != prev_cfg.fontcharset || cfg.vtmode != prev_cfg.vtmode || cfg.bold_colour != prev_cfg.bold_colour || - (cfg.lockfont && !prev_cfg.lockfont)) + (cfg.resize_action != RESIZE_FONT && + prev_cfg.resize_action == RESIZE_FONT)) init_lvl = 2; InvalidateRect(hwnd, NULL, TRUE); @@ -1902,7 +1903,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, * 1) Keep the sizetip uptodate * 2) Make sure the window size is _stepped_ in units of the font size. */ - if (!cfg.locksize && !alt_pressed) { + if (cfg.resize_action == RESIZE_TERM && !alt_pressed) { int width, height, w, h, ew, eh; LPRECT r = (LPRECT) lParam; @@ -2002,7 +2003,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, if (wParam == SIZE_RESTORED || wParam == SIZE_MAXIMIZED) SetWindowText(hwnd, window_name); - if (cfg.lockfont && cfg.locksize) { + if (cfg.resize_action == RESIZE_DISABLED) { /* A resize, well it better be a minimize. */ reset_window(-1); } else { @@ -2017,7 +2018,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, was_zoomed = 1; prev_rows = rows; prev_cols = cols; - if (cfg.lockfont) { + if (cfg.resize_action != RESIZE_FONT) { w = width / font_width; if (w < 1) w = 1; h = height / font_height; @@ -2028,7 +2029,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, reset_window(0); } else if (wParam == SIZE_RESTORED && was_zoomed) { was_zoomed = 0; - if (cfg.lockfont) + if (cfg.resize_action != RESIZE_FONT) term_size(prev_rows, prev_cols, cfg.savelines); reset_window(0); } @@ -2047,7 +2048,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, * down the connection during an NT opaque drag.) */ if (resizing) { - if (!cfg.locksize && !alt_pressed) { + if (cfg.resize_action == RESIZE_TERM && !alt_pressed) { need_backend_resize = TRUE; w = (width-cfg.window_border*2) / font_width; if (w < 1) w = 1;