From 537e7f8ae810343e6d6685e97492c5881298bd7d Mon Sep 17 00:00:00 2001
From: fvogel <fvogelnew1@free.fr>
Date: Thu, 3 May 2018 06:12:45 +0000
Subject: [PATCH 222/693] Further patch from Christian Werner, on the
 observation that on Fedora 28 Workstation on x86_64 XKeyEvents generated by
 input methods have the keycode field set to 0 which fails the range check and
 thus doesn't get processed further

---
 unix/tkUnixKey.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/unix/tkUnixKey.c b/unix/tkUnixKey.c
index d8aa5abe6..c5a024fe6 100644
--- a/unix/tkUnixKey.c
+++ b/unix/tkUnixKey.c
@@ -146,9 +146,15 @@ TkpGetString(
     XDisplayKeycodes(winPtr->dispPtr->display, &mincode, &maxcode);
     if ((eventPtr->xkey.keycode < mincode) ||
 	(eventPtr->xkey.keycode > maxcode)) {
-	len = 0;
-	Tcl_DStringSetLength(dsPtr, len);
-	goto done;
+        if (eventPtr->xkey.keycode != 0) {
+	    len = 0;
+	    Tcl_DStringSetLength(dsPtr, len);
+	    goto done;
+        }
+        /*
+         * Keycode 0 seems to come from e.g. ibus input methods,
+         * we let this pass and hope for the best.
+         */
     }
 
 #ifdef TK_USE_INPUT_METHODS
-- 
2.19.1

