Tk Source Code

Artifact [802ff44d4b]
Login

Artifact 802ff44d4b4c62119fb8a59fb7b7e13229a05868:

Attachment "tk84-xim-fixes.patch" to ticket [905830ffff] added by jenglish 2005-12-16 03:24:30.
Date: Thu Dec 15 12:21:20 -0800 2005
Files: unix/tkUnixEvent.c generic/tkEvent.c
Bugid: 905830

--- unix/tkUnixEvent.c.xim-fixes.old	2005-12-15 10:28:52.290498688 -0800
+++ unix/tkUnixEvent.c	2005-12-15 12:14:21.276654334 -0800
@@ -343,19 +343,22 @@
 TransferXEventsToTcl(display)
     Display *display;
 {
-    int numFound;
     XEvent event;
 
-    numFound = QLength(display);
-
     /*
-     * Transfer events from the X event queue to the Tk event queue.
+     * Transfer events from the X event queue to the Tk event queue
+     * after XIM event filtering.  KeyPress and KeyRelease events
+     * are filtered in Tk_HandleEvent instead of here, so that Tk's
+     * focus management code can redirect them.
      */
-
-    while (numFound > 0) {
+    while (QLength(display) > 0) {
 	XNextEvent(display, &event);
+	if (event.type != KeyPress && event.type != KeyRelease) {
+	    if (XFilterEvent(&event, None)) {
+		continue;
+	    }
+	}
 	Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
-	numFound--;
     }
 }
 
@@ -650,31 +653,10 @@
 {
     unsigned short i;
     XIMStyles *stylePtr;
-    char *modifiers;
 
-    modifiers = XSetLocaleModifiers("");
-    if (modifiers == NULL) {
+    if (XSetLocaleModifiers("") == NULL) {
 	goto error;
     }
-#if 1
-    /* 
-     * This is a temporary hack that can be taken back out again
-     * once Tk has learned how to deal with SCIM
-     */
-    while ((modifiers = strchr(modifiers, '@')) != NULL) {
-	if (strncmp(modifiers, "@im=", 4) == 0) {
-	    /* The first "@im=" entry wins */
-	    const char *scim = "@im=SCIM";
-	    if (strncmp(modifiers, scim, strlen(scim)) == 0) {
-		/* If it is SCIM, we override it */
-		if (XSetLocaleModifiers("@im=local") == NULL) {
-		    goto error;
-		}
-	    }
-	    break;
-	}
-    }
-#endif
 
     dispPtr->inputMethod = XOpenIM(dispPtr->display, NULL, NULL, NULL);
     if (dispPtr->inputMethod == NULL) {
--- generic/tkEvent.c.xim-fixes.old	2005-11-30 13:13:12.000000000 -0800
+++ generic/tkEvent.c	2005-12-15 11:59:08.099432576 -0800
@@ -948,8 +948,10 @@
 		XSetICFocus(winPtr->inputContext);
 	    }
 	}
-	if (XFilterEvent(eventPtr, None)) {
-	    goto done;
+	if (eventPtr->type == KeyPress || eventPtr->type == KeyRelease) {
+	    if (XFilterEvent(eventPtr, None)) {
+		goto done;
+	    }
 	}
     }
 #endif /* TK_USE_INPUT_METHODS */