1
From f3b6e35bba6b6dcef63d520ecf08971040fa41bf Mon Sep 17 00:00:00 2001
2
From: Rui Matos <tiagomatos@gmail.com>
3
Date: Mon, 30 Sep 2013 13:16:49 +0200
4
Subject: [PATCH] keyboard: Don't set the XKB group switching option when not
7
We might set up different layouts in different groups - see
8
replace_layout_and_variant(). But we don't want the X server group
9
switching feature to actually switch them. Regularly, if we have at
10
least two input sources, gnome-shell will tell us to switch input
11
source at that point so we fix that automatically. But when there's
12
only one source, gnome-shell short circuits as an optimization and
13
doesn't call us so we can't set the group switching XKB option in the
14
first place otherwise the X server's switch will take effect and we
15
get a broken configuration.
17
https://bugzilla.gnome.org/show_bug.cgi?id=709085
19
plugins/keyboard/gsd-keyboard-manager.c | 56 +++++++++++++++++++++++++++------
20
1 file changed, 47 insertions(+), 9 deletions(-)
22
diff --git a/plugins/keyboard/gsd-keyboard-manager.c b/plugins/keyboard/gsd-keyboard-manager.c
23
index 10c2a66..57060e9 100644
24
--- a/plugins/keyboard/gsd-keyboard-manager.c
25
+++ b/plugins/keyboard/gsd-keyboard-manager.c
26
@@ -861,29 +861,64 @@ append_options (gchar **a,
30
-add_xkb_options (GsdKeyboardManager *manager,
31
- XkbRF_VarDefsRec *xkb_var_defs,
32
- gchar **extra_options)
33
+strip_xkb_option (gchar **options,
34
+ const gchar *prefix)
37
+ gchar **p = options;
43
+ if (g_str_has_prefix (*p, prefix)) {
44
+ last = g_strv_length (options) - 1;
47
+ options[last] = NULL;
54
+prepare_xkb_options (GsdKeyboardManager *manager,
56
+ gchar **extra_options)
59
gchar **settings_options;
62
settings_options = g_settings_get_strv (manager->priv->input_sources_settings,
63
KEY_KEYBOARD_OPTIONS);
64
options = append_options (settings_options, extra_options);
65
g_strfreev (settings_options);
67
- free (xkb_var_defs->options);
68
- xkb_var_defs->options = build_xkb_options_string (options);
70
+ /* We might set up different layouts in different groups - see
71
+ * replace_layout_and_variant(). But we don't want the X
72
+ * server group switching feature to actually switch
73
+ * them. Regularly, if we have at least two input sources,
74
+ * gnome-shell will tell us to switch input source at that
75
+ * point so we fix that automatically. But when there's only
76
+ * one source, gnome-shell short circuits as an optimization
77
+ * and doesn't call us so we can't set the group switching XKB
78
+ * option in the first place otherwise the X server's switch
79
+ * will take effect and we get a broken configuration. */
81
+ strip_xkb_option (options, "grp:");
83
+ options_str = build_xkb_options_string (options);
90
apply_xkb_settings (GsdKeyboardManager *manager,
96
XkbRF_RulesRec *xkb_rules;
97
XkbRF_VarDefsRec *xkb_var_defs;
98
@@ -891,7 +926,9 @@ apply_xkb_settings (GsdKeyboardManager *manager,
100
gnome_xkb_info_get_var_defs (&rules_file_path, &xkb_var_defs);
102
- add_xkb_options (manager, xkb_var_defs, options);
103
+ free (xkb_var_defs->options);
104
+ xkb_var_defs->options = options;
106
replace_layout_and_variant (manager, xkb_var_defs, layout, variant);
108
gdk_error_trap_push ();
109
@@ -1003,7 +1040,8 @@ apply_input_sources_settings (GSettings *settings,
113
- apply_xkb_settings (manager, layout, variant, options);
114
+ apply_xkb_settings (manager, layout, variant,
115
+ prepare_xkb_options (manager, n_sources, options));
116
maybe_return_from_set_input_source (manager);
117
g_variant_unref (sources);