diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2016-08-30 07:33:06 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2016-08-30 07:33:06 (GMT) |
commit | 8e0cfedf783c540c0e00370d38795596836c17a4 (patch) | |
tree | 26e4f0ebdba0ae5bdc9af687cab666f7be8bdd7c /win | |
parent | 8a165192c2d08763b9540f35e9f2cb4f521b5f5f (diff) | |
parent | 11b7e411734b876ba7f7241f93b4123a29c96ff9 (diff) | |
download | tk-8e0cfedf783c540c0e00370d38795596836c17a4.zip tk-8e0cfedf783c540c0e00370d38795596836c17a4.tar.gz tk-8e0cfedf783c540c0e00370d38795596836c17a4.tar.bz2 |
merge core-8-6-branch.
Add patch from Christian Werner, and one step closer to working with TCL_UTF_MAX=3
Diffstat (limited to 'win')
-rw-r--r-- | win/tkWinX.c | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/win/tkWinX.c b/win/tkWinX.c index 12739ea..2180f52 100644 --- a/win/tkWinX.c +++ b/win/tkWinX.c @@ -81,6 +81,7 @@ typedef struct ThreadSpecificData { TkDisplay *winDisplay; /* TkDisplay structure that represents Windows * screen. */ int updatingClipboard; /* If 1, we are updating the clipboard. */ + int surrogateBuffer; /* Buffer for first of surrogate pair. */ } ThreadSpecificData; static Tcl_ThreadDataKey dataKey; @@ -1208,23 +1209,19 @@ GenerateXEvent( event.xkey.keycode = 0; if ((int)wParam & 0xff00) { int i, ch1 = wParam & 0xffff; - char buffer[TCL_UTF_MAX+1]; + char buffer[XMaxTransChars]; -#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); - 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); + if ((ch1 & 0xfc00) == 0xd800) { + tsdPtr->surrogateBuffer = ch1; + return; + } + if ((ch1 & 0xfc00) == 0xdc00) { + ch1 = ((tsdPtr->surrogateBuffer & 0x3ff) << 10) | + (ch1 & 0x3ff); + ch1 += 0x10000; + tsdPtr->surrogateBuffer = 0; + } + event.xkey.nbytes = Tcl_UniCharToUtf(ch1, buffer); for (i=0; i<event.xkey.nbytes && i<XMaxTransChars; ++i) { event.xkey.trans_chars[i] = buffer[i]; } @@ -1249,7 +1246,7 @@ GenerateXEvent( break; case WM_UNICHAR: { - char buffer[TCL_UTF_MAX+1]; + char buffer[XMaxTransChars]; int i; event.type = KeyPress; event.xany.send_event = -3; |