diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2016-09-27 14:41:50 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2016-09-27 14:41:50 (GMT) |
commit | 73b2c28849b73d0b903780b08c2836921cacc917 (patch) | |
tree | 2abcb2e36b86027465dc94601ba1fdb1f2506cbf | |
parent | f35b0dc87b8b6a693a0e14ccd33f7462f7cc4e19 (diff) | |
download | tk-73b2c28849b73d0b903780b08c2836921cacc917.zip tk-73b2c28849b73d0b903780b08c2836921cacc917.tar.gz tk-73b2c28849b73d0b903780b08c2836921cacc917.tar.bz2 |
Internal code simplification: Store Unicode character in keycode field in stead of trans_chars. No behavior change, just use a different internal event type.
-rw-r--r-- | win/tkWinKey.c | 15 | ||||
-rw-r--r-- | win/tkWinX.c | 15 |
2 files changed, 6 insertions, 24 deletions
diff --git a/win/tkWinKey.c b/win/tkWinKey.c index a567653..89b5d29 100644 --- a/win/tkWinKey.c +++ b/win/tkWinKey.c @@ -97,21 +97,6 @@ TkpGetString( Tcl_ExternalToUtfDString(TkWinGetKeyInputEncoding(), keyEv->trans_chars, keyEv->nbytes, dsPtr); } - } else if (keyEv->send_event == -2) { - /* - * Special case for win2000 multi-lingal IME input. xkey.trans_chars[] - * already contains a UNICODE char. - */ - - int unichar; - - unichar = keyEv->trans_chars[1] & 0xff; - unichar <<= 8; - unichar |= keyEv->trans_chars[0] & 0xff; - - len = Tcl_UniCharToUtf((Tcl_UniChar) unichar, buf); - - Tcl_DStringAppend(dsPtr, buf, len); } else if (keyEv->send_event == -3) { /* diff --git a/win/tkWinX.c b/win/tkWinX.c index e13bb4f..5771a29 100644 --- a/win/tkWinX.c +++ b/win/tkWinX.c @@ -1573,18 +1573,18 @@ HandleIMEComposition( n = ImmGetCompositionString(hIMC, GCS_RESULTSTR, NULL, 0); if (n > 0) { - char *buff = ckalloc(n); + WCHAR *buff = (WCHAR *) ckalloc(n); TkWindow *winPtr; XEvent event; int i; - n = ImmGetCompositionString(hIMC, GCS_RESULTSTR, buff, (unsigned) n); + n = ImmGetCompositionString(hIMC, GCS_RESULTSTR, buff, (unsigned) n) / 2; /* * Set up the fields pertinent to key event. * - * We set send_event to the special value of -2, so that TkpGetString - * in tkWinKey.c knows that trans_chars[] already contains a UNICODE + * We set send_event to the special value of -3, so that TkpGetString + * in tkWinKey.c knows that keycode already contains a UNICODE * char and there's no need to do encoding conversion. * * Note that the event *must* be zeroed out first; Tk plays cunning @@ -1595,7 +1595,7 @@ HandleIMEComposition( memset(&event, 0, sizeof(XEvent)); event.xkey.serial = winPtr->display->request++; - event.xkey.send_event = -2; + event.xkey.send_event = -3; event.xkey.display = winPtr->display; event.xkey.window = winPtr->window; event.xkey.root = RootWindow(winPtr->display, winPtr->screenNum); @@ -1603,8 +1603,6 @@ HandleIMEComposition( event.xkey.state = TkWinGetModifierState(); event.xkey.time = TkpGetMS(); event.xkey.same_screen = True; - event.xkey.keycode = 0; - event.xkey.nbytes = 2; for (i=0; i<n; ) { /* @@ -1612,8 +1610,7 @@ HandleIMEComposition( * UNICODE character in the composition. */ - event.xkey.trans_chars[0] = (char) buff[i++]; - event.xkey.trans_chars[1] = (char) buff[i++]; + event.xkey.keycode = buff[i++]; event.type = KeyPress; Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL); |