After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 768412 - $GTK_IM_MODULE is ignored
$GTK_IM_MODULE is ignored
Status: RESOLVED OBSOLETE
Product: gtk+
Classification: Platform
Component: Input Methods
3.20.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2016-07-04 19:27 UTC by Konstantin Kharlamov
Modified: 2018-05-02 17:16 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Konstantin Kharlamov 2016-07-04 19:27:46 UTC
After distro upgrade, Compose key for all GTK3 (only) apps produces wrong characters, like if it ignores the GTK_IM_MODULE=xim. E.g.: «Compose + - + space» ought to produce «— », as is set in ~/.XCompose, but produces «~» instead. Other toolkit apps — GTK2 and Qt — works fine.

For testing purposes I created with Glade a window with textbox, and ran against built gtk+-3.20.6 — and I can confirm, the problem still persist.

I tried to debug it myself, and found that in the gtkimmodule.c:970

        context_id = lookup_immodule (immodules);

«immodules[0] == "xim"», and lookup_immodule() probably checks if the string is in global variable «contexts_hash» — and returns zero 'cause it isn't. A bit of code later, in the line

	  return context_id ? context_id : SIMPLE_ID;

the "gtk-im-context-simple" is returned instead of xim.

I think we need to find where the «contexts_hash» is initialized, but I wrongly assumed that hardware watchpoints doesn't work in libs, tried to look trough the code manually, and kinda lost. I think, if nobody would guess what's the problem, I'll try this weekend to debug this again.
Comment 1 Matthias Clasen 2016-07-05 13:25:10 UTC
You left out some important information: what version of gtk3 did you see this working with (before your distro upgrade) ?
Comment 2 Matthias Clasen 2016-07-05 13:26:05 UTC
Btw, in GTK+ 3.20, GtkIMContextSimple is reading and using ~/.XCompose anyway.
Comment 3 Konstantin Kharlamov 2016-07-05 17:25:16 UTC
> what version of gtk3 did you see this working with (before your distro
> upgrade) ?

Looking through the logs it was upgrade 3.10.8 → 3.18.9. I just downloaded this version, compiled, and tried to run the test window against it, but gtk3.10.8 doesn't show a window with complaint:

	$ LD_LIBRARY_PATH=./gtk/.libs/ GTK_THEME=./gtk/theme/Adwaita/gtk.css ./a

	(a:5446): Gtk-CRITICAL **: gtk_widget_show: assertion 'GTK_IS_WIDGET (widget)' failed

> Btw, in GTK+ 3.20, GtkIMContextSimple is reading and using ~/.XCompose
> anyway.

Well, for whatever reason I can't produce any of those characters in the test window, when run against 3.20.6.
Comment 4 Konstantin Kharlamov 2016-07-05 17:31:37 UTC
Right — I just tried to run the test app against 3.20.6 like:

	$ LD_LIBRARY_PATH=./gtk/.libs/ GTK_THEME=./gtk/theme/Adwaita/gtk.css GTK_IM_MODULE=gtk-im-context-simple ./a

And none of ~/.XCompose combinations works.
Comment 5 Konstantin Kharlamov 2016-07-05 17:48:40 UTC
Btw, I don't think it is relevant, but I witnessed a funny accident. The first time I ran the test app against just built gtk-3.20.6, it produced hundreds of warnings about ~/.XCompose. I managed to read only one of them, it was saying something about not supported multicharacter "— ". Then I decided to redirect the output to a file for comfortable reading, restarted the app, and surprisingly revealed that those warnings gone. Then I fought warnings about a theme by setting «GTK_THEME=./gtk/theme/Adwaita/gtk.css», and now I see no warnings at all.
Comment 6 Matthias Clasen 2016-07-08 04:58:28 UTC
ok, so thats a pretty good hint. gtk is parsing .XCompose and caches the results in ~/.cache/gtk-3.0/compose. So unless you modify .XCompose or remove the cache, you will not see the warnings again. The warnings seem to indicate that your .XCompose file is using features that gtk doesn't support.
Comment 7 Konstantin Kharlamov 2016-07-08 05:19:58 UTC
Ah, that's interesting. I have had something like this in mind, but what confused me: for some reason if I ran the app under `strace`, and grep for all successful open calls — I never see anything relevant to compose being opened.

