From 844eb95c69219228aa059f9c35178901ecd32f6e Mon Sep 17 00:00:00 2001 From: Leo Date: Sat, 30 Sep 2023 07:12:59 +0900 Subject: [PATCH] Don't block `Alt + Shift` when there is only one keyboard layout (#1756) --- data/gala.metainfo.xml.in | 12 ++++++++++++ src/KeyboardManager.vala | 22 +++++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/data/gala.metainfo.xml.in b/data/gala.metainfo.xml.in index 48d912be5..0983fbf75 100644 --- a/data/gala.metainfo.xml.in +++ b/data/gala.metainfo.xml.in @@ -25,6 +25,18 @@ contact_at_elementary.io + + +

Improvements:

+
    +
  • Updated translations
  • +
+
+ + Alt + Shift unnecessarily blocked when there is only one keyboard layout + +
+

Improvements:

diff --git a/src/KeyboardManager.vala b/src/KeyboardManager.vala index d0bc4bd88..f1ddae91f 100644 --- a/src/KeyboardManager.vala +++ b/src/KeyboardManager.vala @@ -5,6 +5,12 @@ */ public class Gala.KeyboardManager : Object { + private const string[] BLOCKED_OPTIONS = { + "grp:alt_caps_toggle", "grp:alt_shift_toggle", "grp:alt_space_toggle", + "grp:shifts_toggle", "grp:caps_toggle", "grp:ctrl_alt_toggle", + "grp:ctrl_shift_toggle", "grp:shift_caps_toggle" + }; + private static KeyboardManager? instance; private static VariantType sources_variant_type; private static GLib.Settings settings; @@ -90,7 +96,21 @@ public class Gala.KeyboardManager : Object { } } - var xkb_options = settings.get_strv ("xkb-options"); + if (layouts.length == 0) { + layouts = { "us" }; + variants = { "" }; + } + + string[] xkb_options = {}; + if (layouts.length == 1) { + foreach (unowned var option in settings.get_strv ("xkb-options")) { + if (!(option in BLOCKED_OPTIONS)) { + xkb_options += option; + } + } + } else { + xkb_options = settings.get_strv ("xkb-options"); + } var layout = string.joinv (",", layouts); var variant = string.joinv (",", variants);