1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-03-21 22:28:37 -05:00

Add support for Always On Top. Patch due to Janes "Ender" Brown.

[originally from svn r773]
This commit is contained in:
Simon Tatham 2000-10-27 09:46:04 +00:00
parent 696400a672
commit 091acb4e06
4 changed files with 42 additions and 16 deletions

View File

@ -165,6 +165,7 @@ typedef struct {
int alt_space; /* is it special? */ int alt_space; /* is it special? */
int alt_only; /* is it special? */ int alt_only; /* is it special? */
int ldisc_term; int ldisc_term;
int alwaysontop;
int scroll_on_key; int scroll_on_key;
int scroll_on_disp; int scroll_on_disp;
int compose_key; int compose_key;

View File

@ -89,6 +89,7 @@ void save_settings (char *section, int do_host, Config *cfg) {
write_setting_i (sesskey, "AltOnly", cfg->alt_only); write_setting_i (sesskey, "AltOnly", cfg->alt_only);
write_setting_i (sesskey, "ComposeKey", cfg->compose_key); write_setting_i (sesskey, "ComposeKey", cfg->compose_key);
write_setting_i (sesskey, "LdiscTerm", cfg->ldisc_term); write_setting_i (sesskey, "LdiscTerm", cfg->ldisc_term);
write_setting_i (sesskey, "AlwaysOnTop", cfg->alwaysontop);
write_setting_i (sesskey, "BlinkCur", cfg->blink_cur); write_setting_i (sesskey, "BlinkCur", cfg->blink_cur);
write_setting_i (sesskey, "Beep", cfg->beep); write_setting_i (sesskey, "Beep", cfg->beep);
write_setting_i (sesskey, "ScrollbackLines", cfg->savelines); write_setting_i (sesskey, "ScrollbackLines", cfg->savelines);
@ -217,6 +218,7 @@ void load_settings (char *section, int do_host, Config *cfg) {
gppi (sesskey, "AltOnly", 0, &cfg->alt_only); gppi (sesskey, "AltOnly", 0, &cfg->alt_only);
gppi (sesskey, "ComposeKey", 0, &cfg->compose_key); gppi (sesskey, "ComposeKey", 0, &cfg->compose_key);
gppi (sesskey, "LdiscTerm", 0, &cfg->ldisc_term); gppi (sesskey, "LdiscTerm", 0, &cfg->ldisc_term);
gppi (sesskey, "AlwaysOnTop", 0, &cfg->alwaysontop);
gppi (sesskey, "BlinkCur", 0, &cfg->blink_cur); gppi (sesskey, "BlinkCur", 0, &cfg->blink_cur);
gppi (sesskey, "Beep", 1, &cfg->beep); gppi (sesskey, "Beep", 1, &cfg->beep);
gppi (sesskey, "ScrollbackLines", 200, &cfg->savelines); gppi (sesskey, "ScrollbackLines", 200, &cfg->savelines);

View File

@ -258,6 +258,7 @@ enum { IDCX_ABOUT = IDC_ABOUT, IDCX_TVSTATIC, IDCX_TREEVIEW, controlstartvalue,
IDC_ALTONLY, IDC_ALTONLY,
IDC_SCROLLKEY, IDC_SCROLLKEY,
IDC_SCROLLDISP, IDC_SCROLLDISP,
IDC_ALWAYSONTOP,
windowpanelend, windowpanelend,
appearancepanelstart, appearancepanelstart,
@ -444,6 +445,7 @@ static void init_dlg_ctrls(HWND hwnd) {
CheckDlgButton (hwnd, IDC_ALTONLY, cfg.alt_only); CheckDlgButton (hwnd, IDC_ALTONLY, cfg.alt_only);
CheckDlgButton (hwnd, IDC_COMPOSEKEY, cfg.compose_key); CheckDlgButton (hwnd, IDC_COMPOSEKEY, cfg.compose_key);
CheckDlgButton (hwnd, IDC_LDISCTERM, cfg.ldisc_term); CheckDlgButton (hwnd, IDC_LDISCTERM, cfg.ldisc_term);
CheckDlgButton (hwnd, IDC_ALWAYSONTOP, cfg.alwaysontop);
CheckDlgButton (hwnd, IDC_SCROLLKEY, cfg.scroll_on_key); CheckDlgButton (hwnd, IDC_SCROLLKEY, cfg.scroll_on_key);
CheckDlgButton (hwnd, IDC_SCROLLDISP, cfg.scroll_on_disp); CheckDlgButton (hwnd, IDC_SCROLLDISP, cfg.scroll_on_disp);
@ -708,7 +710,7 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg,
checkbox(&cp, "&Beep enabled", IDC_BEEP); checkbox(&cp, "&Beep enabled", IDC_BEEP);
checkbox(&cp, "Use background colour to &erase screen", IDC_BCE); checkbox(&cp, "Use background colour to &erase screen", IDC_BCE);
checkbox(&cp, "Enable bli&nking text", IDC_BLINKTEXT); checkbox(&cp, "Enable bli&nking text", IDC_BLINKTEXT);
checkbox(&cp, "&Use local terminal line discipline", IDC_LDISCTERM); checkbox(&cp, "&Use local terminal line discipline", IDC_LDISCTERM);
endbox(&cp); endbox(&cp);
treeview_insert(&tvfaff, 0, "Terminal"); treeview_insert(&tvfaff, 0, "Terminal");
@ -759,7 +761,7 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg,
treeview_insert(&tvfaff, 1, "Keyboard"); treeview_insert(&tvfaff, 1, "Keyboard");
} }
/* The Window panel. Accelerators used: [acgo] bsdkw4ylp */ /* The Window panel. Accelerators used: [acgo] bsdkw4ylpt */
{ {
struct ctlpos cp; struct ctlpos cp;
ctlposinit(&cp, hwnd, 80, 3, 13); ctlposinit(&cp, hwnd, 80, 3, 13);
@ -787,6 +789,7 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg,
checkbox(&cp, "Window closes on ALT-F&4", IDC_ALTF4); checkbox(&cp, "Window closes on ALT-F&4", IDC_ALTF4);
checkbox(&cp, "S&ystem menu appears on ALT-Space", IDC_ALTSPACE); checkbox(&cp, "S&ystem menu appears on ALT-Space", IDC_ALTSPACE);
checkbox(&cp, "System menu appears on A&LT alone", IDC_ALTONLY); checkbox(&cp, "System menu appears on A&LT alone", IDC_ALTONLY);
checkbox(&cp, "Ensure window is always on &top", IDC_ALWAYSONTOP);
endbox(&cp); endbox(&cp);
treeview_insert(&tvfaff, 0, "Window"); treeview_insert(&tvfaff, 0, "Window");
@ -1275,6 +1278,11 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg,
HIWORD(wParam) == BN_DOUBLECLICKED) HIWORD(wParam) == BN_DOUBLECLICKED)
cfg.ldisc_term = IsDlgButtonChecked (hwnd, IDC_LDISCTERM); cfg.ldisc_term = IsDlgButtonChecked (hwnd, IDC_LDISCTERM);
break; break;
case IDC_ALWAYSONTOP:
if (HIWORD(wParam) == BN_CLICKED ||
HIWORD(wParam) == BN_DOUBLECLICKED)
cfg.alwaysontop = IsDlgButtonChecked (hwnd, IDC_ALWAYSONTOP);
break;
case IDC_SCROLLKEY: case IDC_SCROLLKEY:
if (HIWORD(wParam) == BN_CLICKED || if (HIWORD(wParam) == BN_CLICKED ||
HIWORD(wParam) == BN_DOUBLECLICKED) HIWORD(wParam) == BN_DOUBLECLICKED)

View File

@ -365,14 +365,15 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) {
{ {
int winmode = WS_OVERLAPPEDWINDOW|WS_VSCROLL; int winmode = WS_OVERLAPPEDWINDOW|WS_VSCROLL;
if (!cfg.scrollbar) winmode &= ~(WS_VSCROLL); int exwinmode = 0;
if (cfg.locksize) winmode &= ~(WS_THICKFRAME|WS_MAXIMIZEBOX); if (!cfg.scrollbar) winmode &= ~(WS_VSCROLL);
hwnd = CreateWindow (appname, appname, if (cfg.locksize) winmode &= ~(WS_THICKFRAME|WS_MAXIMIZEBOX);
winmode, if (cfg.alwaysontop) exwinmode = WS_EX_TOPMOST;
CW_USEDEFAULT, CW_USEDEFAULT, hwnd = CreateWindowEx (exwinmode, appname, appname,
guess_width, guess_height, winmode, CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL, inst, NULL); guess_width, guess_height,
} NULL, NULL, inst, NULL);
}
/* /*
* Initialise the fonts, simultaneously correcting the guesses * Initialise the fonts, simultaneously correcting the guesses
@ -1152,7 +1153,7 @@ static LRESULT CALLBACK WndProc (HWND hwnd, UINT message,
free(cl); free(cl);
} }
break; break;
case IDM_RECONF: case IDM_RECONF:
if (!do_reconfig(hwnd)) if (!do_reconfig(hwnd))
break; break;
just_reconfigged = TRUE; just_reconfigged = TRUE;
@ -1174,11 +1175,21 @@ static LRESULT CALLBACK WndProc (HWND hwnd, UINT message,
logpal = NULL; logpal = NULL;
pal = NULL; pal = NULL;
cfgtopalette(); cfgtopalette();
init_palette(); init_palette();
/* Enable or disable the scroll bar, etc */ /* Enable or disable the scroll bar, etc */
{ {
LONG nflg, flag = GetWindowLong(hwnd, GWL_STYLE); LONG nflg, flag = GetWindowLong(hwnd, GWL_STYLE);
LONG nexflag, exflag = GetWindowLong(hwnd, GWL_EXSTYLE);
nexflag = exflag;
if (cfg.alwaysontop) {
nexflag = WS_EX_TOPMOST;
SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE);
} else {
nexflag = 0;
SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE);
}
nflg = flag; nflg = flag;
if (cfg.scrollbar) nflg |= WS_VSCROLL; if (cfg.scrollbar) nflg |= WS_VSCROLL;
@ -1188,15 +1199,19 @@ static LRESULT CALLBACK WndProc (HWND hwnd, UINT message,
else else
nflg |= (WS_THICKFRAME|WS_MAXIMIZEBOX); nflg |= (WS_THICKFRAME|WS_MAXIMIZEBOX);
if (nflg != flag) if (nflg != flag || nexflag != exflag)
{ {
RECT cr, wr; RECT cr, wr;
SetWindowLong(hwnd, GWL_STYLE, nflg); if (nflg != flag)
SetWindowLong(hwnd, GWL_STYLE, nflg);
if (nexflag != exflag)
SetWindowLong(hwnd, GWL_EXSTYLE, nexflag);
SendMessage (hwnd, WM_IGNORE_SIZE, 0, 0); SendMessage (hwnd, WM_IGNORE_SIZE, 0, 0);
SetWindowPos(hwnd, NULL, 0,0,0,0, SetWindowPos(hwnd, NULL, 0,0,0,0,
SWP_NOACTIVATE|SWP_NOCOPYBITS| SWP_NOACTIVATE|SWP_NOCOPYBITS|
SWP_NOMOVE|SWP_NOSIZE| SWP_NOZORDER| SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|
SWP_FRAMECHANGED); SWP_FRAMECHANGED);
GetWindowRect (hwnd, &wr); GetWindowRect (hwnd, &wr);
@ -1217,7 +1232,7 @@ static LRESULT CALLBACK WndProc (HWND hwnd, UINT message,
SetWindowText (hwnd, SetWindowText (hwnd,
cfg.win_name_always ? window_name : icon_name); cfg.win_name_always ? window_name : icon_name);
} }
break; break;
case IDM_CLRSB: case IDM_CLRSB:
term_clrsb(); term_clrsb();
break; break;