From 01f88614f08f19f548ccce9a191ab5edd911c05a Mon Sep 17 00:00:00 2001 From: Rick Calixte <10281587+rcalixte@users.noreply.github.com> Date: Fri, 28 Oct 2022 11:24:36 -0400 Subject: [PATCH] Support multiple key bindings for 'locate-pointer-key' (#638) --- data/org.cinnamon.muffin.gschema.xml.in | 4 +-- src/core/prefs.c | 41 +++++++++++++++++-------- 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/data/org.cinnamon.muffin.gschema.xml.in b/data/org.cinnamon.muffin.gschema.xml.in index 22fd81791..5ee5c4edd 100644 --- a/data/org.cinnamon.muffin.gschema.xml.in +++ b/data/org.cinnamon.muffin.gschema.xml.in @@ -179,8 +179,8 @@ - - 'Control_L' + + ['Control_L'] Modifier to use to locate the pointer This key will initiate the “locate pointer” action. diff --git a/src/core/prefs.c b/src/core/prefs.c index 2cf4bca7f..aed5b6d9b 100644 --- a/src/core/prefs.c +++ b/src/core/prefs.c @@ -1719,29 +1719,44 @@ locate_pointer_key_handler (GVariant *value, gpointer *result, gpointer data) { - MetaKeyCombo combo; - const gchar *string_value; + MetaKeyCombo *combo; + const gchar **string_values; + gboolean output; + int i; *result = NULL; /* ignored */ - string_value = g_variant_get_string (value, NULL); + string_values = g_variant_get_strv (value, NULL); + output = TRUE; - if (!string_value || !meta_parse_accelerator (string_value, &combo)) + for (i = 0; string_values && string_values[i]; i++) { - meta_topic (META_DEBUG_KEYBINDINGS, - "Failed to parse value for locate-pointer-key\n"); - return FALSE; - } - combo.modifiers = 0; + combo = g_malloc0 (sizeof(MetaKeyCombo)); - if (locate_pointer_key_combo.keysym != combo.keysym || - locate_pointer_key_combo.keycode != combo.keycode) + if (!meta_parse_accelerator (string_values[i], combo)) + { + meta_topic (META_DEBUG_KEYBINDINGS, + "Failed to parse keybinding value \"%s\" for locate-pointer-key\n", + string_values[i]); + + g_free (combo); + + output = FALSE; + } + + combo->modifiers = 0; + } + + if (locate_pointer_key_combo.keysym != combo->keysym || + locate_pointer_key_combo.keycode != combo->keycode) { - locate_pointer_key_combo = combo; + locate_pointer_key_combo = *combo; queue_changed (META_PREF_KEYBINDINGS); } - return TRUE; + g_free (string_values); + + return output; } static gboolean