Oops, fix that fix. TranslateKey can return <0 and it needs to be
[u/mdw/putty] / window.c
index ff7ae2a..46bf64f 100644 (file)
--- a/window.c
+++ b/window.c
@@ -706,7 +706,7 @@ char *do_select(SOCKET skt, int startup)
     int msg, events;
     if (startup) {
        msg = WM_NETEVENT;
-       events = FD_READ | FD_WRITE | FD_OOB | FD_CLOSE;
+       events = FD_READ | FD_WRITE | FD_OOB | FD_CLOSE | FD_ACCEPT;
     } else {
        msg = events = 0;
     }
@@ -1863,10 +1863,19 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
                len = TranslateKey(message, wParam, lParam, buf);
                if (len == -1)
                    return DefWindowProc(hwnd, message, wParam, lParam);
-               ldisc_send(buf, len);
 
-               if (len > 0)
+               if (len != 0) {
+                   /*
+                    * We need not bother about stdin backlogs
+                    * here, because in GUI PuTTY we can't do
+                    * anything about it anyway; there's no means
+                    * of asking Windows to hold off on KEYDOWN
+                    * messages. We _have_ to buffer everything
+                    * we're sent.
+                    */
+                   ldisc_send(buf, len);
                    show_mouseptr(0);
+               }
            }
        }
        return 0;
@@ -2998,6 +3007,15 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
                            luni_send(&keybuf, 1);
                        } else {
                            ch = (char) alt_sum;
+                           /*
+                            * We need not bother about stdin
+                            * backlogs here, because in GUI PuTTY
+                            * we can't do anything about it
+                            * anyway; there's no means of asking
+                            * Windows to hold off on KEYDOWN
+                            * messages. We _have_ to buffer
+                            * everything we're sent.
+                            */
                            ldisc_send(&ch, 1);
                        }
                        alt_sum = 0;
@@ -3009,6 +3027,7 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
                    lpage_send(kbd_codepage, cbuf + !left_alt,
                               1 + !!left_alt);
                }
+               show_mouseptr(0);
            }
 
            /* This is so the ALT-Numpad and dead keys work correctly. */