~attente/gnome-settings-daemon/lp1218322

« back to all changes in this revision

Viewing changes to debian/patches/git_keyboard-Don-t-set-the-XKB-group-switching-option.patch

  • Committer: William Hua
  • Date: 2013-10-21 19:05:24 UTC
  • Revision ID: william.hua@canonical.com-20131021190524-i8kwo5z5u6d2wapi
Add git patch for not setting the XKB group switching option.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
5
 needed
 
6
 
 
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.
 
16
 
 
17
https://bugzilla.gnome.org/show_bug.cgi?id=709085
 
18
---
 
19
 plugins/keyboard/gsd-keyboard-manager.c | 56 +++++++++++++++++++++++++++------
 
20
 1 file changed, 47 insertions(+), 9 deletions(-)
 
21
 
 
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,
 
27
 }
 
28
 
 
29
 static void
 
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)
 
35
+{
 
36
+        guint last;
 
37
+        gchar **p = options;
 
38
+
 
39
+        if (!p)
 
40
+                return;
 
41
+
 
42
+        while (*p) {
 
43
+                if (g_str_has_prefix (*p, prefix)) {
 
44
+                        last = g_strv_length (options) - 1;
 
45
+                        g_free (*p);
 
46
+                        *p = options[last];
 
47
+                        options[last] = NULL;
 
48
+                }
 
49
+                p += 1;
 
50
+        }
 
51
+}
 
52
+
 
53
+static gchar *
 
54
+prepare_xkb_options (GsdKeyboardManager *manager,
 
55
+                     guint               n_sources,
 
56
+                     gchar             **extra_options)
 
57
 {
 
58
         gchar **options;
 
59
         gchar **settings_options;
 
60
+        gchar  *options_str;
 
61
 
 
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);
 
66
 
 
67
-        free (xkb_var_defs->options);
 
68
-        xkb_var_defs->options = build_xkb_options_string (options);
 
69
-
 
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. */
 
80
+        if (n_sources < 2)
 
81
+                strip_xkb_option (options, "grp:");
 
82
+
 
83
+        options_str = build_xkb_options_string (options);
 
84
         g_strfreev (options);
 
85
+
 
86
+        return options_str;
 
87
 }
 
88
 
 
89
 static void
 
90
 apply_xkb_settings (GsdKeyboardManager *manager,
 
91
                     const gchar        *layout,
 
92
                     const gchar        *variant,
 
93
-                    gchar             **options)
 
94
+                    gchar              *options)
 
95
 {
 
96
         XkbRF_RulesRec *xkb_rules;
 
97
         XkbRF_VarDefsRec *xkb_var_defs;
 
98
@@ -891,7 +926,9 @@ apply_xkb_settings (GsdKeyboardManager *manager,
 
99
 
 
100
         gnome_xkb_info_get_var_defs (&rules_file_path, &xkb_var_defs);
 
101
 
 
102
-        add_xkb_options (manager, xkb_var_defs, options);
 
103
+        free (xkb_var_defs->options);
 
104
+        xkb_var_defs->options = options;
 
105
+
 
106
         replace_layout_and_variant (manager, xkb_var_defs, layout, variant);
 
107
 
 
108
         gdk_error_trap_push ();
 
109
@@ -1003,7 +1040,8 @@ apply_input_sources_settings (GSettings          *settings,
 
110
         }
 
111
 
 
112
  exit:
 
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);
 
118
         g_free (layout);
 
119
-- 
 
120
1.8.3.2
 
121