Add support for Always On Top. Patch due to Janes "Ender" Brown.
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Fri, 27 Oct 2000 09:46:04 +0000 (09:46 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Fri, 27 Oct 2000 09:46:04 +0000 (09:46 +0000)
git-svn-id: svn://svn.tartarus.org/sgt/putty@773 cda61777-01e9-0310-a592-d414129be87e

putty.h
settings.c
windlg.c
window.c

diff --git a/putty.h b/putty.h
index 0a2cad6..bd867f3 100644 (file)
--- a/putty.h
+++ b/putty.h
@@ -165,6 +165,7 @@ typedef struct {
     int alt_space;                    /* is it special? */
     int alt_only;                     /* is it special? */
     int ldisc_term;
+    int alwaysontop;
     int scroll_on_key;
     int scroll_on_disp;
     int compose_key;
index 13c6580..b760239 100644 (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, "ComposeKey", cfg->compose_key);
     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, "Beep", cfg->beep);
     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, "ComposeKey", 0, &cfg->compose_key);
     gppi (sesskey, "LdiscTerm", 0, &cfg->ldisc_term);
+    gppi (sesskey, "AlwaysOnTop", 0, &cfg->alwaysontop);
     gppi (sesskey, "BlinkCur", 0, &cfg->blink_cur);
     gppi (sesskey, "Beep", 1, &cfg->beep);
     gppi (sesskey, "ScrollbackLines", 200, &cfg->savelines);
index ea62301..a912df8 100644 (file)
--- a/windlg.c
+++ b/windlg.c
@@ -258,6 +258,7 @@ enum { IDCX_ABOUT = IDC_ABOUT, IDCX_TVSTATIC, IDCX_TREEVIEW, controlstartvalue,
     IDC_ALTONLY,
     IDC_SCROLLKEY,
     IDC_SCROLLDISP,
+    IDC_ALWAYSONTOP,
     windowpanelend,
 
     appearancepanelstart,
@@ -444,6 +445,7 @@ static void init_dlg_ctrls(HWND hwnd) {
     CheckDlgButton (hwnd, IDC_ALTONLY, cfg.alt_only);
     CheckDlgButton (hwnd, IDC_COMPOSEKEY, cfg.compose_key);
     CheckDlgButton (hwnd, IDC_LDISCTERM, cfg.ldisc_term);
+    CheckDlgButton (hwnd, IDC_ALWAYSONTOP, cfg.alwaysontop);
     CheckDlgButton (hwnd, IDC_SCROLLKEY, cfg.scroll_on_key);
     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, "Use background colour to &erase screen", IDC_BCE);
            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);
 
             treeview_insert(&tvfaff, 0, "Terminal");
@@ -759,7 +761,7 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg,
             treeview_insert(&tvfaff, 1, "Keyboard");
        }
 
-        /* The Window panel. Accelerators used: [acgo] bsdkw4ylp */
+        /* The Window panel. Accelerators used: [acgo] bsdkw4ylpt */
        {
            struct ctlpos cp;
            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, "S&ystem menu appears on ALT-Space", IDC_ALTSPACE);
            checkbox(&cp, "System menu appears on A&LT alone", IDC_ALTONLY);
+            checkbox(&cp, "Ensure window is always on &top", IDC_ALWAYSONTOP);
             endbox(&cp);
 
             treeview_insert(&tvfaff, 0, "Window");
@@ -1275,6 +1278,11 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg,
                HIWORD(wParam) == BN_DOUBLECLICKED)
                cfg.ldisc_term = IsDlgButtonChecked (hwnd, IDC_LDISCTERM);
            break;
+          case IDC_ALWAYSONTOP:
+           if (HIWORD(wParam) == BN_CLICKED ||
+               HIWORD(wParam) == BN_DOUBLECLICKED)
+                cfg.alwaysontop = IsDlgButtonChecked (hwnd, IDC_ALWAYSONTOP);
+           break;
          case IDC_SCROLLKEY:
            if (HIWORD(wParam) == BN_CLICKED ||
                HIWORD(wParam) == BN_DOUBLECLICKED)
index 68e2bf2..c1ae7e4 100644 (file)
--- a/window.c
+++ b/window.c
@@ -365,14 +365,15 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) {
 
     {
        int winmode = WS_OVERLAPPEDWINDOW|WS_VSCROLL;
-       if (!cfg.scrollbar) winmode &= ~(WS_VSCROLL);
-       if (cfg.locksize)   winmode &= ~(WS_THICKFRAME|WS_MAXIMIZEBOX);
-       hwnd = CreateWindow (appname, appname,
-                            winmode,
-                            CW_USEDEFAULT, CW_USEDEFAULT,
-                            guess_width, guess_height,
-                            NULL, NULL, inst, NULL);
-    }
+        int exwinmode = 0;
+       if (!cfg.scrollbar)  winmode &= ~(WS_VSCROLL);
+       if (cfg.locksize)    winmode &= ~(WS_THICKFRAME|WS_MAXIMIZEBOX);
+        if (cfg.alwaysontop) exwinmode = WS_EX_TOPMOST;
+        hwnd = CreateWindowEx (exwinmode, appname, appname,
+                              winmode, CW_USEDEFAULT, CW_USEDEFAULT,
+                              guess_width, guess_height,
+                              NULL, NULL, inst, NULL);
+     }
 
     /*
      * Initialise the fonts, simultaneously correcting the guesses
@@ -1152,7 +1153,7 @@ static LRESULT CALLBACK WndProc (HWND hwnd, UINT message,
                    free(cl);
            }
            break;
-         case IDM_RECONF:
+          case IDM_RECONF:
            if (!do_reconfig(hwnd))
                break;
            just_reconfigged = TRUE;
@@ -1174,11 +1175,21 @@ static LRESULT CALLBACK WndProc (HWND hwnd, UINT message,
            logpal = NULL;
            pal = NULL;
            cfgtopalette();
-           init_palette();
+            init_palette();
 
            /* Enable or disable the scroll bar, etc */
            {
                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;
                if (cfg.scrollbar) nflg |=  WS_VSCROLL;
@@ -1188,15 +1199,19 @@ static LRESULT CALLBACK WndProc (HWND hwnd, UINT message,
                else              
                   nflg |= (WS_THICKFRAME|WS_MAXIMIZEBOX);
 
-               if (nflg != flag)
+                if (nflg != flag || nexflag != exflag)
                {
                    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);
                    SetWindowPos(hwnd, NULL, 0,0,0,0,
                         SWP_NOACTIVATE|SWP_NOCOPYBITS|
-                        SWP_NOMOVE|SWP_NOSIZE| SWP_NOZORDER|
+                         SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|
                         SWP_FRAMECHANGED);
 
                    GetWindowRect (hwnd, &wr);
@@ -1217,7 +1232,7 @@ static LRESULT CALLBACK WndProc (HWND hwnd, UINT message,
                SetWindowText (hwnd,
                               cfg.win_name_always ? window_name : icon_name);
            }
-           break;
+            break;
          case IDM_CLRSB:
            term_clrsb();
            break;