Bug 77424 - tcl/tk 8.4.11 doesn't support XIM very well.
Summary: tcl/tk 8.4.11 doesn't support XIM very well.
Status: RESOLVED FIXED
: 104557 (view as bug list)
Alias: None
Product: SUSE LINUX 10.0
Classification: openSUSE
Component: X11 Applications (show other bugs)
Version: Beta 3
Hardware: All All
: P5 - None : Normal
Target Milestone: ---
Assignee: Reinhard Max
QA Contact: E-mail List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-04-13 07:57 UTC by Zhe Su
Modified: 2006-01-04 14:15 UTC (History)
2 users (show)

See Also:
Found By: Other
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
First attempt of a patch to make Tk work with SCIM (27.51 KB, patch)
2005-09-02 21:01 UTC, Reinhard Max
Details | Diff
A patch against tk cvs head to fix the SCIM XIM issue. (2.54 KB, patch)
2006-01-04 09:03 UTC, Zhe Su
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Zhe Su 2005-04-13 07:57:18 UTC
I found that tcl/tk application couldn't receive keyboard input at all if SCIM
XIM server is running. I debugged SCIM and found that tcl/tk did not send any
key event to SCIM at all.

Nothing could be inputted into tcl/tk app, if locale is zh_CN.UTF-8. With locale
zh_CN, only English could be accepted by app.

I tried kinput2 with ja_JP locale, tcl/tk works without problem. I also tried
another Chinese XIM input method, fcitx, it did not work as well, just like SCIM.

Searching on internet, I found a patch to improve the XIM and i18n support for
tcl/tk 8.3.1, but unfortunately there is no similar patch for 8.4.9. And 8.4.9
doesn't include such improvement. 

You can get the patch from:
ftp://ftp.sra.co.jp/pub/lang/tcl/jp/tcltk8.3.1i18n.patch.tar.gz

The testing program is idle (python IDE).
Comment 1 Reinhard Max 2005-04-13 14:40:41 UTC
Yes, it is known, that XIM support in Tk is far from being perfect, but
unfortunately the Tcl community is lacking people with good skills in XIM
programming and personal need to have it working.

Would you be able to help me updating that patch to work with Tcl/Tk 8.4 and 8.5?
Comment 2 Zhe Su 2005-04-13 15:14:47 UTC
I can try to port this patch. But I don't know if I have time to do it. Anyway,
I'll try to finish it before the next SL release.
Comment 3 Reinhard Max 2005-04-13 15:20:05 UTC
Maybe we can work together on this. I know Tcl and Tk internals fairly well, and
have contacts to the Tcl community, in case questions arise.
Comment 4 Zhe Su 2005-04-14 08:23:03 UTC
Ok. I'll ask for your help if I encounter any issue. 
Comment 5 Reinhard Max 2005-04-14 08:56:16 UTC
I've chatted with the Tcl/Tk release manager last night, and told him about this
patch. He said he thinks it has already been merged into the official Tcl/Tk
releases before 8.4.
Comment 6 Zhe Su 2005-04-14 10:31:09 UTC
Hi, I checked the source code of tcl/tk 8.4.9 but could not find any improved
code similar with the patch.
Comment 7 Reinhard Max 2005-04-14 11:47:16 UTC
Hmm - maybe only parts of it have been integrated, or even reimplemented.
At least there has been improvement in XIM support between 8.3.1 and 8.4.x .
Comment 8 Mike Fabian 2005-04-14 13:38:20 UTC
max> At least there has been improvement in XIM support between 8.3.1
max> and 8.4.x .

kinput2 works with over the spot mode now. In some older
version sof Tcl/Tk it worked only with root mode.

But that seems to be the only improvement, even with
kinput2 the input is difficult because the preedit strings
are unreadably small.

And I can confirm that it doesn't work at all with scim.

scim is our default and most important input method now, therefore
this is really quite bad.

I keep kinput2 only for historical reasons because some users
are very used to the behaviour of kinput2. But scim is much
better and much more important.
Comment 9 Mike Fabian 2005-04-14 14:55:19 UTC
It seems that an easy way for Reinhard Max to reproduce
that SCIM doesn't work is to try using the Compose support
built into SCIM with Tcl/Tk, this doesn't work either:

    scim -d
    export XMODIFIERS=@im=SCIM

then start some tk application and try to use compose.
Comment 10 Reinhard Max 2005-08-15 08:31:52 UTC
*** Bug 104557 has been marked as a duplicate of this bug. ***
Comment 11 Tobias Burnus 2005-08-30 15:26:46 UTC
Is there the plan to create a script
"/usr/bin/wish" which contains:
------------
#!/bin/sh
XMODIFIERS=xim
exec /usr/bin/wish8.4 "$@"
------------
as a work around for 10.0?
Comment 12 Reinhard Max 2005-08-30 16:09:54 UTC
Yes, but I'll patch it into Tk itself instead of creating a wrapper script, and
I'll only overwrite XMODIFIERS when it's value is "@im=SCIM" .
Comment 13 Mike Fabian 2005-08-30 16:14:06 UTC
Tobias Burnus> XMODIFIERS=xim

