Fix for spurious Space getting sent when alt_space and alt_only are
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Sun, 7 Jan 2001 19:15:59 +0000 (19:15 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Sun, 7 Jan 2001 19:15:59 +0000 (19:15 +0000)
both set and you bring up the Sysmenu with an alt_space and dispatch
it with an alt_only. (The SYSKEYDOWN for alt_only is never received,
but we get the SYSKEYUP which PostMessages the space since it
expects to be triggering the _creation_ of a sysmenu. Solution: set
alt_state to 0 when an alt_space triggers a sysmenu, so that the
final SYSKEYUP will be seen as spurious, which it is. Perhaps we
could do this better.)

git-svn-id: svn://svn.tartarus.org/sgt/putty@848 cda61777-01e9-0310-a592-d414129be87e

window.c

index b2bd490..99b374d 100644 (file)
--- a/window.c
+++ b/window.c
@@ -1889,6 +1889,7 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
     int  scan, left_alt = 0, key_down, shift_state;
     int  r, i, code;
     unsigned char * p = output;
+    static int alt_state = 0;
 
     HKL kbd_layout = GetKeyboardLayout(0);
 
@@ -2085,6 +2086,7 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
             return -1;
        }
        if (left_alt && wParam == VK_SPACE && cfg.alt_space) {
+           alt_state = 0;
             PostMessage(hwnd, WM_CHAR, ' ', 0);
             SendMessage (hwnd, WM_SYSCOMMAND, SC_KEYMENU, 0);
             return -1;
@@ -2361,7 +2363,6 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
     /* ALT alone may or may not want to bring up the System menu */
     if (wParam == VK_MENU) {
         if (cfg.alt_only) {
-            static int alt_state = 0;
             if (message == WM_SYSKEYDOWN)
                 alt_state = 1;
             else if (message == WM_SYSKEYUP && alt_state)