Skip to content

Commit

Permalink
Support multiple key bindings for 'locate-pointer-key' (#638)
Browse files Browse the repository at this point in the history
  • Loading branch information
rcalixte authored Oct 28, 2022
1 parent 48b8252 commit 01f8861
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 15 deletions.
4 changes: 2 additions & 2 deletions data/org.cinnamon.muffin.gschema.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@
</description>
</key>

<key name="locate-pointer-key" type="s">
<default>'Control_L'</default>
<key name="locate-pointer-key" type="as">
<default>['Control_L']</default>
<summary>Modifier to use to locate the pointer</summary>
<description>
This key will initiate the “locate pointer” action.
Expand Down
41 changes: 28 additions & 13 deletions src/core/prefs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 01f8861

Please sign in to comment.