mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 17:38:00 +00:00
Jacob's patch to improve Close On Exit behaviour
[originally from svn r927]
This commit is contained in:
parent
0507b7437a
commit
4d830f7587
9
putty.h
9
putty.h
@ -130,6 +130,15 @@ enum {
|
||||
LD_ECHO /* local echo */
|
||||
};
|
||||
|
||||
enum {
|
||||
/*
|
||||
* Close On Exit behaviours. (cfg.close_on_exit)
|
||||
*/
|
||||
COE_NEVER, /* Never close the window */
|
||||
COE_ALWAYS, /* Always close the window */
|
||||
COE_NORMAL /* Close window on "normal" (non-error) exits only */
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
char *(*init) (char *host, int port, char **realhost);
|
||||
void (*send) (char *buf, int len);
|
||||
|
@ -42,7 +42,7 @@ void save_settings (char *section, int do_host, Config *cfg) {
|
||||
}
|
||||
write_setting_s (sesskey, "Protocol", p);
|
||||
}
|
||||
write_setting_i (sesskey, "CloseOnExit", !!cfg->close_on_exit);
|
||||
write_setting_i (sesskey, "CloseOnExit", cfg->close_on_exit);
|
||||
write_setting_i (sesskey, "WarnOnClose", !!cfg->warn_on_close);
|
||||
write_setting_i (sesskey, "PingInterval", cfg->ping_interval / 60); /* minutes */
|
||||
write_setting_i (sesskey, "PingIntervalSecs", cfg->ping_interval % 60); /* seconds */
|
||||
@ -171,7 +171,7 @@ void load_settings (char *section, int do_host, Config *cfg) {
|
||||
break;
|
||||
}
|
||||
|
||||
gppi (sesskey, "CloseOnExit", 1, &cfg->close_on_exit);
|
||||
gppi (sesskey, "CloseOnExit", COE_NORMAL, &cfg->close_on_exit);
|
||||
gppi (sesskey, "WarnOnClose", 1, &cfg->warn_on_close);
|
||||
{
|
||||
/* This is two values for backward compatibility with 0.50/0.51 */
|
||||
|
29
windlg.c
29
windlg.c
@ -204,6 +204,9 @@ enum { IDCX_ABOUT = IDC_ABOUT, IDCX_TVSTATIC, IDCX_TREEVIEW, controlstartvalue,
|
||||
IDC_SESSSAVE,
|
||||
IDC_SESSDEL,
|
||||
IDC_CLOSEEXIT,
|
||||
IDC_COEALWAYS,
|
||||
IDC_COENORMAL,
|
||||
IDC_COENEVER,
|
||||
sessionpanelend,
|
||||
|
||||
loggingpanelstart,
|
||||
@ -537,7 +540,9 @@ static void init_dlg_ctrls(HWND hwnd) {
|
||||
CheckDlgButton (hwnd, IDC_BLINKCUR, cfg.blink_cur);
|
||||
CheckDlgButton (hwnd, IDC_SCROLLBAR, cfg.scrollbar);
|
||||
CheckDlgButton (hwnd, IDC_LOCKSIZE, cfg.locksize);
|
||||
CheckDlgButton (hwnd, IDC_CLOSEEXIT, cfg.close_on_exit);
|
||||
CheckRadioButton (hwnd, IDC_COEALWAYS, IDC_COENEVER,
|
||||
cfg.close_on_exit==COE_NEVER ? IDC_COENEVER :
|
||||
cfg.close_on_exit==COE_NORMAL ? IDC_COENORMAL : IDC_COEALWAYS);
|
||||
CheckDlgButton (hwnd, IDC_CLOSEWARN, cfg.warn_on_close);
|
||||
|
||||
SetDlgItemText (hwnd, IDC_TTEDIT, cfg.termtype);
|
||||
@ -659,7 +664,7 @@ static HTREEITEM treeview_insert(struct treeview_faff *faff,
|
||||
*/
|
||||
static void create_controls(HWND hwnd, int dlgtype, int panel) {
|
||||
if (panel == sessionpanelstart) {
|
||||
/* The Session panel. Accelerators used: [acgo] nprtih elsd x */
|
||||
/* The Session panel. Accelerators used: [acgo] nprtih elsd w */
|
||||
struct ctlpos cp;
|
||||
ctlposinit(&cp, hwnd, 80, 3, 13);
|
||||
bartitle(&cp, "Basic options for your PuTTY session",
|
||||
@ -699,7 +704,10 @@ static void create_controls(HWND hwnd, int dlgtype, int panel) {
|
||||
endbox(&cp);
|
||||
}
|
||||
beginbox(&cp, NULL, IDC_BOX_SESSION3);
|
||||
checkbox(&cp, "Close Window on E&xit", IDC_CLOSEEXIT);
|
||||
radioline(&cp, "At session end, close &window:", IDC_CLOSEEXIT, 3,
|
||||
"Always", IDC_COEALWAYS,
|
||||
"On clean exit", IDC_COENORMAL,
|
||||
"Never", IDC_COENEVER, NULL);
|
||||
endbox(&cp);
|
||||
}
|
||||
|
||||
@ -1596,11 +1604,16 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg,
|
||||
GetDlgItemText (hwnd, IDC_WINEDIT, cfg.wintitle,
|
||||
sizeof(cfg.wintitle)-1);
|
||||
break;
|
||||
case IDC_CLOSEEXIT:
|
||||
if (HIWORD(wParam) == BN_CLICKED ||
|
||||
HIWORD(wParam) == BN_DOUBLECLICKED)
|
||||
cfg.close_on_exit = IsDlgButtonChecked (hwnd, IDC_CLOSEEXIT);
|
||||
break;
|
||||
case IDC_COEALWAYS:
|
||||
case IDC_COENORMAL:
|
||||
case IDC_COENEVER:
|
||||
if (HIWORD(wParam) == BN_CLICKED ||
|
||||
HIWORD(wParam) == BN_DOUBLECLICKED) {
|
||||
cfg.close_on_exit = IsDlgButtonChecked (hwnd, IDC_COEALWAYS) ? COE_ALWAYS :
|
||||
IsDlgButtonChecked (hwnd, IDC_COENORMAL) ? COE_NORMAL :
|
||||
COE_NEVER;
|
||||
}
|
||||
break;
|
||||
case IDC_CLOSEWARN:
|
||||
if (HIWORD(wParam) == BN_CLICKED ||
|
||||
HIWORD(wParam) == BN_DOUBLECLICKED)
|
||||
|
19
window.c
19
window.c
@ -667,7 +667,7 @@ void connection_fatal(char *fmt, ...) {
|
||||
vsprintf(stuff, fmt, ap);
|
||||
va_end(ap);
|
||||
MessageBox(hwnd, stuff, "PuTTY Fatal Error", MB_ICONERROR | MB_OK);
|
||||
if (cfg.close_on_exit)
|
||||
if (cfg.close_on_exit == COE_ALWAYS)
|
||||
PostQuitMessage(1);
|
||||
else {
|
||||
session_closed = TRUE;
|
||||
@ -692,16 +692,17 @@ static void enact_pending_netevent(void) {
|
||||
ret = select_result (pend_netevent_wParam, pend_netevent_lParam);
|
||||
reentering = 0;
|
||||
|
||||
if (ret == 0) {
|
||||
if (cfg.close_on_exit)
|
||||
if (ret == 0 && !session_closed) {
|
||||
/* Abnormal exits will already have set session_closed and taken
|
||||
* appropriate action. */
|
||||
if (cfg.close_on_exit == COE_ALWAYS ||
|
||||
cfg.close_on_exit == COE_NORMAL)
|
||||
PostQuitMessage(0);
|
||||
else {
|
||||
if (!session_closed) {
|
||||
session_closed = TRUE;
|
||||
SetWindowText (hwnd, "PuTTY (inactive)");
|
||||
MessageBox(hwnd, "Connection closed by remote host",
|
||||
"PuTTY", MB_OK | MB_ICONINFORMATION);
|
||||
}
|
||||
session_closed = TRUE;
|
||||
SetWindowText (hwnd, "PuTTY (inactive)");
|
||||
MessageBox(hwnd, "Connection closed by remote host",
|
||||
"PuTTY", MB_OK | MB_ICONINFORMATION);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user