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 776189 - Wrong default input configuration for Japanese
Wrong default input configuration for Japanese
Status: RESOLVED FIXED
Product: gnome-initial-setup
Classification: Applications
Component: general
3.23.x
Other Linux
: Normal normal
: ---
Assigned To: GNOME Initial Setup maintainer(s)
GNOME Initial Setup maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2016-12-17 02:49 UTC by Adam Williamson
Modified: 2018-04-12 04:37 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
keyboard: pre-select input source from X Window or gnome-desktop (2.35 KB, patch)
2018-04-03 07:19 UTC, Peng Wu
none Details | Review
keyboard: pre-select input source from X Window or gnome-desktop (3.42 KB, patch)
2018-04-09 09:04 UTC, Peng Wu
none Details | Review
keyboard: pre-select input source from X Window or gnome-desktop (3.90 KB, patch)
2018-04-11 07:55 UTC, Peng Wu
committed Details | Review

Description Adam Williamson 2016-12-17 02:49:42 UTC
When you install Fedora in Japanese, and encounter the gnome-initial-setup input method screen on first boot, the default selection is not the best choice.

There are five choices, which translate as (from top to bottom):

Japanese (Kana Kanji)
Japanese
Japanese (Dvorak)
Japanese (Macintosh)
Japanese (OADG 109A)

The first of these, "Japanese (Kana Kanji)", is the best choice, as that is the choice that provides you with two input choices, one a standard US keyboard layout, the other a proper Japanese input method.

However, the option that is selected by default is the second one, which is just labelled "Japanese" (日本語). This is a bad choice, because it is simply the 'ja' keyboard layout, which is just a slight variant on 'us' and doesn't actually give you the ability to input any Japanese text.

g-i-s should select "Japanese (Kana Kanji)" - 日本語(かな漢字) - instead.
Comment 1 Adam Williamson 2016-12-17 02:50:47 UTC
Tested with Fedora Rawhide (20161211.n.0), gnome-initial-setup-3.23.1-1.fc26 .
Comment 2 Adam Williamson 2016-12-17 03:42:16 UTC
minor correction, picking Japanese (Kana Kanji) gives you the 'ja' keyboard layout as one of your input methods and the real Japanese input method as the other (not 'us' plus the input method as I wrote).
Comment 3 Michael Catanzaro 2017-01-09 17:34:24 UTC
Haven't looked at the code, but I rather suspect we always choose the "default" layout rather than selecting a more-qualified layout. Unless you or the ibus folks have some recommendation on exactly how we are supposed to pick the best input method for a language, I kinda doubt we're going to be able to do better. Certainly we're not going to hardcode something for Japanese in particular.
Comment 4 Adam Williamson 2017-01-09 17:38:32 UTC
I don't know how it used to happen, but GNOME certainly used to pick the input-method based choice. It was in fact quite 'trumpeted' as a feature a few years ago, IIRC, that you could actually work properly with CJK languages in GNOME out of the box.
Comment 5 Adam Williamson 2017-03-10 01:41:33 UTC
This is still the case in current Fedora 26 and Rawhide.
Comment 6 Michael Catanzaro 2017-07-05 23:50:15 UTC
Is this an F25 regression or an F24 regression?

Either way, I fear there are no relevant changes in gnome-initial-setup, so something must have changed elsewhere in the stack.
Comment 7 Adam Williamson 2017-07-05 23:55:38 UTC
Well, per my initial report I first noticed it with Rawhide early in the F26 cycle. I'll have to go back and check how F25 behaved.
Comment 8 Adam Williamson 2017-07-05 23:57:33 UTC
(it was actually openQA tests that exposed this; the test assumed that g-i-s would do 'the right thing' and when it stopped doing that, the test broke. I had to adjust the test to check whether the right input method was selected and choose it if not.)
Comment 9 Michael Catanzaro 2017-07-06 00:23:14 UTC
Someone more familiar with the input method stack might want to look around for relevant package upgrades that landed around the start of the F26 cycle.

