XIM protocol mismatch between scim and xorg

Eirik Byrkjeflot Anonsen eirik at opera.com
Mon Aug 7 02:47:00 PDT 2006

I have a problem where scim starts eating all key events from an
application so no key events ever reach the application itself.

The problem seems to be that X and scim does not interpret the XIM
protocol the same way when it comes to SYNC handling.

As far as I can tell, what happens is that scim sends an event to X
with the synchronous flag.  X receives the event and marks the input
context with MARK_NEED_SYNC_REPLY.  X will now send a SYNC_REPLY the
next time it tries to handle an event on that input context.  However,
the application has managed to switch input contexts in the meantime,
so X never looks at that input context again, and thus sends no
SYNC_REPLY.  This causes scim to queue up all incoming events from the
client (regardless of input context) while it is waiting for the
SYNC_REPLY that never comes.

I'm not sure if the bug is in scim, X or in the XIM protocol
specification.  I didn't read the XIM protocol specification carefully
enough to be able to tell.

The application in question is the opera web browser, though I have
managed to reproduce the problem with khexedit and firefox as well.
It is not trivial to reproduce the problem on any given system.  But
on some systems it is highly reproducible.  The bug is probably timing
sensitive, so adding carefully chosen delays at strategic points in
scim and/or X will probably make it much easier to reproduce.

The typical way (for me, anyway) to reproduce it is to start opera,
using scim with scim-pinyin and through xim.  Press Ctrl-t to open a
new tab.  Focus is automatically set to the url address field.  Type a
couple of characters.  This brings up the "auto-completion box", a
white popup window containing lines of suggested urls.  Hit ctrl-t
again to open another tab.  Now it's no longer possible to type
anything anywhere.

This has been reproduced on a standard install of fedora core 5, and
it has been reproduced by running scim and opera on a suse 10 with
remote X server on a debian testing.  We have failed to reproduce it
locally on suse 10.

I managed to reproduce with firefox after having added quite a few
debug printfs to scim.  The reproduction pattern is somewhat simpler,
but less reproducible: Start firefox, hit ctrl-n to create a new
window.  Make sure that the new window shows up under the mouse (and
use focus follows mouse).  At this point, the new window does not
accept input.

Note that it is not necessary to actually activate the chinese input
mode.  It is sufficient that scim is examining the key events before
sending them back to the application.


More information about the xorg mailing list