Christopher Allene's patch for going full-screen on Alt-Enter.
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Thu, 13 Sep 2001 18:24:51 +0000 (18:24 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Thu, 13 Sep 2001 18:24:51 +0000 (18:24 +0000)
git-svn-id: svn://svn.tartarus.org/sgt/putty@1267 cda61777-01e9-0310-a592-d414129be87e

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

diff --git a/putty.h b/putty.h
index 39dfc94..371945f 100644 (file)
--- a/putty.h
+++ b/putty.h
@@ -287,6 +287,7 @@ typedef struct {
     int localecho;
     int localedit;
     int alwaysontop;
+    int fullscreenonaltenter;
     int scroll_on_key;
     int scroll_on_disp;
     int compose_key;
index 16442db..07103c3 100644 (file)
@@ -198,6 +198,7 @@ void save_settings(char *section, int do_host, Config * cfg)
     write_setting_i(sesskey, "LocalEdit", cfg->localedit);
     write_setting_s(sesskey, "Answerback", cfg->answerback);
     write_setting_i(sesskey, "AlwaysOnTop", cfg->alwaysontop);
+    write_setting_i(sesskey, "FullScreenOnAltEnter", cfg->fullscreenonaltenter);
     write_setting_i(sesskey, "HideMousePtr", cfg->hide_mouseptr);
     write_setting_i(sesskey, "SunkenEdge", cfg->sunken_edge);
     write_setting_i(sesskey, "CurType", cfg->cursor_type);
@@ -374,6 +375,7 @@ void load_settings(char *section, int do_host, Config * cfg)
     gpps(sesskey, "Answerback", "PuTTY", cfg->answerback,
         sizeof(cfg->answerback));
     gppi(sesskey, "AlwaysOnTop", 0, &cfg->alwaysontop);
+    gppi(sesskey, "FullScreenOnAltEnter", 0, &cfg->fullscreenonaltenter);
     gppi(sesskey, "HideMousePtr", 0, &cfg->hide_mouseptr);
     gppi(sesskey, "SunkenEdge", 0, &cfg->sunken_edge);
     gppi(sesskey, "CurType", 0, &cfg->cursor_type);
index 7726438..785f380 100644 (file)
--- a/windlg.c
+++ b/windlg.c
@@ -365,6 +365,7 @@ enum { IDCX_ABOUT =
     IDC_SCROLLKEY,
     IDC_SCROLLDISP,
     IDC_ALWAYSONTOP,
+    IDC_FULLSCREENONALTENTER,
     windowpanelend,
 
     appearancepanelstart,
@@ -625,6 +626,7 @@ static void init_dlg_ctrls(HWND hwnd, int keepsess)
                     cfg.localedit == LD_YES ? IDC_EDITYES : IDC_EDITNO);
     SetDlgItemText(hwnd, IDC_ANSWEREDIT, cfg.answerback);
     CheckDlgButton(hwnd, IDC_ALWAYSONTOP, cfg.alwaysontop);
+    CheckDlgButton(hwnd, IDC_FULLSCREENONALTENTER, cfg.fullscreenonaltenter);
     CheckDlgButton(hwnd, IDC_SCROLLKEY, cfg.scroll_on_key);
     CheckDlgButton(hwnd, IDC_SCROLLDISP, cfg.scroll_on_disp);
 
@@ -1026,7 +1028,7 @@ static void create_controls(HWND hwnd, int dlgtype, int panel)
     }
 
     if (panel == windowpanelstart) {
-       /* The Window panel. Accelerators used: [acgo] rmz sdkp w4ylt */
+       /* The Window panel. Accelerators used: [acgo] rmz sdkp w4ylt */
        struct ctlpos cp;
        ctlposinit(&cp, hwnd, 80, 3, 13);
        bartitle(&cp, "Options controlling PuTTY's window",
@@ -1052,6 +1054,7 @@ static void create_controls(HWND hwnd, int dlgtype, int panel)
        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);
+       checkbox(&cp, "&Full screen on Alt-Enter", IDC_FULLSCREENONALTENTER);
        endbox(&cp);
     }
 
@@ -1090,14 +1093,14 @@ static void create_controls(HWND hwnd, int dlgtype, int panel)
     }
 
     if (panel == translationpanelstart) {
-       /* The Translation panel. Accelerators used: [acgo] xbep t s */
+       /* The Translation panel. Accelerators used: [acgo] rxbepu */
        struct ctlpos cp;
        ctlposinit(&cp, hwnd, 80, 3, 13);
        bartitle(&cp, "Options controlling character set translation",
                 IDC_TITLE_TRANSLATION);
        beginbox(&cp, "Character set translation on received data",
                 IDC_BOX_TRANSLATION2);
-       combobox(&cp, "Received data assumed to be in which character set:",
+       combobox(&cp, "&Received data assumed to be in which character set:",
                 IDC_CODEPAGESTATIC, IDC_CODEPAGE);
        endbox(&cp);
        beginbox(&cp, "Adjust how PuTTY displays line drawing characters",
@@ -1237,7 +1240,7 @@ static void create_controls(HWND hwnd, int dlgtype, int panel)
     }
 
     if (panel == sshpanelstart) {
-       /* The SSH panel. Accelerators used: [acgo] r pe12i sud */
+       /* The SSH panel. Accelerators used: [acgo] r pe12i s */
        struct ctlpos cp;
        ctlposinit(&cp, hwnd, 80, 3, 13);
        if (dlgtype == 0) {
@@ -1846,6 +1849,12 @@ static int GenericMainDlgProc(HWND hwnd, UINT msg,
                        cfg.alwaysontop =
                        IsDlgButtonChecked(hwnd, IDC_ALWAYSONTOP);
                break;
+             case IDC_FULLSCREENONALTENTER:
+               if (HIWORD(wParam) == BN_CLICKED ||
+                   HIWORD(wParam) == BN_DOUBLECLICKED)
+                       cfg.fullscreenonaltenter =
+                       IsDlgButtonChecked(hwnd, IDC_FULLSCREENONALTENTER);
+               break;
              case IDC_SCROLLKEY:
                if (HIWORD(wParam) == BN_CLICKED ||
                    HIWORD(wParam) == BN_DOUBLECLICKED)
index f097359..869e91f 100644 (file)
--- a/window.c
+++ b/window.c
@@ -71,13 +71,16 @@ static void init_fonts(int);
 static void another_font(int);
 static void deinit_fonts(void);
 
-static int extra_width, extra_height;
+static int full_screen = 0, extra_width, extra_height;
+static LONG old_wind_style;
+static WINDOWPLACEMENT old_wind_placement;
 
 static int pending_netevent = 0;
 static WPARAM pend_netevent_wParam = 0;
 static LPARAM pend_netevent_lParam = 0;
 static void enact_pending_netevent(void);
 static void flash_window(int mode);
+static void flip_full_screen(void);
 
 static time_t last_movement = 0;
 
@@ -2552,6 +2555,10 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
            SendMessage(hwnd, WM_SYSCOMMAND, SC_KEYMENU, 0);
            return -1;
        }
+       if (left_alt && wParam == VK_RETURN && cfg.fullscreenonaltenter) {
+           flip_full_screen();
+           return -1;
+       }
        /* Control-Numlock for app-keypad mode switch */
        if (wParam == VK_PAUSE && shift_state == 2) {
            app_keypad_keys ^= 1;
@@ -3415,3 +3422,27 @@ void beep(int mode)
        flash_window(2);               /* start */
     }
 }
+
+/*
+ * Toggle full screen mode. Thanks to cwis@nerim.fr for the
+ * implementation.
+ */
+static void flip_full_screen(void)
+{
+    if (!full_screen) {
+       int cx, cy;
+
+       cx = GetSystemMetrics(SM_CXSCREEN);
+       cy = GetSystemMetrics(SM_CYSCREEN);
+       GetWindowPlacement(hwnd, &old_wind_placement);
+       old_wind_style = GetWindowLong(hwnd, GWL_STYLE);
+       SetWindowLong(hwnd, GWL_STYLE,
+                     old_wind_style & ~(WS_CAPTION | WS_BORDER | WS_THICKFRAME));
+       SetWindowPos(hwnd, HWND_TOP, 0, 0, cx, cy, SWP_SHOWWINDOW);
+       full_screen = 1;
+    } else {
+       SetWindowLong(hwnd, GWL_STYLE, old_wind_style);
+       SetWindowPlacement(hwnd,&old_wind_placement);
+       full_screen = 0;
+    }
+}