diff options
Diffstat (limited to 'win/tkWinX.c')
-rw-r--r-- | win/tkWinX.c | 56 |
1 files changed, 45 insertions, 11 deletions
diff --git a/win/tkWinX.c b/win/tkWinX.c index 6c44059..12739ea 100644 --- a/win/tkWinX.c +++ b/win/tkWinX.c @@ -911,15 +911,24 @@ Tk_TranslateWinEvent( Tk_PointerEvent(hwnd, (short) LOWORD(lParam), (short) HIWORD(lParam)); return 1; + case WM_SYSKEYDOWN: + case WM_KEYDOWN: + if (wParam == VK_PACKET) { + /* + * This will trigger WM_CHAR event(s) with unicode data. + */ + *resultPtr = + PostMessageW(hwnd, message, HIWORD(lParam), LOWORD(lParam)); + return 1; + } + /* else fall through */ case WM_CLOSE: case WM_SETFOCUS: case WM_KILLFOCUS: case WM_DESTROYCLIPBOARD: case WM_UNICHAR: case WM_CHAR: - case WM_SYSKEYDOWN: case WM_SYSKEYUP: - case WM_KEYDOWN: case WM_KEYUP: case WM_MOUSEWHEEL: GenerateXEvent(hwnd, message, wParam, lParam); @@ -1197,17 +1206,42 @@ GenerateXEvent( event.type = KeyPress; event.xany.send_event = -1; event.xkey.keycode = 0; - event.xkey.nbytes = 1; - event.xkey.trans_chars[0] = (char) wParam; - - if (IsDBCSLeadByte((BYTE) wParam)) { - MSG msg; + if ((int)wParam & 0xff00) { + int i, ch1 = wParam & 0xffff; + char buffer[TCL_UTF_MAX+1]; - if ((PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) != 0) +#if TCL_UTF_MAX >= 4 + if ((((int)wParam & 0xfc00) == 0xd800) + && (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) != 0) && (msg.message == WM_CHAR)) { + MSG msg; + int ch2; + GetMessage(&msg, NULL, 0, 0); - event.xkey.nbytes = 2; - event.xkey.trans_chars[1] = (char) msg.wParam; + ch2 = wParam & 0xffff; + ch1 = ((ch1 & 0x3ff) << 10) | (ch2 & 0x3ff); + ch1 += 0x10000; + event.xkey.nbytes = Tcl_UniCharToUtf(ch1, buffer); + } else +#endif + event.xkey.nbytes = Tcl_UniCharToUtf(ch1, buffer); + for (i=0; i<event.xkey.nbytes && i<XMaxTransChars; ++i) { + event.xkey.trans_chars[i] = buffer[i]; + } + event.xany.send_event = -3; + } else { + event.xkey.nbytes = 1; + event.xkey.trans_chars[0] = (char) wParam; + + if (IsDBCSLeadByte((BYTE) wParam)) { + MSG msg; + + if ((PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) != 0) + && (msg.message == WM_CHAR)) { + GetMessage(&msg, NULL, 0, 0); + event.xkey.nbytes = 2; + event.xkey.trans_chars[1] = (char) msg.wParam; + } } } Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL); @@ -1221,7 +1255,7 @@ GenerateXEvent( event.xany.send_event = -3; event.xkey.keycode = wParam; event.xkey.nbytes = Tcl_UniCharToUtf((int)wParam, buffer); - for (i=0; i<event.xkey.nbytes && i<TCL_UTF_MAX; ++i) { + for (i=0; i<event.xkey.nbytes && i<XMaxTransChars; ++i) { event.xkey.trans_chars[i] = buffer[i]; } Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL); |