summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhobbs <hobbs>2006-08-30 21:55:51 (GMT)
committerhobbs <hobbs>2006-08-30 21:55:51 (GMT)
commit94edca83e594d771323cb9f0b5a4e1e0d03d8dc5 (patch)
treeab3b85ab817293966daf56abb9d0c1a3a41105a7
parent86610663094570936526ba513660875c9794532e (diff)
downloadtk-94edca83e594d771323cb9f0b5a4e1e0d03d8dc5.zip
tk-94edca83e594d771323cb9f0b5a4e1e0d03d8dc5.tar.gz
tk-94edca83e594d771323cb9f0b5a4e1e0d03d8dc5.tar.bz2
* win/tkWinKey.c: Add WM_UNICHAR window message support (used by
* win/tkWinX.c: virtual keyboard apps). [Bug 1518677] (petasis)
-rw-r--r--ChangeLog5
-rw-r--r--win/tkWinKey.c9
-rw-r--r--win/tkWinX.c44
3 files changed, 56 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 1c2ef7f..e64775f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-08-30 Jeff Hobbs <jeffh@ActiveState.com>
+
+ * win/tkWinKey.c: Add WM_UNICHAR window message support (used by
+ * win/tkWinX.c: virtual keyboard apps). [Bug 1518677] (petasis)
+
2006-08-24 Daniel Steffen <das@users.sourceforge.net>
* macosx/tkMacOSXScrlbr.c (UpdateControlValues): set native scrollbar
diff --git a/win/tkWinKey.c b/win/tkWinKey.c
index 22e5dd9..7df78e1 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.16 2005/12/02 13:42:29 dkf Exp $
+ * RCS: @(#) $Id: tkWinKey.c,v 1.17 2006/08/30 21:55:51 hobbs Exp $
*/
#include "tkWinInt.h"
@@ -115,6 +115,13 @@ TkpGetString(
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 nchars or
diff --git a/win/tkWinX.c b/win/tkWinX.c
index 3a38aab..5614385 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.53 2006/04/05 20:58:09 hobbs Exp $
+ * RCS: @(#) $Id: tkWinX.c,v 1.54 2006/08/30 21:55:51 hobbs Exp $
*/
/*
@@ -54,6 +54,15 @@
# pragma comment (lib, "imm32.lib")
#endif
+/*
+ * 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,
@@ -856,6 +865,21 @@ TkWinChildProc(
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)) {
result = DefWindowProc(hwnd, message, wParam, lParam);
@@ -945,6 +969,7 @@ Tk_TranslateWinEvent(
case WM_SETFOCUS:
case WM_KILLFOCUS:
case WM_DESTROYCLIPBOARD:
+ case WM_UNICHAR:
case WM_CHAR:
case WM_SYSKEYDOWN:
case WM_SYSKEYUP:
@@ -1098,6 +1123,7 @@ GenerateXEvent(
*/
case WM_CHAR:
+ case WM_UNICHAR:
case WM_SYSKEYDOWN:
case WM_SYSKEYUP:
case WM_KEYDOWN:
@@ -1230,6 +1256,22 @@ GenerateXEvent(
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;
}