summaryrefslogtreecommitdiffstats
path: root/macosx
diff options
context:
space:
mode:
authorculler <culler>2017-12-05 15:51:53 (GMT)
committerculler <culler>2017-12-05 15:51:53 (GMT)
commitb50aa41fd509b6e0829da869f3e3fbd4f34e1307 (patch)
tree70b2a8cebae6dbc73c981ae78728319ffddd5cdd /macosx
parent2bf5f6b8191034e185f6bd6ea8cba07146900649 (diff)
parentde0eaeebac1635a66b66ca05dca003f1dad2243a (diff)
downloadtk-b50aa41fd509b6e0829da869f3e3fbd4f34e1307.zip
tk-b50aa41fd509b6e0829da869f3e3fbd4f34e1307.tar.gz
tk-b50aa41fd509b6e0829da869f3e3fbd4f34e1307.tar.bz2
Merge core-8-6-branch into trunk. Fixes [1088805fff]. See [0feb63f139]
for explanations.
Diffstat (limited to 'macosx')
-rw-r--r--macosx/tkMacOSXKeyboard.c56
1 files changed, 45 insertions, 11 deletions
diff --git a/macosx/tkMacOSXKeyboard.c b/macosx/tkMacOSXKeyboard.c
index bbbbf96..1abbbba 100644
--- a/macosx/tkMacOSXKeyboard.c
+++ b/macosx/tkMacOSXKeyboard.c
@@ -96,6 +96,24 @@ static KeyInfo virtualkeyArray[] = {
{0, 0}
};
+#define NUM_MOD_KEYCODES 14
+static KeyCode modKeyArray[NUM_MOD_KEYCODES] = {
+ XK_Shift_L,
+ XK_Shift_R,
+ XK_Control_L,
+ XK_Control_R,
+ XK_Caps_Lock,
+ XK_Shift_Lock,
+ XK_Meta_L,
+ XK_Meta_R,
+ XK_Alt_L,
+ XK_Alt_R,
+ XK_Super_L,
+ XK_Super_R,
+ XK_Hyper_L,
+ XK_Hyper_R,
+};
+
static int initialized = 0;
static Tcl_HashTable keycodeTable; /* keyArray hashed by keycode value. */
static Tcl_HashTable vkeyTable; /* virtualkeyArray hashed by virtual
@@ -457,7 +475,6 @@ XGetModifierMapping(
* MacOSX doesn't use the key codes for the modifiers for anything, and we
* don't generate them either. So there is no modifier map.
*/
-
modmap = ckalloc(sizeof(XModifierKeymap));
modmap->max_keypermod = 0;
modmap->modifiermap = NULL;
@@ -548,7 +565,6 @@ XKeysymToMacKeycode(
KeySym keysym)
{
KeyInfo *kPtr;
-
if (keysym <= LATIN1_MAX) {
/*
* Handle keysyms in the Latin-1 range where keysym and Unicode
@@ -580,6 +596,17 @@ XKeysymToMacKeycode(
}
/*
+ * Modifier keycodes only come from generated events. No translation
+ * is needed.
+ */
+
+ for (int i=0; i < NUM_MOD_KEYCODES; i++) {
+ if (keysym == modKeyArray[i]) {
+ return keysym;
+ }
+ }
+
+ /*
* For other keysyms (not Latin-1 and not special keys), we'd need a
* generic keysym-to-unicode table. We don't have that, so we give up here.
*/
@@ -661,6 +688,13 @@ TkpSetKeycodeAndState(
{
if (keysym == NoSymbol) {
eventPtr->xkey.keycode = 0;
+ } else if ( modKeyArray[0] <= keysym &&
+ keysym <= modKeyArray[NUM_MOD_KEYCODES - 1]) {
+ /*
+ * Keysyms for pure modifiers only arise in generated events.
+ * We should just copy them to the keycode.
+ */
+ eventPtr->xkey.keycode = keysym;
} else {
Display *display = Tk_Display(tkwin);
int macKeycode = XKeysymToMacKeycode(display, keysym);
@@ -668,7 +702,6 @@ TkpSetKeycodeAndState(
/*
* See also XKeysymToKeycode.
*/
-
if ((keysym >= XK_F1) && (keysym <= XK_F35)) {
eventPtr->xkey.keycode = 0x0010;
} else {
@@ -734,7 +767,6 @@ TkpGetKeySym(
*/
if (eventPtr->xany.send_event == -1) {
-
int modifier = eventPtr->xkey.keycode & NSDeviceIndependentModifierFlagsMask;
if (modifier == NSCommandKeyMask) {
@@ -891,18 +923,20 @@ TkpInitKeymapInfo(
#endif
/*
- * MacOSX doesn't use the keycodes for the modifiers for anything, and we
- * don't generate them either (the keycodes actually given in the simulated
- * modifier events are bogus). So there is no modifier map. If we ever want
- * to simulate real modifier keycodes, the list will be constant in the
- * Carbon implementation.
+ * MacOSX doesn't create a key event when a modifier key is pressed or
+ * released. However, it is possible to generate key events for
+ * modifier keys, and this is done in the tests. So we construct an array
+ * containing the keycodes of the standard modifier keys from static data.
*/
if (dispPtr->modKeyCodes != NULL) {
ckfree(dispPtr->modKeyCodes);
}
- dispPtr->numModKeyCodes = 0;
- dispPtr->modKeyCodes = NULL;
+ dispPtr->numModKeyCodes = NUM_MOD_KEYCODES;
+ dispPtr->modKeyCodes = (KeyCode *)ckalloc(NUM_MOD_KEYCODES * sizeof(KeyCode));
+ for (int i = 0; i < NUM_MOD_KEYCODES; i++) {
+ dispPtr->modKeyCodes[i] = modKeyArray[i];
+ }
}
/*