This is not a valid setting for XMODIFIERS.

Valid settings look like XMODIFIERS="@im=<name-of-xim-server>".

for example:

    XMODIFIERS=@im=local    (means use Compose)
    XMODIFIERS=@im=SCIM     (means use SCIM)
    XMODIFIERS=@im=kinput2  (means use kinput2)
    ...




Comment 14 Mike Fabian 2005-08-30 16:17:06 UTC
Reinhard> Yes, but I'll patch it into Tk itself instead of creating a wrapper
Reinhard> script, and I'll only overwrite XMODIFIERS when it's value is
Reinhard> "@im=SCIM" .

In the long run it should be fixed properly though.  With this hack,
SCIM cannot be used with Tk. Of course this hack is better than not
being able to input anything, not even ASCII.

But it is a pity that our default input method cannot be used with Tk.

Tk is the only program I know of which works with "old" input methods
like "kinput2" but not with scim. And even when using kinput2 it is
far from perfect.


Comment 15 Reinhard Max 2005-08-30 16:17:10 UTC
What if I just unset it, if I find it to be "@im=SCIM" when Tk starts up?
Comment 16 Mike Fabian 2005-08-30 16:23:43 UTC
Better set it to "@im=local". When XMODIFIERS is unset, it can still
mean that a XIM server is used under some circumstances.

For example: If running in en_US.UTF-8 locale and a file like
/usr/X11R6/lib/X11/locale/en_US.UTF-8/Compose does *not* exist (it
exists on SuSE Linux), *and* exactly one XIM server is running (for
example only kinput2 or only SCIM are running), than that XIM server
will be used.

This is a weird, rare case which probably cannot happen in practice
because most subdirectories in /usr/X11R6/lib/X11/locale/ have a
"Compose" file.  But it is probably better to set "@im=local" instead
of unsetting it.

Comment 17 Reinhard Max 2005-08-30 16:27:37 UTC
Of course should it be fixed properly, but I doubt the Tk community will do so
any time soon, because (a) nobody there knows how to do it, and (b) nobody there
has a pressing need to get it fixed. Most Tk hackers don't need XIM at all and
those who do don't use SCIM.
Comment 18 Reinhard Max 2005-08-30 16:31:30 UTC
BTW, I recently tried the patch mentioned in comment #1 on the 8.3.1 sources,
and it worked with SCIM.
Comment 19 Mike Fabian 2005-08-30 17:09:10 UTC
Does it look difficult to port that patch to 8.4.9?
Comment 20 Reinhard Max 2005-08-30 17:16:00 UTC
I've just started an attempt to port it, and it looks more promising than I had
expected, given the set of changes that went into that area of Tk between 8.3.1
and 8.4.11. I'll continue tomorrow...
Comment 21 Reinhard Max 2005-09-02 17:56:00 UTC
I've just submitted a first version of the forward-ported patch for inclusion in
10.0 . It still has a little focus problem, which I will look into on Monday.

After the next ftp sync test packages for the 10.0 betas will be available under
ftp://ftp.suse.com/pub/projects/tcl/tk8.4.11 .

Tobias, and Zhe, could you please test it over the weekend, so that we can
decide if it is good enough for putting it into 10.0 so late in the development
cycle?

Thanks.
Comment 22 Reinhard Max 2005-09-02 21:01:12 UTC
Created attachment 48662 [details]
First attempt of a patch to make Tk work with SCIM

Adding the patch to this bug report so that others from the Tcl community can
test it without having to download my RPMs.
Comment 23 Mike Fabian 2005-09-06 13:12:18 UTC
Add Liu Cougar <liucougar@gmail.com> to CC:. 
 
Comment 24 Reinhard Max 2005-09-06 15:09:00 UTC
For 10.0, I took out the patch from comment #22, because it had some focus
problems: entering composed characters, and using an IM server was only possible
when the mouse pointer was over the widget that has the keyboard focus.

Instead I added a workaround that calls XSetLocaleModifiers("@im=local") if it
finds SCIM to be used. Overwriting the XMODIFIERS environment variable as
discussed above was rejected, because it would also have switched off SCIM for
(possibly non-Tk) child processes of a Tk application.
Comment 25 Zhe Su 2006-01-04 09:03:05 UTC
Created attachment 61935 [details]
A patch against tk cvs head to fix the SCIM XIM issue.

It's a patch from a Taiwan engineer (Jim Huang) for tk cvs head to fix support issue of SCIM XIM server. I tested it and it works ok.

I think it's simple enough to be committed into tk cvs head.
Comment 26 Reinhard Max 2006-01-04 14:00:10 UTC
I've applied the patch to Tk 8.4.12 from STABLE, and it works perfectly with SCIM. Thanks a lot, Zhe.

I'll now apply it to HEAD and the 8.4 branch of the Tk CVS.
Comment 27 Reinhard Max 2006-01-04 14:15:26 UTC
BTW, this patch appears to be the work of Joe English from the Tcl Core Team:
https://sourceforge.net/tracker/?func=detail&atid=112997&aid=905830&group_id=12997