Anyway, I just removed the file, restarted the app, and I see a bunch of errors. I noticed three types of them: two of them — incompatibility errors, and one type — just parsing error. FWIW I'm using slightly modified version of this file https://github.com/kragen/xcompose/blob/master/dotXCompose

I'm wondering: should I report a bug against gtk-im-context-simple now? Or do we have to finish this bug, so that we would be sure that it is the problem of gtk-im-context-simple?
Comment 8 Konstantin Kharlamov 2016-07-08 06:49:24 UTC
Well, ATM I'm at my work, and I quickly build the same test against an older GTK here — 3.10. When I'm setting GTK_IM_MODULE=gtk-im-context-simple, XCompose also produces wrong characters, and I didn't see errors about ~/.XCompose. The file to remove — specifically whole directory ~/.cache/gtk-3.0 — doesn't exist.
Comment 9 Matthias Clasen 2016-07-08 14:18:05 UTC
Support for reading ~/.XCompose was added in 3.20
Comment 10 Konstantin Kharlamov 2016-07-09 20:56:50 UTC
Yay, I fixed it! :з

Okay, so, the problem was: GTK-3.20 assumes that this «contexts_hash» is filled, and seeks for $GTK_IM_MODULE modules inside this variable. If it's not found, then instead of the $GTK_IM_MODULE module, it uses its default module, i.e. «gtk-im-context-simple».

But the variable being filled from the file "/usr/local/lib/gtk-3.0/3.0.0/immodules.cache" which doesn't exist. So I created it with:

	$ sudo /usr/lib/x86_64-linux-gnu/libgtk-3-0/gtk-query-immodules-3.0 --update-cache

Now for most gtk3 apps on my system, Compose key works, the $GTK_IM_MODULE is no more ignored. There's an exception though: if I run the test app with the preloaded gtk-3.20:

	LD_LIBRARY_PATH=./gtk/.libs/ GTK_THEME=./gtk/theme/Adwaita/gtk.css ./a

Then it doesn't work because gtk-3.20 for some reason looks for the file in another directory, it is "/usr/local/lib/gtk-3.0/3.0.0/immodules.cache" instead of "/usr/lib/x86_64-linux-gnu/gtk-3.0/3.0.0/immodules.cache.AGUOKY". So, as distros move to gtk-3.20, you might expect more bugreports about IM modules not loaded ☺

The bug though is still relevant. I think, rather than bail out to the default IM module, GTK, at the very least, ought to warn about the missing file. Or even better, to create it — because refusing to load the module just because it wasn't cached looks completely wrong.
Comment 11 Konstantin Kharlamov 2016-10-10 11:09:12 UTC
Matthias Clasen, after reading many posts on the matter, I started wondering, what's the point of the GtkIMContextSimple? Shouldn't GTK in the absence of IM use libxkb, which also does parse of ~/.XCompose in the right way?
Comment 12 Matthias Clasen 2018-02-10 04:56:45 UTC
We're moving to gitlab! As part of this move, we are moving bugs to NEEDINFO if they haven't seen activity in more than a year. If this issue is still important to you and still relevant with GTK+ 3.22 or master, please reopen it and we will migrate it to gitlab.
Comment 13 Konstantin Kharlamov 2018-02-11 08:31:53 UTC
(In reply to Matthias Clasen from comment #12)
> We're moving to gitlab! As part of this move, we are moving bugs to NEEDINFO
> if they haven't seen activity in more than a year. If this issue is still
> important to you and still relevant with GTK+ 3.22 or master, please reopen
> it and we will migrate it to gitlab.

Well, as noted in comment:

> The bug though is still relevant. I think, rather than bail out to the
> default IM module, GTK, at the very least, ought to warn about the missing
> file. Or even better, to create it — because refusing to load the module
> just because it wasn't cached looks completely wrong.

It's still relevant. I just removed immodules.cache, and started

	$ GTK_IM_MODULE=xim gnome-terminal

No warnings, however Compose key produces unexpected characters, like "~" for "Compose+-+<space>" instead of "— " (that is a Em Dash followed by space) which is set in ~/.XCompose.

gtk version tested is 3.22.26.
Comment 14 GNOME Infrastructure Team 2018-05-02 17:16:26 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gtk/issues/643.