summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorhobbs <hobbs>2006-08-30 21:53:46 (GMT)
committerhobbs <hobbs>2006-08-30 21:53:46 (GMT)
commitc205e2f533cdd989f00a0c10dcec801c3e6ad6dc (patch)
tree65a32d7bbafd725faa8019ffcd23a0ce89ccc737 /win
parent7f475d7962d8fe7ea9f615f3b14b92de1ddef483 (diff)
downloadtk-c205e2f533cdd989f00a0c10dcec801c3e6ad6dc.zip
tk-c205e2f533cdd989f00a0c10dcec801c3e6ad6dc.tar.gz
tk-c205e2f533cdd989f00a0c10dcec801c3e6ad6dc.tar.bz2
* win/tkWinKey.c: Add WM_UNICHAR window message support (used by
* win/tkWinX.c: virtual keyboard apps). [Bug 1518677] (petasis)
Diffstat (limited to 'win')
-rw-r--r--win/tkWinKey.c9
-rw-r--r--win/tkWinX.c44
2 files changed, 51 insertions, 2 deletions
diff --git a/win/tkWinKey.c b/win/tkWinKey.c
index 7f5a338..a7a973d 100644
--- a/win/tkWinKey.c
+++ b/win/tkWinKey.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinKey.c,v 1.14 2001/05/30 22:41:11 hobbs Exp $
+ * RCS: @(#) $Id: tkWinKey.c,v 1.14.4.1 2006/08/30 21:53:46 hobbs Exp $
*/
#include "tkWinInt.h"
@@ -112,6 +112,13 @@ TkpGetString(winPtr, eventPtr, dsPtr)
len = Tcl_UniCharToUtf((Tcl_UniChar) unichar, buf);
Tcl_DStringAppend(dsPtr, buf, len);
+ } else if (eventPtr->xkey.send_event == -3) {
+ /*
+ * Special case for WM_UNICHAR.
+ * xkey.trans_chars[] already contains a UTF-8 char.
+ */
+ Tcl_DStringAppend(dsPtr, eventPtr->xkey.trans_chars,
+ eventPtr->xkey.nbytes);
} else {
/*
* This is an event generated from generic code. It has no
diff --git a/win/tkWinX.c b/win/tkWinX.c
index 39339c9..28bfda3 100644
--- a/win/tkWinX.c
+++ b/win/tkWinX.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinX.c,v 1.25.2.7 2006/04/05 19:48:23 hobbs Exp $
+ * RCS: @(#) $Id: tkWinX.c,v 1.25.2.8 2006/08/30 21:53:47 hobbs Exp $
*/
#include "tkWinInt.h"
@@ -39,6 +39,15 @@
#include <imm.h>
+/*
+ * WM_UNICHAR is a message for Unicode input on all windows systems.
+ * Perhaps this definition should be moved in another file.
+ */
+#ifndef WM_UNICHAR
+#define WM_UNICHAR 0x0109
+#define UNICODE_NOCHAR 0xFFFF
+#endif
+
static TkWinProcs asciiProcs = {
0,
@@ -839,6 +848,22 @@ TkWinChildProc(hwnd, message, wParam, lParam)
result = TkWinEmbeddedEventProc(hwnd, message, wParam, lParam);
break;
+ case WM_UNICHAR:
+ if (wParam == UNICODE_NOCHAR) {
+ /* If wParam is UNICODE_NOCHAR and the application processes
+ * this message, then return TRUE. */
+ result = 1;
+ } else {
+ /* If the event was translated, we must return 0 */
+ if (Tk_TranslateWinEvent(hwnd, message, wParam, lParam,
+ &result)) {
+ result = 0;
+ } else {
+ result = 1;
+ }
+ }
+ break;
+
default:
if (!Tk_TranslateWinEvent(hwnd, message, wParam, lParam,
&result)) {
@@ -928,6 +953,7 @@ Tk_TranslateWinEvent(hwnd, message, wParam, lParam, resultPtr)
case WM_SETFOCUS:
case WM_KILLFOCUS:
case WM_DESTROYCLIPBOARD:
+ case WM_UNICHAR:
case WM_CHAR:
case WM_SYSKEYDOWN:
case WM_SYSKEYUP:
@@ -1075,6 +1101,7 @@ GenerateXEvent(hwnd, message, wParam, lParam)
*/
case WM_CHAR:
+ case WM_UNICHAR:
case WM_SYSKEYDOWN:
case WM_SYSKEYUP:
case WM_KEYDOWN:
@@ -1215,6 +1242,21 @@ GenerateXEvent(hwnd, message, wParam, lParam)
Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
event.type = KeyRelease;
break;
+
+ case WM_UNICHAR: {
+ char buffer[TCL_UTF_MAX+1];
+ int i;
+ event.type = KeyPress;
+ event.xany.send_event = -3;
+ event.xkey.keycode = wParam;
+ event.xkey.nbytes = Tcl_UniCharToUtf(wParam, buffer);
+ for (i=0; i<event.xkey.nbytes && i<TCL_UTF_MAX; ++i) {
+ event.xkey.trans_chars[i] = buffer[i];
+ }
+ Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
+ event.type = KeyRelease;
+ break;
+ }
}
break;
}