Subject: Wrongly picks AZERTY layout when alternative Canadian layout is present.

From: Charles Plessy <[email-masked]>
Date: Wed, 04 Mar 2020 04:31:10 +0900

Package: ibus-mozc
Version: 2.23.2815.102+dfsg-4
Severity: normal

Hi Nobuhiro,

It has been years that I was affected with that bug, but I am only
reporting it now as I found an (old!) workaround in Launchpad.

I use GNOME with a Japanese keyboard, and I have 3 layouts configured; I
switch between them according to the language I write in.

 - jp – Japanese (OADG 109A), for writing English and programming.
 - fr – Candian Multilingual, for writing French.  This is a QWERTY layout.
 - あ – Japanese (Mozc), for writing Japanese.

Strangely, while both the Japanese and Canadian layouts are QWERYY, the mozc
engine automatically picks an AZERTY layout (which is standard in France),
despite my laptop has a Japanese keyboard.

In https://bugs.launchpad.net/ubuntu/+source/indicator-keyboard/+bug/1240004
I learnt that if I replace "default" with "jp" in /usr/share/ibus/component/mozc.xml
then mozc will use the Japanese layout as appropriate.  But obviously
this change will be erased at the next package upgrade.

I am not sure how to solve that problem in the long term…

Cheers,

-- Charles

-- System Information:
Debian Release: 10.3
  APT prefers stable
  APT policy: (900, 'stable'), (500, 'stable-updates')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.19.0-8-amd64 (SMP w/4 CPU cores)
Kernel taint flags: TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=fr_FR.utf8, LC_CTYPE=fr_FR.utf8 (charmap=UTF-8), LANGUAGE=fr_FR.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages ibus-mozc depends on:
ii  ibus                    1.5.19-4+deb10u1
ii  libc6                   2.28-10
ii  libglib2.0-0            2.58.3-2+deb10u2
ii  libibus-1.0-5           1.5.19-4+deb10u1
ii  libprotobuf17           3.6.1.3-2
ii  libstdc++6              8.3.0-6
ii  libxcb-xfixes0          1.13.1-2
ii  libxcb1                 1.13.1-2
ii  mozc-data               2.23.2815.102+dfsg-4
ii  mozc-server             2.23.2815.102+dfsg-4
ii  tegaki-zinnia-japanese  0.3-1

Versions of packages ibus-mozc recommends:
ii  mozc-utils-gui  2.23.2815.102+dfsg-4

ibus-mozc suggests no packages.

-- no debconf information

---

From: Gunnar Hjalmarsson <[email-masked]>
Date: Sun, 21 Mar 2021 15:05:38 +0100

Thanks for your report!

Can you please run these terminal commands:

gsettings get org.gnome.desktop.input-sources sources

gsettings get org.freedesktop.ibus.general use-system-keyboard-layout

cat /etc/default/keyboard

and let us know what they output.

-- 
Cheers,

Gunnar Hjalmarsson
https://launchpad.net/~gunnarhj

---

From: Charles Plessy <[email-masked]>
Date: Sun, 24 Jul 2022 18:42:18 +0900

Dear Gunnar and Nobuhiro,

it took me some time to debug the issue further, but here are some
new information that I hope you will find useful:

In finally found that the AZERTY layout is imposed by the Japanese
input system when the language I chose in Gnome is French from France,
and switching it to French from Canada or of course English restores
the QWERTY layout.

So it looks like the problem did not have to do with the presence of
the alternative canadian keyboard layout.

I inspected my locales when using the different variants of French
and the most prominent change is LANG, with either fr_FR or fr_CA.

So maybe ibus or Mozc hardcode the input layout to AZERTY through
a guess based on the fr_FR locale, assuming that all French speakers
from France type on AZERTY keyboards ?

> gsettings get org.gnome.desktop.input-sources sources

[('ibus', 'mozc-jp'), ('xkb', 'jp'), ('xkb', 'ca+multix')]
 
> gsettings get org.freedesktop.ibus.general use-system-keyboard-layout

false

> cat /etc/default/keyboard

XKBLAYOUT=jp,ca
XKBVARIANT=,multix
BACKSPACE=guess

And also:

cat /etc/default/locale 

LANG=fr_CA.UTF-8

Have a nice day,

-- 
Charles Plessy                         Nagahama, Yomitan, Okinawa, Japan
Debian Med packaging team         http://www.debian.org/devel/debian-med
Tooting from work,           https://mastodon.technology/@charles_plessy
Tooting from home,                 https://framapiaf.org/@charles_plessy

---

From: Gunnar Hjalmarsson <[email-masked]>
Date: Sun, 24 Jul 2022 22:27:38 +0200

