GNOME Bugzilla – Bug 153800
IME input method prevents text input on Swedish Windows XP (HEAD)
Last modified: 2014-03-24 03:03:55 UTC
I'm running latest GTK+ from CVS HEAD on Swedish Windows XP Home SP2, with Swedish keyboard layout. I only have Swedish and English input languages installed with corresponding keyboard layouts. The imime input method that was added in bug #135195 seems to prevent all text input for me. For example if I start tests/testgtk and choose the Entry test, typing on the keyboard yields no input in the entry. I also get some error messages, for example when changing cursor position in an entry (but not when typing on the keyboard): ** (testgtk.exe): CRITICAL **: get_utf8_preedit_string: assertion `himc' failed ** (testgtk.exe): CRITICAL **: get_pango_attr_list: assertion `himc' failed Of course I can solve this for myself by commenting out the imime module in gtk.immodules, and then text entry works fine, but it would be nicer if it worked out of the box. There was some related discussion on #gtk-devel recently: http://www.gtk.org/plan/meetings/20040831.txt
I have done some local changes to the IME stuff, to make it use the wide-char API all the time (and not just if compiled with -DUNICODE, which we haven't done in GTK). The wide-char versions of the Imm* API is present also in Win98/Me, so using it shouldn't be a big concern. (There are already other stuff in HEAD GTK+ that doesn't exist in Win95.) Will attach my patch to gtkimcontextime.c. Check if it helps you.
Created attachment 31993 [details] [review] Suggested patch
Nope, it still doesn't work. It seems like ImmGetContext() on client_window's hwnd returns 0.
ImmCreateContext() returns 0 as well. I guess it has something to do with this (guessing that the same applies to XP): "Note that Windows 2000 provides full-featured IME support in all localized language versions, however, that IMM is enabled only when an Asian language pack is installed." from http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/ime_6wtu.asp
Created attachment 32045 [details] Try this then... New version of gtkimcontextime.c. Now I check for ImmGetContext() returning NULL at all places. Seems to work fine for me, too. (I do have IMEs installed.)
That removes the error messages but text input still doesn't work. I have tried to read and understand the gtkimcontext code now, and as far as I can see the problem is simply that since IME is not available, gtkimcontextime basically won't do anything to the keypress events and never send any "commit" signal to the entry widgets. When the imime module is not loaded, the gtkimcontextsimple class is created by default and handles keypress events and sends "commit" signals. So maybe it is simply wrong to load the imime module on a system which does not support IME. Otherwise I think one needs a mechanism that allows gtkimcontextime to fall back on the other input methods when no IME is available. But I see no such handling for the imxim / gtkimcontextxim module, it is simply only set as default for "ko:ja:th:zh". (#include "I-dont-know-this-stuff-very-well.disclaimer" :))
Well, as you say, a simple way around the problem for you is to change imime.c to set itself as default only for ja:ko:zh. (and th?) All Windows boxes whose locale are one of those presumably have IMEs activated? Still, it would be nice if the ime module would work also if somebody selects it even though the machine hasn't any IMEs. Hmm, now that I look again at gtk_im_context_ime_filter_keypress(), I don't understand why it calls ImmGetContext() at all? It doesn't do anything with the HIMC. Try to just remove the ImmGetContext() and ImmReleaseContext() calls.
Of course I can work around the problem very easily myself, I can just make sure the imime module is not built and installed, but don't you think this will bite every single user who don't have an IME-enabled system? Don't spend time on this if you don't think this is a problem for anyone else. I hacked away the Imm* calls in gtk_im_context_ime_filter_keypress, and had to remove the !context_ime->focus check as well, and then text entry works, but dead key handling is missing. For example, if I press ^ and a, an ordinary a is entered. As far as I can see dead keys are usually handled by gtkimcontextsimple.
> don't you think this will bite every single user > who don't have an IME-enabled system? Yep. Unless this can be fixed I don't think one should include the im-ime module in a GTK binary distribution. If only modules could tell the upper levels at run time whether they actually want to be used on not it would be easy, im-ime would just say No Thanks if they system doesn't have any IMEs. But the gtkimmodule API doesn't currently enable that. Hmm, but the im-ime module could have a g_module_check_init() function (which is called automatically by g_module_open() if it exists) that returns FALSE if there are no IMEs?
I have a patch sitting around to add a Gtk/IMModule setting. Need to finish that up. Then the Win32 backend could just set that.
I committed an updated version of the gtkimcontextime.c above, and a change to imime.c to make it default only for ja:ko:zh. 2004-10-01 Tor Lillqvist <tml@iki.fi> * modules/input/gtkimcontextime.c: Numerous changes. Remove the ifdef UNICODE conditionals. Always use the wide-character Imm* API. It is present also in Windows 98 and Me. (Not Windows 95, but I think we don't care about that.) Using the multibyte API wouldn't work anyway on systems where the system codepage doesn't support the language the user uses an IME for, so for instance I wouldn't be able to test this module on my English Windows 2000 although I do have C, J and K IMEs available. Guard against IMM not being active, always check ImmGetContext() returning NULL. Work to some extent even without any IME. Fixes #153800 at least partially. * modules/input/imime.c (ime_info): Rename to "ime" to match the naming pattern of other input modules. Make it default for ja:ko:zh only.
Owen, do you still want to finish that Gtk/IMModule setting ?
I take that as a no