summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--win/tkWinKey.c17
-rw-r--r--win/tkWinX.c15
2 files changed, 23 insertions, 9 deletions
diff --git a/win/tkWinKey.c b/win/tkWinKey.c
index 10cc7b8..d4e7223 100644
--- a/win/tkWinKey.c
+++ b/win/tkWinKey.c
@@ -339,14 +339,13 @@ KeycodeToKeysym(
* 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]
+ * neither the left nor the right shift key. This is therefore manually
+ * enforced at KeyPress/KeyRelease event generation time (in tkWinX.c).
+ * This is a bit of a hack but there is no other way that would work
+ * for both KeyPress and KeyRelease events.
+ * 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.
*/
case VK_CONTROL:
@@ -355,7 +354,7 @@ KeycodeToKeysym(
}
break;
case VK_SHIFT:
- if (GetKeyState(VK_RSHIFT) & 0x80) {
+ if (state & EXTENDED_MASK) {
return XK_Shift_R;
}
break;
diff --git a/win/tkWinX.c b/win/tkWinX.c
index 567b281..2f81ece 100644
--- a/win/tkWinX.c
+++ b/win/tkWinX.c
@@ -1323,6 +1323,21 @@ GetState(
if (HIWORD(lParam) & KF_EXTENDED) {
state |= EXTENDED_MASK;
}
+
+ /*
+ * Windows does not set the Extended flag for neither the left nor the right
+ * shift key. Since we need to distinguish later at event handling time
+ * which one was pressed, we force the Extended flag manually here so that
+ * KeycodeToKeysym() in tkWinKey.c can return the correct left or right
+ * keysym. Detection is based on the scan code contained in lParam.
+ * This is a bit of a hack but there is no other way that would work
+ * for both KeyPress and KeyRelease events.
+ */
+
+ if ((wParam == VK_SHIFT) &&
+ ((HIWORD(lParam) & 0xFF) != MapVirtualKey(VK_LSHIFT, 0))) {
+ state |= EXTENDED_MASK;
+ }
}
return state;
}