summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/tkEvent.c14
-rw-r--r--generic/tkInt.h18
-rw-r--r--unix/tkUnixEvent.c3
-rw-r--r--unix/tkUnixKey.c17
-rw-r--r--xlib/X11/Xlib.h4
5 files changed, 21 insertions, 35 deletions
diff --git a/generic/tkEvent.c b/generic/tkEvent.c
index a2fa293..6c2ba94 100644
--- a/generic/tkEvent.c
+++ b/generic/tkEvent.c
@@ -1749,20 +1749,6 @@ CleanUpTkEvent(
XEvent *eventPtr)
{
switch (eventPtr->type) {
- case KeyPress:
- case KeyRelease: {
-
-#if !defined(_WIN32) && !defined(MAC_OSX_TK)
- TkKeyEvent *kePtr = (TkKeyEvent *) eventPtr;
- if (kePtr->charValuePtr != NULL) {
- ckfree(kePtr->charValuePtr);
- kePtr->charValuePtr = NULL;
- kePtr->charValueLen = 0;
- }
-#endif
- break;
- }
-
case VirtualEvent: {
XVirtualEvent *vePtr = (XVirtualEvent *) eventPtr;
diff --git a/generic/tkInt.h b/generic/tkInt.h
index d90cb0e..008b8c4 100644
--- a/generic/tkInt.h
+++ b/generic/tkInt.h
@@ -850,20 +850,20 @@ typedef struct TkWindow {
* but have internally generated pieces added to them.
*/
+#ifndef XMaxTransChars
+# if defined(_WIN32)
+# define XMaxTransChars 15
+# else
+# define XMaxTransChars 27
+# endif
+#endif
+
typedef struct {
XKeyEvent keyEvent; /* The real event from X11. */
-#ifdef _WIN32
char trans_chars[XMaxTransChars];
/* translated characters */
unsigned char nbytes;
-#else
- char *charValuePtr; /* A pointer to a string that holds the key's
- * %A substitution text (before backslash
- * adding), or NULL if that has not been
- * computed yet. If non-NULL, this string was
- * allocated with ckalloc(). */
- int charValueLen; /* Length of string in charValuePtr when that
- * is non-NULL. */
+#if !defined(_WIN32)
KeySym keysym; /* Key symbol computed after input methods
* have been invoked */
#endif
diff --git a/unix/tkUnixEvent.c b/unix/tkUnixEvent.c
index 4d0b9be..dacc1f3 100644
--- a/unix/tkUnixEvent.c
+++ b/unix/tkUnixEvent.c
@@ -397,8 +397,7 @@ TransferXEventsToTcl(
continue;
}
if (event.type == KeyPress || event.type == KeyRelease) {
- event.k.charValuePtr = NULL;
- event.k.charValueLen = 0;
+ event.k.nbytes = 0;
event.k.keysym = NoSymbol;
/*
diff --git a/unix/tkUnixKey.c b/unix/tkUnixKey.c
index 3e41626..7f8d8b7 100644
--- a/unix/tkUnixKey.c
+++ b/unix/tkUnixKey.c
@@ -119,10 +119,10 @@ TkpGetString(
* If we have the value cached already, use it now. [Bug 1373712]
*/
- if (kePtr->charValuePtr != NULL) {
- Tcl_DStringSetLength(dsPtr, kePtr->charValueLen);
- memcpy(Tcl_DStringValue(dsPtr), kePtr->charValuePtr,
- (unsigned) kePtr->charValueLen+1);
+ if (kePtr->nbytes > 0) {
+ Tcl_DStringSetLength(dsPtr, kePtr->nbytes);
+ memcpy(Tcl_DStringValue(dsPtr), kePtr->trans_chars,
+ (unsigned) kePtr->nbytes+1);
return Tcl_DStringValue(dsPtr);
}
@@ -228,9 +228,8 @@ TkpGetString(
*/
done:
- kePtr->charValuePtr = ckalloc(len + 1);
- kePtr->charValueLen = len;
- memcpy(kePtr->charValuePtr, Tcl_DStringValue(dsPtr), (unsigned) len + 1);
+ kePtr->nbytes = len;
+ memcpy(kePtr->trans_chars, Tcl_DStringValue(dsPtr), (unsigned) len + 1);
return Tcl_DStringValue(dsPtr);
}
@@ -336,7 +335,7 @@ TkpGetKeySym(
if (eventPtr->type == KeyPress && dispPtr
&& (dispPtr->flags & TK_DISPLAY_USE_IM)) {
- if (kePtr->charValuePtr == NULL) {
+ if (kePtr->nbytes == 0) {
Tcl_DString ds;
TkWindow *winPtr = (TkWindow *)
Tk_IdToWindow(eventPtr->xany.display, eventPtr->xany.window);
@@ -345,7 +344,7 @@ TkpGetKeySym(
(void) TkpGetString(winPtr, eventPtr, &ds);
Tcl_DStringFree(&ds);
}
- if (kePtr->charValuePtr != NULL) {
+ if (kePtr->nbytes > 0) {
return kePtr->keysym;
}
}
diff --git a/xlib/X11/Xlib.h b/xlib/X11/Xlib.h
index f3ee13d..08adfa3 100644
--- a/xlib/X11/Xlib.h
+++ b/xlib/X11/Xlib.h
@@ -530,7 +530,9 @@ typedef struct _XDisplay {
#endif
#ifndef _XEVENT_
-#define XMaxTransChars 7
+#ifdef MAC_OSX_TK
+# define XMaxTransChars 27
+#endif
/*
* Definitions of specific events.