[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: gedit: freeze when XIM is used to input Japanese



# warning, two patches in fact
tags 374640 + patch
reassign 374640 libx11-6
forwarded 374640 https://bugs.freedesktop.org/show_bug.cgi?id=7869
severity 374640 important
stop

On Wed, Nov 22, 2006, Osamu Aoki wrote:
> Muto san said:
> https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=201284
> https://bugs.freedesktop.org/show_bug.cgi?id=7869

 Great!

> these looks like intesresing.  He applied these patches but it goes into
> _XimRespSyncReplyのMARK_NEED_SYNC_REPLY(ic)
> and and loops for ever.

 Which patches did you apply?  Could you please try the attached patches
 which I've extracted from the Fedora SRPM?  One looks the same as the
 freedesktop one, the other one seems to flag events appropriately.

-- 
Loïc Minier <lool@dooz.org>
        10 SIN
        20 GO TO ROBOT HELL             -- Temple of Robotology
--- libX11-1.0.3/modules/im/ximcp/imDefLkup.c.bug-201284	2006-10-30 23:58:41.000000000 -0500
+++ libX11-1.0.3/modules/im/ximcp/imDefLkup.c	2006-10-30 23:58:41.000000000 -0500
@@ -216,8 +216,13 @@
     Xic		 ic,
     BITMASK16	 mode)
 {
-    if (mode & XimSYNCHRONUS) /* SYNC Request */
-	MARK_NEED_SYNC_REPLY(ic);
+    if (mode & XimSYNCHRONUS) /* SYNC Request */ {
+	if (IS_FOCUSED(ic))
+	    MARK_NEED_SYNC_REPLY(ic);
+	else
+	    _XimProcSyncReply(ic->core.im, ic);
+    }
+    
     return True;
 }
 
--- libX11-1.0.3/modules/im/ximcp/imDefIc.c.bug-201284	2006-06-22 17:22:22.000000000 -0400
+++ libX11-1.0.3/modules/im/ximcp/imDefIc.c	2006-10-30 23:58:41.000000000 -0500
@@ -949,6 +949,8 @@
     (void)_XimWrite(im, len, (XPointer)buf);
     _XimFlush(im);
 
+    MARK_FOCUSED(ic);
+
     _XimRegisterFilter(ic);
     return;
 }
@@ -994,6 +996,8 @@
     (void)_XimWrite(im, len, (XPointer)buf);
     _XimFlush(im);
 
+    UNMARK_FOCUSED(ic);
+    
     _XimUnregisterFilter(ic);
     return;
 }
--- libX11-1.0.3/src/xlibi18n/XimintP.h.bug-201284	2006-06-22 17:22:23.000000000 -0400
+++ libX11-1.0.3/src/xlibi18n/XimintP.h	2006-10-31 00:01:30.000000000 -0500
@@ -244,6 +244,7 @@
 #define IC_CONNECTED		(1L)
 #define FABLICATED		(1L << 1)
 #define	NEED_SYNC_REPLY		(1L << 2)
+#define FOCUSED			(1L << 3)
 
 /*
  * macro for the flag of XICPrivateRec
@@ -269,6 +270,13 @@
 #define	UNMARK_NEED_SYNC_REPLY(ic) \
 		(((Xic)ic)->private.proto.flag &= ~NEED_SYNC_REPLY)
 
+#define IS_FOCUSED(ic) \
+		(((Xic)ic)->private.proto.flag & FOCUSED)
+#define MARK_FOCUSED(ic) \
+		(((Xic)ic)->private.proto.flag |= FOCUSED)
+#define UNMARK_FOCUSED(ic) \
+		(((Xic)ic)->private.proto.flag &= ~FOCUSED)
+
 /*
  * macro for the filter_event_mask of XICPrivateRec
  */
--- libX11-1.0.3/modules/im/ximcp/imDefLkup.c.dont-forward-keycode-0	2006-06-22 17:22:22.000000000 -0400
+++ libX11-1.0.3/modules/im/ximcp/imDefLkup.c	2006-09-20 17:57:49.000000000 -0400
@@ -332,6 +332,17 @@
     XEvent	*ev,
     Bool	 sync)
 {
+    /*
+     * Don't forward a key event which has keycode=0.
+     * keycode=0 is reserved for special purpose to let Xmb/wcLookupString()
+     * functions know that there is a commited string available from IM.
+     */
+    if (((ev->type == KeyPress) || (ev->type == KeyRelease))) {
+        if (((XKeyEvent *)ev)->keycode == 0) {
+            return True;
+        }
+    }
+
 #ifdef EXT_FORWARD
     if (((ev->type == KeyPress) || (ev->type == KeyRelease)))
 	if (_XimExtForwardKeyEvent(ic, (XKeyEvent *)ev, sync))
@@ -605,6 +616,19 @@
 	Xfree(info->keysym);
     ic->private.proto.commit_info = info->next;
     Xfree(info);
+
+    /*
+     * "Commit" uses fabricated flag to process a commited string
+     * from IM engine.  
+     * Turn off the fabricated flag here (unregister the commited
+     * information function). Otherwise, next regular key press
+     * event will be ignored at _XimProtoKeypressFilter() and it
+     * will not be passed to IM engine.
+     */
+    if (IS_FABLICATED(ic)) {
+        UNMARK_FABLICATED(ic);
+    }
+
     return;
 }
 
--- libX11-1.0.3/modules/im/ximcp/imDefFlt.c.dont-forward-keycode-0	2006-06-22 17:22:22.000000000 -0400
+++ libX11-1.0.3/modules/im/ximcp/imDefFlt.c	2006-09-20 17:57:49.000000000 -0400
@@ -147,7 +147,7 @@
     Xim		im = (Xim)ic->core.im;
 #endif
 
-    if (IS_FABLICATED(ic)) {
+    if ((ev->keycode == 0) || IS_FABLICATED(ic)) {
 	_XimPendingFilter(ic);
 	UNMARK_FABLICATED(ic);
 	return NOTFILTERD;

Reply to: