Package: gnome-control-center / 1:48.3-3

kbd-lvl3.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
From: Nathan Pratta Teodosio <nathan.teodosio@canonical.com>
Date: Mon, 2 Sep 2024 14:20:08 +0200
Subject: [PATCH] Add none and layout's default alternate keys (lv3).
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit

The window only offers actual keys for the 3rd level, by default, right alt.

A user might nonetheless want right alt to be just an alt, not a lv3 key.
And so for all other modifiers. So offer the "none" option.

Likewise the user might prefer just not to mess with the keyboard layout —
some layouts do have unusual keys as 3rd level switchers —, so offer the
"layout's default" option.

Closes #918.

Forwarded: https://gitlab.gnome.org/GNOME/gnome-control-center/-/merge_requests/2811
---
 panels/keyboard/cc-keyboard-panel.c    |  7 ++++++-
 panels/keyboard/cc-xkb-modifier-page.c | 10 ++++++----
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/panels/keyboard/cc-keyboard-panel.c b/panels/keyboard/cc-keyboard-panel.c
index d87e9e7..870b9e4 100644
--- a/panels/keyboard/cc-keyboard-panel.c
+++ b/panels/keyboard/cc-keyboard-panel.c
@@ -63,6 +63,11 @@ static const CcXkbModifier LV3_MODIFIER = {
   N_("Alternate Characters Key"),
   N_("The alternate characters key can be used to enter additional characters. These are sometimes printed as a third-option on your keyboard."),
   (CcXkbOption[]){
+    /* Set xkb_option to the prefix, namely "lvl3:", to signify removal of any
+     * lvl3: option from the xkb-options Gsetting.
+     */
+    { NC_("keyboard key", "Default"), "lv3:" },
+    { NC_("keyboard key", "None"),        "lv3:ralt_alt" },
     { NC_("keyboard key", "Left Alt"),    "lv3:lalt_switch" },
     { NC_("keyboard key", "Right Alt"),   "lv3:ralt_switch" },
     { NC_("keyboard key", "Left Super"),  "lv3:lwin_switch" },
@@ -71,7 +76,7 @@ static const CcXkbModifier LV3_MODIFIER = {
     { NC_("keyboard key", "Right Ctrl"),  "lv3:switch" },
     { NULL,                               NULL }
   },
-  "lv3:ralt_switch",
+  "lv3:",
 };
 
 static const CcXkbModifier COMPOSE_MODIFIER = {
diff --git a/panels/keyboard/cc-xkb-modifier-page.c b/panels/keyboard/cc-xkb-modifier-page.c
index ddbf72b..d2a566d 100644
--- a/panels/keyboard/cc-xkb-modifier-page.c
+++ b/panels/keyboard/cc-xkb-modifier-page.c
@@ -117,21 +117,23 @@ set_xkb_option (CcXkbModifierPage *self,
 {
   g_autoptr(GPtrArray) array = NULL;
   g_auto(GStrv) options = NULL;
-  gboolean found;
+  gboolean found, is_prefix;
   guint i;
 
   /* Either replace the existing "<modifier>:" option in the string
-   * array, or add the option at the end
+   * array, or add the option at the end, or, in case the argument is exactly
+   * <modifier>:, remove any instance of <modifier>:
    */
   array = g_ptr_array_new ();
   options = g_settings_get_strv (self->input_source_settings, "xkb-options");
   found = FALSE;
+  is_prefix = g_strcmp0(self->modifier->prefix, xkb_option) == 0;
 
   for (i = 0; options != NULL && options[i] != NULL; i++)
     {
       if (g_str_has_prefix (options[i], self->modifier->prefix))
         {
-          if (!found && xkb_option != NULL)
+          if (!found && xkb_option != NULL && !is_prefix)
             g_ptr_array_add (array, xkb_option);
           found = TRUE;
         }
@@ -141,7 +143,7 @@ set_xkb_option (CcXkbModifierPage *self,
         }
     }
 
-  if (!found && xkb_option != NULL)
+  if (!found && xkb_option != NULL && !is_prefix)
     g_ptr_array_add (array, xkb_option);
 
   g_ptr_array_add (array, NULL);