Backport MR #83 to fix preselection of input methods

This commit is contained in:
Adam Williamson 2020-05-04 16:59:06 -07:00
parent af4ef5dce5
commit e3b3925c7a
2 changed files with 98 additions and 1 deletions

View File

@ -0,0 +1,91 @@
From 9e0483079845da8d998e4fc58dab409d540817f6 Mon Sep 17 00:00:00 2001
From: Adam Williamson <awilliam@redhat.com>
Date: Mon, 4 May 2020 13:59:04 -0700
Subject: [PATCH] Fix default keyboard layout / input source choice priority
(#104)
This attempts to fix the problem I identified in #104 while also
not breaking for the case where there is no system source and
gnome_get_input_source_from_locale returns nothing. It should
implement the intended logic fully:
* If gnome-desktop gives us an input source, always preselect that
* If gnome-desktop gives us a keyboard layout and there's no
system sources, preselect the layout gnome-desktop gave us
* If there is a system source and we didn't get an input source
from gnome-desktop, preselect the system source
Signed-off-by: Adam Williamson <awilliam@redhat.com>
---
.../pages/keyboard/gis-keyboard-page.c | 43 +++++++++++++------
1 file changed, 29 insertions(+), 14 deletions(-)
diff --git a/gnome-initial-setup/pages/keyboard/gis-keyboard-page.c b/gnome-initial-setup/pages/keyboard/gis-keyboard-page.c
index fc139ee..a0c3d27 100644
--- a/gnome-initial-setup/pages/keyboard/gis-keyboard-page.c
+++ b/gnome-initial-setup/pages/keyboard/gis-keyboard-page.c
@@ -354,6 +354,8 @@ preselect_input_source (GisKeyboardPage *self)
const gchar *type;
const gchar *id;
gchar *language;
+ gboolean desktop_got_something;
+ gboolean desktop_got_input_method;
GisKeyboardPagePrivate *priv = gis_keyboard_page_get_instance_private (self);
GSList *sources = get_localed_input (priv->localed);
@@ -363,25 +365,38 @@ preselect_input_source (GisKeyboardPage *self)
g_slist_free_full (priv->system_sources, g_free);
priv->system_sources = g_slist_reverse (sources);
- /* For languages that use an input method, we will add both
- * system keyboard layout and the ibus input method. For
- * languages that use keyboard layout only, we will add only
- * system keyboard layout. Because the keyboard layout
- * information from gnome-desktop is not as accurate as system
- * keyboard layout, if gnome-desktop returns keyboard layout,
- * we ignore it and use system keyboard layout instead. If
- * gnome-desktop instead returns an ibus input method, we will
- * add both system keyboard layout and the ibus input method. */
+ /* We have two potential sources of information as to which
+ * source to pre-select here: the keyboard layout that is
+ * configured system-wide (read from priv->system_sources),
+ * and a gnome-desktop function that lets us look up a default
+ * input source for a given language. An important limitation
+ * here is that there is no system-wide configuration for
+ * input methods, so if the best choice for the language is an
+ * input method, we will only find it from the gnome-desktop
+ * lookup. But if both sources give us keyboard layouts, we
+ * want to prefer the one that's configured system-wide over
+ * the one from gnome-desktop. So we first do the gnome-desktop
+ * lookup, and keep track of what we got. If we got an input
+ * method, we preselect that, and we're done. If we got a
+ * keyboard layout, and there's no system-wide keyboard layout
+ * set, we preselect the layout we got from gnome-desktop. If
+ * we didn't get an input method from gnome-desktop and there
+ * is a system-wide keyboard layout set, we preselect that. If
+ * we got nothing from gnome-desktop and there's no system-wide
+ * keyboard layout set, we don't preselect anything. See:
+ * https://bugzilla.gnome.org/show_bug.cgi?id=776189 */
language = cc_common_language_get_current_language ();
- if (priv->system_sources) {
+ desktop_got_something = gnome_get_input_source_from_locale (language, &type, &id);
+ desktop_got_input_method = (desktop_got_something && g_strcmp0 (type, "xkb") != 0);
+
+ if (desktop_got_input_method || (!priv->system_sources && desktop_got_something)) {
+ cc_input_chooser_set_input (CC_INPUT_CHOOSER (priv->input_chooser),
+ id, type);
+ } else if (priv->system_sources) {
cc_input_chooser_set_input (CC_INPUT_CHOOSER (priv->input_chooser),
(const gchar *) priv->system_sources->data,
"xkb");
- } else if (gnome_get_input_source_from_locale (language, &type, &id) &&
- g_strcmp0 (type, "xkb") != 0) {
- cc_input_chooser_set_input (CC_INPUT_CHOOSER (priv->input_chooser),
- id, type);
}
g_free (language);
--
2.26.2

View File

@ -6,7 +6,7 @@
Name: gnome-initial-setup
Version: 3.37.1
Release: 1%{?dist}
Release: 2%{?dist}
Summary: Bootstrapping your OS
License: GPLv2+
@ -14,6 +14,9 @@ URL: https://wiki.gnome.org/Design/OS/InitialSetup
Source0: https://download.gnome.org/sources/%{name}/3.37/%{name}-%{version}.tar.xz
Source1: vendor.conf
Patch0: honor-firstboot-disabled.patch
# Fix preselection of input methods
# https://gitlab.gnome.org/GNOME/gnome-initial-setup/-/merge_requests/83
Patch1: 0001-Fix-default-keyboard-layout-input-source-choice-prio.patch
BuildRequires: meson
BuildRequires: gcc
@ -108,6 +111,9 @@ useradd -rM -d /run/gnome-initial-setup/ -s /sbin/nologin %{name} &>/dev/null ||
%{_datadir}/gnome-initial-setup/vendor.conf
%changelog
* Mon May 04 2020 Adam Williamson <awilliam@redhat.com> - 3.37.1-1.1
- Backport MR #83 to fix preselection of input methods
* Thu Apr 30 2020 Kalev Lember <klember@redhat.com> - 3.37.1-1
- Update to 3.37.1