> [('ibus', 'mozc-jp'), ('xkb', 'jp'), ('xkb', 'ca+multix')]

I don't understand from where it gets AZERTY, but I may have a solution.

ibus-mozc 2.23.2815.102+dfsg-4, which you at least used when reporting 
the issue, installs the /usr/share/ibus/component/mozc.xml file with 
this line:

   <layout>default</layout>

I changed that on my own machine to:

   <layout>ca</layout>
   <layout_variant>multix</layout_variant>

and it seemed to work. Optionally you can just change it to:

   <layout>jp</layout>

Can you please test those suggestions and let us know if it makes a 
difference for you.

-- 
Gunnar

---

From: Gunnar Hjalmarsson <[email-masked]>
Date: Sun, 24 Jul 2022 22:47:08 +0200

As regards a solution which survives a package update, the latest 
ibus-mozc version in the Debian archive creates this file:

$ cat ~/.config/mozc/ibus_config.textproto
engines {
   name : "mozc-jp"
   longname : "Mozc"
   layout : "default"
}

So to specify a layout you can now do:

   layout : "ca"
   layout_variant : "multix"

or just

   layout : "jp"

---

From: Charles Plessy <[email-masked]>
Date: Sun, 18 Sep 2022 09:10:40 +0900

Hi Gunnar !

Summary: I report which layout I get with various combinations of locale and
user and system configurations.  Perhaps importantly, I also found that when I
switch layout using the keyboard shortcut that I configured (pressing the two
shift keys), I do not get the same result as if I select the same layout using
the mouse in the menu bar!

I tried multiple combinations of configurations.  To describe them easily, I
will call "user layout" the value of "layout" in
~/.config/mozc/ibus_config.textproto, which for instance is "jp"
in the example below:

    cat ~/.config/mozc/ibus_config.textproto
    
    engines {
      name : "mozc-jp"
      longname : "Mozc"
      layout : "jp"
   }

  layout : "jp"

And I will call "system layout" the value of "<layout>" in the
file /usr/share/ibus/component/mozc.xml, which for instance is "jp"
in the example below.

    cat  /usr/share/ibus/component/mozc.xml 
    <component>
      <name>com.google.IBus.Mozc</name>
      <description>Mozc Component</description>
      <exec>/usr/lib/ibus-mozc/ibus-engine-mozc --ibus</exec>
      <version>2.26.4220.100+dfsg-4</version>
      <author>Google Inc.</author>
      <license>New BSD</license>
      <homepage>https://github.com/google/mozc</homepage>
      <textdomain>ibus-mozc</textdomain>
      <engines exec="/usr/lib/ibus-mozc/ibus-engine-mozc --xml" />
      <layout>jp</layout>
    </component>

As I write this, I have "jp" in both my user and system layout, and
LANG=fr_FR.UTF-8, LANGUAGE= and LC_ALL= in my environment.  My three layouts
are Japanese (Mozc), Japanese and Canadian multilingual. `gsettings get
org.gnome.desktop.input-sources sources` indicates: [('ibus', 'mozc-jp'),
('xkb', 'jp'), ('xkb', 'ca+multix')].  However, when I select the xkb jp
layout, the keyboard types in canadian layout.  The two other layouts
give the expected result.

As I reported earlier, when the user and system "layout" values are "default",
and my locale is fr_FR.UTF-8, then when I select the Mozc layout my keyboard
sometimes in types in azerty layout, which I have configured nowhere.  Today
I found that this only happens if I switch to the layout via the keyboard
shortcut (here: shiftL + shiftR).  If I switch layout using the mouse and the
GNOME menu bar, the Mozc layout is the same as the previously selected keyboard
(either Japanese or Canadian multilingual).

Here is a summary of various combinations of configurations that I tested.  Too
be frank, using the fr_CA.UTF-8 is fine with me as a workaround.  My main
motivation with this report is that in the default configuraiton, having the
French azeerty layout picked despite it is nowhere in the configuraiton is
clearly a bug.

user	system	locale		problem
----	------	------		-------
default	default	fr_FR.UTF-8	ibus mozc-jp layout is sometimes French azerty and sometimes Canadian
default	default	fr_CA.UTF-8	fr_CA.UTF-8 is in principle the wrong locale.	
jp	jp	fr_FR.UTF-8	xkb jp layout is Canadian
jp	jp	fr_CA.UTF-8	xkb jp layout is Canadian
jp	default	fr_CA.UTF-8	xkb jp layout is Canadian
jp	default	fr_FR.UTF-8	xkb jp layout is Canadian
default	jp	fr_FR.UTF-8	xkb jp layout is Canadian
default	jp	fr_CA.UTF-8	xkb jp layout is Canadian

Have a nice week-end !

-- 
Charles