summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfvogel <fvogel@noemail.net>2016-08-11 12:22:13 (GMT)
committerfvogel <fvogel@noemail.net>2016-08-11 12:22:13 (GMT)
commit8bbf01839a6530fea826dda68b7d6005943e2078 (patch)
tree33f260f9153299697dddb08cae36dbba5768659e
parente8825cd5802336d02817557e1a14e3fc75765c23 (diff)
downloadtk-8bbf01839a6530fea826dda68b7d6005943e2078.zip
tk-8bbf01839a6530fea826dda68b7d6005943e2078.tar.gz
tk-8bbf01839a6530fea826dda68b7d6005943e2078.tar.bz2
Left and right Control and Alt keys are distinguished using the Extended flag (the previously implemented trick only worked for KeyPress, not for KeyRelease).
FossilOrigin-Name: 92c0425716a23eac15b0d54c389fe7e9b7dfd98e
-rw-r--r--win/tkWinKey.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/win/tkWinKey.c b/win/tkWinKey.c
index ed546f7..10cc7b8 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];