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 695867 - input engine is not switched off when switching to a keyboard layout ibus does not know about in a non-Gnome application
input engine is not switched off when switching to a keyboard layout ibus doe...
Status: RESOLVED FIXED
Product: gnome-settings-daemon
Classification: Core
Component: general
3.7.x
Other Linux
: Normal normal
: ---
Assigned To: gnome-settings-daemon-maint
gnome-settings-daemon-maint
Depends on:
Blocks:
 
 
Reported: 2013-03-14 17:31 UTC by Mike FABIAN
Modified: 2013-03-21 12:32 UTC
See Also:
GNOME target: 3.8
GNOME version: ---


Attachments
keyboard: Always try to activate the ibus daemon (7.66 KB, patch)
2013-03-19 14:24 UTC, Rui Matos
committed Details | Review

Description Mike FABIAN 2013-03-14 17:31:15 UTC
1) Add a keyboard layout to the list if input sources which ibus does not
know about, for example using “gnome-control-center region”
and adding the

   ドイツ語(オーストリア)  = German (Austria)

keyboard layout.

Checking that it is there by checking the dconf key:

mfabian@ari:~
$ dconf dump /org/gnome/desktop/input-sources/
[/]
show-all-sources=false
current=uint32 1
sources=[('xkb', 'us'), ('xkb', 'mike'), ('ibus', 'm17n:t:nil-mike'), ('xkb', 'de'), ('ibus', 'anthy'), ('ibus', 'typing-booster:en_GB'), ('ibus', 'm17n:t:latn-post'), ('ibus', 'typing-booster:de_DE'), ('ibus', 'm17n:t:german-mike'), ('ibus', 'ipa-x-sampa'), ('ibus', 'm17n:ru:translit'), ('ibus', 'wubi-jidian86'), ('ibus', 'stroke5'), ('ibus', 'hangul'), ('ibus', 'libpinyin'), ('ibus', 'm17n:da:post'), ('ibus', 'mozc-jp'), ('ibus', 'kkc'), ('ibus', 'm17n:ru:phonetic'), ('ibus', 'xkb:us:intl:eng'), ('ibus', 'xkb:br::por'), ('xkb', 'at')]
xkb-options=@as []
mfabian@ari:~
$ 

It is the last on in this list: ('xkb', 'at')
(comes from /usr/share/X11/xkb/symbols/at)

2) Now check that ibus does not know this:

mfabian@ari:~
$ ibus list-engine | grep xkb|grep at
  xkb:us:intl:eng - English (US, international with dead keys)
  xkb:us:altgr-intl:eng - English (international AltGr dead keys)
  xkb:lv:apostrophe:lav - Latvian (apostrophe variant)
  xkb:kr:kr104:kor - Korean (101/104 key compatible)
  xkb:es:cat:cat - Catalan (Spain, with middle-dot L)
  xkb:latam::spa - Spanish (Latin American)
  xkb:hr::scr - Croatian
mfabian@ari:~
$ 

OK, ibus doesn’t know this.

3) Now in a non-Gnome application like xterm or konsole (it is important
to use a non-Gnome application here!) do:

- select an input engine, for example ibus-anthy (Japanese)
  (any other engine will do as well, does not have to be Japanese,
  the bug can be reproduced with any engine)
- type ‘a’ and verify you get ‘あ’, i.e. the Japanese input engine is active
- Switch to German (Austria) keyboard (or any other keyboard ibus does not know about)
- type ‘a’, you still get ‘あ’

