Import Tk 8.6.8

This commit is contained in:
Cheryl Sabella
2018-02-22 14:31:15 -05:00
parent b1c28856bb
commit 8e57feeeb9
193 changed files with 6172 additions and 4033 deletions

View File

@@ -13,7 +13,7 @@
#include "tkMacOSXPrivate.h"
#include "tkMacOSXEvent.h"
#include "tkMacOSXConstants.h"
/*
* A couple of simple definitions to make code a bit more self-explaining.
*
@@ -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
@@ -579,6 +595,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];
}
}
/*