I found this:

https://git.gnome.org/browse/gnome-desktop/tree/libgnome-desktop/default-input-sources.h

But there are no relevant changes there. Looks like it should be defaulting to ibus-anthy. And the only changes to that Fedora package are rebuilds. Same for the anthy package. And all the changes to ibus occurred after you reported this bug. So I'm stumped. But hey, I found a neat-o default-input-sources.h file!
Comment 10 Rui Matos 2017-07-06 16:17:25 UTC
You are only talking about the pre-selected input source, right? Users are still able to choose the right one here.

This is a side effect of https://git.gnome.org/browse/gnome-initial-setup/commit/?id=a6b0132193d1c4031035d4d412285a488dfaf2a6 .

We try to pre-select what's already configured system-wide as a convenience. Unfortunately, the system-wide configuration doesn't include IBus sources.

Ideas to improve/change this are welcome.
Comment 11 Michael Catanzaro 2017-07-06 16:24:08 UTC
Well this is a regression from 3.22 to 3.24, so something else has changed a lot more recently than that.
Comment 12 Adam Williamson 2017-07-06 17:20:37 UTC
"You are only talking about the pre-selected input source, right?"

Yes, indeed.

"Users are still able to choose the right one here."

Yes, but note the discussion on Fedora desktop@ mailing list about removing this screen from g-i-s...
Comment 13 Adam Williamson 2017-07-11 21:45:42 UTC
So...I just checked, and both Fedora 24 and Fedora 25 behave the same way (they pre-select Japanese, not Japanese (Kana Kanji)). Now I look back at the commit logs to the openQA test I can no longer say for sure that this ever behaved as I expected for the openQA test. But I'm still pretty sure that some time ago it *did* work, just might be longer than I thought. I'll try a few older versions and see if I can find one where it works.

Perhaps it's never worked so long as g-i-s has been around and had an Input screen, but before that it worked somehow via automatic configuration of an input method based on the locale of the installed system? Well, I'll see.
Comment 14 Adam Williamson 2017-08-03 21:21:39 UTC
I went back to like F22 or something and still didn't see this work the way I'd expect it to. So I think I was wrong in thinking that it ever worked right at least as long as g-i-s has been around; it may have worked right before g-i-s was a thing at all.

But still, it would be much better for the default to be a useful choice. The current default just is not a useful choice at all.
Comment 15 Peng Wu 2018-04-03 07:19:22 UTC
Created attachment 370474 [details] [review]
keyboard: pre-select input source from X Window or gnome-desktop

For keyboard layout, we pre-select it from X Window.
For other input source, we pre-select it from gnome-desktop.
Comment 16 Peng Wu 2018-04-03 07:21:30 UTC
The patch pre-select input source from X Window or gnome-desktop.

Sorry, I will test the patch when I am back.
Comment 17 Peng Wu 2018-04-09 09:04:06 UTC
Created attachment 370677 [details] [review]
keyboard: pre-select input source from X Window or gnome-desktop

For keyboard layout, we pre-select it from X Window.
For other input source, we pre-select it from gnome-desktop.
Comment 18 Peng Wu 2018-04-09 09:06:11 UTC
I tried the patch on Fedora 28, it seems work now.

Also I changed the code to use cc_common_language_get_current_language instead.

Please review the patch, thanks!
Comment 19 Michael Catanzaro 2018-04-09 23:00:09 UTC
Review of attachment 370677 [details] [review]:

Yeah, this looks like a pretty good idea. Thanks for investigating and fixing this!

::: gnome-initial-setup/pages/keyboard/gis-keyboard-page.c
@@ +362,3 @@
         priv->system_sources = g_slist_reverse (sources);
 
