We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 429 - XIM support doesn't work on Linux
Summary: XIM support doesn't work on Linux
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: events (show other bugs)
Version: 1.2.11
Hardware: x86 Linux
: P1 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks: 450
  Show dependency treegraph
 
Reported: 2007-05-26 08:02 UTC by Alissa_Sabre
Modified: 2007-07-12 08:57 UTC (History)
2 users (show)

See Also:


Attachments
Analysis of issues and a proposed patch (10.43 KB, application/octet-stream)
2007-05-26 08:10 UTC, Alissa_Sabre
Details
A short sample program to disclose the XIM bug. (1006 bytes, text/plain)
2007-06-01 22:07 UTC, Alissa_Sabre
Details
A patch against branches/SDL-1.2@3114 of SVN (450 bytes, patch)
2007-06-28 09:25 UTC, Alissa_Sabre
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alissa_Sabre 2007-05-26 08:02:32 UTC
This bug report is against SDL 1.2.11, although there is no choice for the version... :-(

Recent SDL for X11 has XIM support built in.  However, it has some problems and does not work with some IM.  In particular, it doesn't work when combined with SCIM-anthy, that is one of the most popular Japanese IMs these days.

The direct cause here is that SCIM-anthy requires KeyRelease X events to be passed to XFilfterEvent() while SDL 1.2.11 doesn't.  There are more problems that affects various IMs.

I wrote some analysis of the issues and a patch to fix them.  It is available on http://alissa-sabre.cocolog-nifty.com/files/SDL-IM-20070525.zip  Hope this helps.
Comment 1 Alissa_Sabre 2007-05-26 08:10:33 UTC
Created attachment 205 [details]
Analysis of issues and a proposed patch

This is the content of the http://alissa-sabre.cocolog-nifty.com/files/SDL-IM-20070525.zip
Comment 2 Alissa_Sabre 2007-06-01 22:07:28 UTC
Created attachment 206 [details]
A short sample program to disclose the XIM bug.

This is a short sample program to disclose the XIM bug.  Repro steps follow.  I'm assuming SCIM-Anthy as a sample Input Method, although other famous programs such as kinput2 or UIM can be used to expose the issue.

PREPARATION

- Compile this program as an ordinary SDL application.
- Make sure your Linux system has SCIM and Anthy properly installed and setup.
- Start SCIM if not yet.
- Set two key environment variables to use XIM properly.  In this case I used:
    LANG=en_us.UTF-8
    XMODIFIERS=@im=SCIM
- Start the compiled sample program from xterm with unpatched libSDL.1.2.so.0
- A small SDL window should pops up.  Give the winodw the keyboard focus.
- Hit the 'a' key on you keyboard.  The sample program should show "0061" which is a hexadecimal Unicode value for 'a'.  This is fine.
- Then, hit the SCIM hot key.  It depends on the configuration, but Ctrl-Alt-Space, in my case.

OBSERVED BEHAVIOUR

- The sample program echos three "0000"s; one for pressing Ctrl key, one for Alt, and one for Space.
- SCIM status windows does not appear at this moment.
- Typing 'a' key makes the sample program to echo "0061".

EXPECTED BEHAVIOUR

- When you hit the SCIM hot key, the following should happen:
  * "0000" is echoed for Ctrl key.
  * "0000" is echoed for Alt key.
  * Nothing is echoed from the sample program when you hit Space (while holding Ctrl and Alt.)  Instead, the SCIM status window should pop up (on the lower right corner of the screen in my case) at this timing.
- Type 'a' key.  A _root_preedit_window_ (aka bottom line input area) appears and a hiragana letter A is shown there.
- Type Enter key.  The root preedit window disappears and the sample programs echoes "3042" that is the Unicode value for hiragana A.

If you run the sample program with libSDL.1.2.so.0 built with my patch applied, what is described under EXPECTED BEHAVIOUR occurs.

If you use other Input methods, details of the observed and expected behaviour may vary, but the point is, without my patch, you can't use XIM based input methods that require preedits.
Comment 3 Ryan C. Gordon 2007-06-02 13:59:03 UTC
Bumping a bunch of bugs to Priority 1 for consideration for the 1.2.12 release.

--ryan.

Comment 4 Ryan C. Gordon 2007-06-25 13:02:41 UTC
I committed this to the 1.2 branch in svn revision #3102. If it works out, we'll keep it in for the 1.2.12 release and merge it to 1.3 thereafter. Please try the latest in Subversion and make sure it still works, since I had to tweak it a little to get it to apply to the latest in revision control.

Thanks,
--ryan.
Comment 5 Ryan C. Gordon 2007-06-25 17:36:06 UTC
(Sorry, the correct patch level is svn revision #3103.)

--ryan.
Comment 6 Alissa_Sabre 2007-06-28 07:10:07 UTC
I grabbed and tried r3103 and r3114 (HEAD as of June 25) from svn (branches/SDL-1.2).  XIM support didn't work on both revisions...

I'm working on it and report back here.
Comment 7 Alissa_Sabre 2007-06-28 09:21:36 UTC
I found a problem.

For whatever reason, SDL_x11video.c contains a redundant call to XOpenIM().
Although not clearly documented, a process can't make multiple calls to
XOpenIM with a same Display, without closing previous XIM.  The redundant
call filled SDL_IM a NULL.

(The first call is on line 487.)

Just removing this redundant call fixes the problem.

I'm attaching a patch.
Comment 8 Alissa_Sabre 2007-06-28 09:25:46 UTC
Created attachment 216 [details]
A patch against branches/SDL-1.2@3114 of SVN

This is a patch to fix some small (but serious) problem introduced in merging my original patch into SVN.  It is against revisioin 3114 of SDL-1.2 branch
Comment 9 Ryan C. Gordon 2007-06-28 12:30:24 UTC
(In reply to comment #8)
> This is a patch to fix some small (but serious) problem introduced in merging
> my original patch into SVN.  It is against revisioin 3114 of SDL-1.2 branch

Cool, thanks!

This patch is now in Subversion, svn revision #3115.

Resolving bug...

--ryan.