summaryrefslogtreecommitdiffstats
path: root/macosx
diff options
context:
space:
mode:
Diffstat (limited to 'macosx')
-rw-r--r--macosx/tkMacOSXFont.c2
-rw-r--r--macosx/tkMacOSXKeyEvent.c25
-rw-r--r--macosx/tkMacOSXKeyboard.c36
3 files changed, 21 insertions, 42 deletions
diff --git a/macosx/tkMacOSXFont.c b/macosx/tkMacOSXFont.c
index d93d599..3045eab 100644
--- a/macosx/tkMacOSXFont.c
+++ b/macosx/tkMacOSXFont.c
@@ -185,7 +185,7 @@ TkUtfAtIndex(
*code = (int) uniChar;
[[string substringWithRange: NSMakeRange(index, 1)]
getCString: uni
- maxLength: XMaxTransChars
+ maxLength: 7
encoding: NSUTF8StringEncoding];
return strlen(uni);
}
diff --git a/macosx/tkMacOSXKeyEvent.c b/macosx/tkMacOSXKeyEvent.c
index 55c36ce..cd369ed 100644
--- a/macosx/tkMacOSXKeyEvent.c
+++ b/macosx/tkMacOSXKeyEvent.c
@@ -247,16 +247,7 @@ static NSUInteger textInputModifiers;
}
macKC.v.keychar = keychar;
xEvent.xkey.keycode = macKC.uint;
-
- /*
- * Set the trans_chars for keychars outside of the private-use range.
- */
-
setXEventPoint(&xEvent, tkwin, w);
- if (IS_PRINTABLE(keychar)) {
- int length = TkUniCharToUtf(keychar, xEvent.xkey.trans_chars);
- xEvent.xkey.trans_chars[length] = 0;
- }
/*
* Finally we can queue the XEvent, inserting a KeyRelease before a
@@ -351,26 +342,18 @@ static NSUInteger textInputModifiers;
* represented by a sequence of two 16-bit "surrogates". We record this in
* the XEvent by setting the low order 21-bits of the keycode to the UCS-32
* value value of the character and the virtual keycode in the high order
- * byte to the special value NON_BMP. In principle we could set the
- * trans_chars string to the UTF-8 string for the non-BMP character.
- * However, that will not work when TCL_UTF_MAX is set to 3, as is the case
- * for Tcl 8.6. A workaround used internally by Tcl 8.6 is to encode each
- * surrogate as a 3-byte sequence using the UTF-8 algorithm (ignoring the
- * fact that the UTF-8 encoding specification does not allow encoding
- * UTF-16 surrogates). This gives a 6-byte encoding of the non-BMP
- * character which we write into the trans_chars field of the XEvent.
+ * byte to the special value NON_BMP.
*/
state = xEvent.xkey.state;
for (i = 0; i < len; i++) {
- unsigned int code;
UniChar keychar;
MacKeycode macKC = {0};
keychar = [str characterAtIndex:i];
macKC.v.keychar = keychar;
if (CFStringIsSurrogateHighCharacter(keychar)) {
- UniChar lowChar = [str characterAtIndex:i+1];
+ UniChar lowChar = [str characterAtIndex:++i];
macKC.v.keychar = CFStringGetLongCharacterForSurrogatePair(
(UniChar)keychar, lowChar);
macKC.v.virtual = NON_BMP_VIRTUAL;
@@ -389,10 +372,6 @@ static NSUInteger textInputModifiers;
if (xEvent.xkey.state & Mod2Mask) {
macKC.v.o_s |= INDEX_OPTION;
}
- TkUtfAtIndex(str, i, xEvent.xkey.trans_chars, &code);
- if (code > 0xFFFF){
- i++;
- }
xEvent.xkey.keycode = macKC.uint;
xEvent.xany.type = KeyPress;
Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL);
diff --git a/macosx/tkMacOSXKeyboard.c b/macosx/tkMacOSXKeyboard.c
index f4ad164..2780e5b 100644
--- a/macosx/tkMacOSXKeyboard.c
+++ b/macosx/tkMacOSXKeyboard.c
@@ -62,15 +62,13 @@
*
* When the keyboard focus is on a Tk widget which provides text input, there
* are some X11 KeyPress events which cause text to be inserted. We will call
- * these "printable" events. On macOS the text which should be inserted is
- * contained in the xkeys.trans_chars field of a key XEvent as a
- * null-terminated unicode string encoded with a special Tcl encoding. The
- * value of the trans_chars string in an Xevent depends on more than the three
- * items above. It may also depend on the sequence of keypresses that preceded
- * the one being reported by the XEvent. For example, on macOS an <Alt-e>
- * event does not cause text to be inserted but a following <a> event causes an
- * accented 'a' to be inserted. The events in such a composition sequence,
- * other than the final one, are known as "dead-key" events.
+ * these "printable" events. The UCS-32 character stored in the keycode field
+ * of an XKeyEvent depends on more than the three items above. It may also
+ * depend on the sequence of keypresses that preceded the one being reported by
+ * the XKeyEvent. For example, on macOS an <Alt-e> event does not cause text
+ * to be inserted but a following <a> event causes an accented 'a' to be
+ * inserted. The events in such a composition sequence, other than the final
+ * one, are known as "dead-key" events.
*
* MacOS packages the information described above in a different way. Every
* meaningful effect from a key action *other than changing the state of
@@ -498,11 +496,18 @@ TkpGetString(
* result. */
{
(void) winPtr; /*unused*/
- int ch;
+ MacKeycode macKC;
+ char utfChars[8];
+ int length = 0;
+
+ macKC.uint = eventPtr->xkey.keycode;
+ if (IS_PRINTABLE(macKC.v.keychar)) {
+ length = TkUniCharToUtf(macKC.v.keychar, utfChars);
+ }
+ utfChars[length] = 0;
Tcl_DStringInit(dsPtr);
- return Tcl_DStringAppend(dsPtr, eventPtr->xkey.trans_chars,
- TkUtfToUniChar(eventPtr->xkey.trans_chars, &ch));
+ return Tcl_DStringAppend(dsPtr, utfChars, length);
}
/*
@@ -684,7 +689,7 @@ XKeysymToKeycode(
* Modifies the XEvent. Sets the xkey.keycode to a keycode value formatted
* by XKeysymToKeycode and updates the shift and option flags in
* xkey.state if either of those modifiers is required to generate the
- * keysym. Also fills in xkey.trans_chars for printable events.
+ * keysym.
*
*----------------------------------------------------------------------
*/
@@ -735,11 +740,6 @@ TkpSetKeycodeAndState(
}
eventPtr->xkey.keycode = macKC.uint;
eventPtr->xkey.state |= INDEX2STATE(macKC.v.o_s);
- if (IS_PRINTABLE(macKC.v.keychar)) {
- int length = TkUniCharToUtf(macKC.v.keychar,
- eventPtr->xkey.trans_chars);
- eventPtr->xkey.trans_chars[length] = 0;
- }
}
}