diff options
author | fvogelnew1@free.fr <fvogel> | 2016-09-04 18:46:04 (GMT) |
---|---|---|
committer | fvogelnew1@free.fr <fvogel> | 2016-09-04 18:46:04 (GMT) |
commit | f59fffcd39b3170ed337bd1292225651b7d1f091 (patch) | |
tree | f73c87e7641058fc3c32dbf57ff6082f7370a9c1 /win | |
parent | c5b044ba4528b42561af3ecd815ec57f4d1b02a8 (diff) | |
parent | 1140ce0115d05174355c1a26922ca35149341ba4 (diff) | |
download | tk-f59fffcd39b3170ed337bd1292225651b7d1f091.zip tk-f59fffcd39b3170ed337bd1292225651b7d1f091.tar.gz tk-f59fffcd39b3170ed337bd1292225651b7d1f091.tar.bz2 |
Fixed [2945130fff] for the right Control and Alt keys. WONTFIX the case of the right Shift key due to Windows plaftorm limitation.
Diffstat (limited to 'win')
-rw-r--r-- | win/tkWinKey.c | 30 | ||||
-rw-r--r-- | win/tkWinX.c | 6 |
2 files changed, 19 insertions, 17 deletions
diff --git a/win/tkWinKey.c b/win/tkWinKey.c index 5591133..3d2a16a 100644 --- a/win/tkWinKey.c +++ b/win/tkWinKey.c @@ -335,18 +335,24 @@ KeycodeToKeysym( /* * Windows only gives us an undifferentiated VK_CONTROL code (for * example) when either Control key is pressed. To distinguish between - * left and right, we have to query the state of one of the two to - * determine which was actually pressed. So if the keycode indicates - * Control, Shift, or Menu (the key that everybody else calls Alt), do - * this extra test. If the right-side key was pressed, return the - * appropriate keycode. Otherwise, we fall through and rely on the - * keymap table to hold the correct keysym value. + * left and right, we use the Extended flag. Indeed, the right Control + * and Alt (aka Menu) keys are such extended keys (which their left + * counterparts are not). + * Regarding the shift case, Windows does not set the Extended flag for + * the neither the left nor the right shift key. As a consequence another + * way to distinguish between the two keys is to query the state of one + * of the two to determine which was actually pressed. So if the keycode + * indicates Shift, do this extra test. If the right-side key was + * pressed, return the appropriate keycode. Otherwise, we fall through + * and rely on the keymap table to hold the correct keysym value. + * Note: this little trick only works for KeyPress, not for KeyRelease, + * for reasons stated in bug [2945130] */ case VK_CONTROL: - if (GetKeyState(VK_RCONTROL) & 0x80) { - return XK_Control_R; - } + if (state & EXTENDED_MASK) { + return XK_Control_R; + } break; case VK_SHIFT: if (GetKeyState(VK_RSHIFT) & 0x80) { @@ -354,9 +360,9 @@ KeycodeToKeysym( } break; case VK_MENU: - if (GetKeyState(VK_RMENU) & 0x80) { - return XK_Alt_R; - } + if (state & EXTENDED_MASK) { + return XK_Alt_R; + } break; } return keymap[keycode]; diff --git a/win/tkWinX.c b/win/tkWinX.c index 99102cb..2dbc098 100644 --- a/win/tkWinX.c +++ b/win/tkWinX.c @@ -1321,11 +1321,7 @@ GetState( state &= ~mask; } if (HIWORD(lParam) & KF_EXTENDED) { - if (message == WM_SYSKEYDOWN || message == WM_KEYDOWN) { - state |= EXTENDED_MASK; - } else { - state &= ~EXTENDED_MASK; - } + state |= EXTENDED_MASK; } } return state; |