Miscellaneous ssh2 fixes. plink is now relatively sane
[u/mdw/putty] / window.c
index 5acddc7..685b4f3 100644 (file)
--- a/window.c
+++ b/window.c
@@ -36,6 +36,7 @@
 
 #define WM_IGNORE_SIZE (WM_XUSER + 1)
 #define WM_IGNORE_CLIP (WM_XUSER + 2)
+#define WM_IGNORE_KEYMENU (WM_XUSER + 3)
 
 static LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
 static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam, unsigned char *output);
@@ -89,6 +90,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) {
     int guess_width, guess_height;
 
     putty_inst = inst;
+    flags = FLAG_VERBOSE | FLAG_INTERACTIVE;
 
     winsock_ver = MAKEWORD(1, 1);
     if (WSAStartup(winsock_ver, &wsadata)) {
@@ -174,14 +176,16 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) {
        } else if (*p) {
            char *q = p;
             /*
-             * If the hostname starts with "telnet://", set the
+             * If the hostname starts with "telnet:", set the
              * protocol to Telnet and process the string as a
              * Telnet URL.
              */
-            if (!strncmp(q, "telnet://", 9)) {
+            if (!strncmp(q, "telnet:", 7)) {
                 char c;
 
-                q += 9;
+                q += 7;
+               if (q[0] == '/' && q[1] == '/')
+                   q += 2;
                 cfg.protocol = PROT_TELNET;
                 p = q;
                 while (*p && *p != ':' && *p != '/') p++;
@@ -520,8 +524,16 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) {
  */
 static void enact_pending_netevent(void) {
     int i;
+    static int reentering = 0;
+
+    if (reentering)
+        return;                        /* don't unpend the pending */
+
     pending_netevent = FALSE;
+
+    reentering = 1;
     i = back->msg (pend_netevent_wParam, pend_netevent_lParam);
+    reentering = 0;
 
     if (i < 0) {
        char buf[1024];
@@ -852,6 +864,7 @@ static LRESULT CALLBACK WndProc (HWND hwnd, UINT message,
     HDC hdc;
     static int ignore_size = FALSE;
     static int ignore_clip = FALSE;
+    static int ignore_keymenu = TRUE;
     static int just_reconfigged = FALSE;
 
     switch (message) {
@@ -876,6 +889,10 @@ static LRESULT CALLBACK WndProc (HWND hwnd, UINT message,
        return 0;
       case WM_SYSCOMMAND:
        switch (wParam & ~0xF) {       /* low 4 bits reserved to Windows */
+          case SC_KEYMENU:
+            if (ignore_keymenu)
+                return 0;              /* don't put up system menu on Alt */
+            break;
          case IDM_SHOWLOG:
            showeventlog(hwnd);
            break;
@@ -1105,6 +1122,9 @@ static LRESULT CALLBACK WndProc (HWND hwnd, UINT message,
       case WM_IGNORE_CLIP:
        ignore_clip = wParam;          /* don't panic on DESTROYCLIPBOARD */
        break;
+      case WM_IGNORE_KEYMENU:
+       ignore_keymenu = wParam;       /* do or don't ignore SC_KEYMENU */
+       break;
       case WM_DESTROYCLIPBOARD:
        if (!ignore_clip)
            term_deselect();
@@ -1692,19 +1712,22 @@ static WPARAM compose_key = 0;
 
        /* Lets see if it's a pattern we know all about ... */
        if (wParam == VK_PRIOR && shift_state == 1) {
-          SendMessage (hwnd, WM_VSCROLL, SB_PAGEUP, 0);
-          return 0;
+            SendMessage (hwnd, WM_VSCROLL, SB_PAGEUP, 0);
+            return 0;
        }
        if (wParam == VK_NEXT && shift_state == 1) {
-          SendMessage (hwnd, WM_VSCROLL, SB_PAGEDOWN, 0);
-          return 0;
+            SendMessage (hwnd, WM_VSCROLL, SB_PAGEDOWN, 0);
+            return 0;
        }
        if (left_alt && wParam == VK_F4 && cfg.alt_f4) {
-          return -1;
+            return -1;
        }
        if (left_alt && wParam == VK_SPACE && cfg.alt_space) {
-          SendMessage (hwnd, WM_SYSCOMMAND, SC_KEYMENU, 0);
-          return -1;
+            
+            SendMessage (hwnd, WM_IGNORE_KEYMENU, FALSE, 0);
+            SendMessage (hwnd, WM_SYSCOMMAND, SC_KEYMENU, 0);
+            SendMessage (hwnd, WM_IGNORE_KEYMENU, TRUE, 0);
+            return -1;
        }
 
        /* Nethack keypad */