So the Japanese engine is not deactivated in non-Gnome applications
when switching to a keyboard layout ibus doesn’t know about.
Comment 1 Takao Fujiwara 2013-03-15 02:43:29 UTC
Only 'at' is lacked?
Probably I think either adding 'at' in /usr/share/ibus/component/simple.xml or removing 'at' from gnome-control-center would be a good idea.
However if your xkb does not exist in ibus list, I think maybe it's good to fallback ibus_bus_set_global_engine(,'xkb:us::eng') in gnome-settings-daemon.
Comment 2 Mike FABIAN 2013-03-15 11:14:20 UTC
(In reply to comment #1)
> Only 'at' is lacked?

There  maybe more, I am not sure.

I discovered this bug using my own keyboard layout. I added a
file

    /usr/share/X11/xkb/symbols/mike

And added it to base.xml:

mfabian@ari:/usr/share/X11/xkb/rules
$ diff  -u base.xml.orig base.xml
--- base.xml.orig	2013-03-15 11:41:10.790563728 +0100
+++ base.xml	2013-03-15 11:43:41.785063272 +0100
@@ -1376,6 +1376,18 @@
     </layout>
     <layout>
       <configItem>
+        <name>mike</name>
+
+        <shortDescription>Mike</shortDescription>
+        <description>Mike’s layout</description>
+        <languageList>
+          <iso639Id>eng</iso639Id>
+        </languageList>
+      </configItem>
+      <variantList/>
+    </layout>
+    <layout>
+      <configItem>
         <name>ad</name>
         
         <shortDescription>ca</shortDescription>

Then I ran into that problem, asked Rui on IRC. He knew that problem already
and knew that it happens with all keyboard layouts ibus doesn’t know about.

So I checked whether there are others like this and found “at”.
I guess there maybe be more, didn’t check that carefully yet.

> Probably I think either adding 'at' in /usr/share/ibus/component/simple.xml

Ah, so I can make it work by adding my layout there as well:

$ diff -u  /usr/share/ibus/component/simple.xml.orig /usr/share/ibus/component/simple.xml
--- /usr/share/ibus/component/simple.xml.orig	2013-01-31 11:06:57.000000000 +0100
+++ /usr/share/ibus/component/simple.xml	2013-03-15 12:00:50.663526099 +0100
@@ -9,6 +9,17 @@
 	<textdomain>ibus</textdomain>
 	<engines>
 		<engine>
+			<name>xkb:mike::eng</name>
+			<language>eng</language>
+			<license>GPL</license>
+			<author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+			<layout>mike</layout>
+			<longname>Mike</longname>
+			<description>Mike’s layout</description>
+                        <icon>ibus-keyboard</icon>
+			<rank>99</rank>
+		</engine>
+		<engine>
 			<name>xkb:us::eng</name>
 			<language>eng</language>
 			<license>GPL</license>

If I do this, the problem disappears for my custom layout.

> or removing 'at' from gnome-control-center would be a good idea.
> However if your xkb does not exist in ibus list, I think maybe it's
> good to fallback ibus_bus_set_global_engine(,'xkb:us::eng') in
> gnome-settings-daemon.

That could be the right solution if I understood the discussion in #ibus
correctly.
Comment 3 Matthias Clasen 2013-03-18 10:22:15 UTC
rui, can you look at this ?
Comment 4 Rui Matos 2013-03-18 10:27:35 UTC
(In reply to comment #3)
> rui, can you look at this ?

yes, doing it now
Comment 5 Rui Matos 2013-03-19 14:24:56 UTC
Created attachment 239253 [details] [review]
keyboard: Always try to activate the ibus daemon

We set XMODIFIERS=@im=ibus globally at session start so that XIM
clients can immediately benefit from IBus input sources when/if the
user adds one. Unfortunately, these clients then won't work correctly
in case we don't actually activate the ibus daemon. E.g. dead keys
don't work in this case.

As such we'll always try to activate the daemon even if none of the
user's current input sources need it and set one of the trivial "echo"
engines so that XIM clients work correctly.
Comment 6 Rui Matos 2013-03-19 14:25:42 UTC
https://bugzilla.redhat.com/show_bug.cgi?id=917130 is related and should also get fixed with this patch.
Comment 7 Rui Matos 2013-03-19 14:44:30 UTC
Just noticed that it isn't clear from the commit description why it fixes this bug here. There's this comment in the code that explains it:

+        /* All the "xkb:..." IBus engines simply "echo" back symbols,
+           despite their naming implying differently, so we always set
+           one in order for XIM applications to work given that we set
+           XMODIFIERS=@im=ibus in the first place so that they can
+           work without restarting when/if the user adds an IBus
+           input source. */

Previously we'd try to set an "xkb:..." ibus engine according to the XKB layout. It happens that this wouldn't work for most layouts since there isn't an ibus engine for each layout and it's actually not needed since all of those "xkb:..." engines work the same way despite having different names. I just realized this fact recently.
Comment 8 Bastien Nocera 2013-03-19 14:56:35 UTC
Review of attachment 239253 [details] [review]:

Looks fine with the explanation in the comment.
Comment 9 Rui Matos 2013-03-19 15:19:19 UTC
Pused with an expanded commit message.

Attachment 239253 [details] pushed as a656df8 - keyboard: Always try to activate the ibus daemon
Comment 10 Mike FABIAN 2013-03-21 12:32:38 UTC
That works, thank you!