+        /* We pre-select the input source from X Window or gnome-desktop.

Let me test my understanding of this code change. I guess it would be more accurate to say: "we pre-select the input source from gnome-desktop if the default source for the current language is a non-xkb source, and from localed otherwise," right? In other words: pre-select the GNOME default input source if the default input source for the language is an input method, otherwise, select the input source from localed. In other words: ignore the keyboard layout set in the distro installer if we think the user probably wants to enable an input method. Is that all correct? I think this makes a lot of sense, because gnome-desktop understands input methods, whereas I assume localed will only ever return a vanilla keyboard layout, so this seems good to me.

@@ +365,3 @@
+         * For keyboard layout, we pre-select it from X Window.
+         * For other input source, we pre-select it from gnome-desktop. */
+        if (priv->system_sources) {

I think this condition needs to be moved lower, because:

 * In case the default input source from gnome-desktop is not xkb, we don't use priv->system_sources at all, and it shouldn't matter if it's NULL
 * Even if the default input source from gnome-desktop is xkb, if priv->system_sources is NULL, we probably want to fall back to the input source provided by gnome-desktop, right?

So I'd do something like:

if (!priv->input_sources ||
    (gnome_get_input_source_from_locale (language, &type, &id) && strcmp (type, "xkb") != 0)) {
        // ...
} else {
        // ...
}

That way we always pre-select the input source from gnome-desktop if we can't get anything out of localed.

@@ +369,3 @@
+
+		if (gnome_get_input_source_from_locale (language, &type, &id) &&
+		    !g_str_equal (type, "xkb"))

g_str_equal is for hash tables, just use strcmp here.

Also, I'd put braces

if () {
} else {
}

around this whole thing, since it's pretty big, even if each condition is only one statement and that's not strictly necessary... it looks cleaner that way IMO.
Comment 20 Michael Catanzaro 2018-04-09 23:07:19 UTC
(In reply to Michael Catanzaro from comment #19)
> I guess it would be more
> accurate to say: "we pre-select the input source from gnome-desktop if the
> default source for the current language is a non-xkb source, and from
> localed otherwise," right? 

I would change the comment to say that, and add a bit of explanation as to why this approach was chosen.
Comment 21 Peng Wu 2018-04-11 07:55:46 UTC
Created attachment 370779 [details] [review]
keyboard: pre-select input source from X Window or gnome-desktop

For keyboard layout, we pre-select it from X Window.
For other input source, we pre-select it from gnome-desktop.
Comment 22 Peng Wu 2018-04-11 07:57:51 UTC
Okay, I wrote the explanation in the code comment.

Please review it again, thanks!
Comment 23 Michael Catanzaro 2018-04-11 17:36:55 UTC
OK it looks good, I'll just edit the comment slightly and adjust the line breaking before committing.
Comment 24 Michael Catanzaro 2018-04-11 17:37:47 UTC
Review of attachment 370779 [details] [review]:

::: gnome-initial-setup/pages/keyboard/gis-keyboard-page.c
@@ +378,3 @@
+
+        if ((gnome_get_input_source_from_locale (language, &type, &id) &&
+	     g_strcmp0 (type, "xkb") != 0) || !priv->system_sources) {

(It's easier to read if the g_strcmp0 is moved to the previous line, since that is the first half of the big OR.)
Comment 25 Michael Catanzaro 2018-04-11 17:38:00 UTC
Review of attachment 370779 [details] [review]:

::: gnome-initial-setup/pages/keyboard/gis-keyboard-page.c
@@ +378,3 @@
+
+        if ((gnome_get_input_source_from_locale (language, &type, &id) &&
+	     g_strcmp0 (type, "xkb") != 0) || !priv->system_sources) {

(It's easier to read if the g_strcmp0 is moved to the previous line, since that is the first half of the big OR.)
Comment 26 Michael Catanzaro 2018-04-11 18:15:14 UTC
I'm also going to rename load_localed_input() to preselect_input_source() since it's no longer getting it's info from just localed.
Comment 27 Michael Catanzaro 2018-04-11 18:16:22 UTC
Attachment 370779 [details] pushed as 07e24d6 - keyboard: pre-select input source from X Window or gnome-desktop
Comment 28 Peng Wu 2018-04-12 04:37:36 UTC
Thanks for the review!