[PATCH libX11 1/2] XIM: Fix race on focus change: set 'FABRICATED' only when keyev filters in place.

Egbert Eich eich at freedesktop.org
Fri Dec 7 02:57:51 PST 2012


When synthesized key events are sent on commit XIM sets the 'fabricated'
flag so that the keypress handler knows that these were not real events.
This also happens when committing due to the loss of focus. However in this
case the keypress/release filters which consume and unset this flag are no
longer in the filter chain.
So the flag is erronously set when a real keyboard event is received after
focus has been regained. So the first event is wrongly treated as a
'fablicated' key in the keypress handler which will at the same time reset
the flag so the second key event is treated correctly.
This fix only sets the flag when at least one of the keyboard filters is in
place.
How to reproduce this bug: run scim, choose a Japanese input method start
two instances of xterm: start typing in one xterm (this should pop up an
IM window). Without comitting (hitting 'enter') move focus to the other
xterm, then move focus back. Start typing again. The first character will
be committed immediately without popping up an input window.
With this fix this behavior is gone.

See also: https://bugzilla.novell.com/show_bug.cgi?id=239698

Signed-off-by: Egbert Eich <eich at freedesktop.org>
---
 modules/im/ximcp/imDefLkup.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/modules/im/ximcp/imDefLkup.c b/modules/im/ximcp/imDefLkup.c
index 0a9553a..b5cbfb5 100644
--- a/modules/im/ximcp/imDefLkup.c
+++ b/modules/im/ximcp/imDefLkup.c
@@ -704,7 +704,9 @@ _XimCommitRecv(
 
     (void)_XimRespSyncReply(ic, flag);
 
-    MARK_FABRICATED(im);
+    if (ic->private.proto.registed_filter_event
+	& (KEYPRESS_MASK | KEYRELEASE_MASK))
+	    MARK_FABRICATED(im);
 
     ev.type = KeyPress;
     ev.send_event = False;
-- 
1.7.7



More information about the xorg-devel mailing list