Skip to content

Commit 01f8861

Browse files
authored
Support multiple key bindings for 'locate-pointer-key' (#638)
1 parent 48b8252 commit 01f8861

File tree

2 files changed

+30
-15
lines changed

2 files changed

+30
-15
lines changed

data/org.cinnamon.muffin.gschema.xml.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@
179179
</description>
180180
</key>
181181

182-
<key name="locate-pointer-key" type="s">
183-
<default>'Control_L'</default>
182+
<key name="locate-pointer-key" type="as">
183+
<default>['Control_L']</default>
184184
<summary>Modifier to use to locate the pointer</summary>
185185
<description>
186186
This key will initiate the “locate pointer” action.

src/core/prefs.c

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1719,29 +1719,44 @@ locate_pointer_key_handler (GVariant *value,
17191719
gpointer *result,
17201720
gpointer data)
17211721
{
1722-
MetaKeyCombo combo;
1723-
const gchar *string_value;
1722+
MetaKeyCombo *combo;
1723+
const gchar **string_values;
1724+
gboolean output;
1725+
int i;
17241726

17251727
*result = NULL; /* ignored */
1726-
string_value = g_variant_get_string (value, NULL);
1728+
string_values = g_variant_get_strv (value, NULL);
1729+
output = TRUE;
17271730

1728-
if (!string_value || !meta_parse_accelerator (string_value, &combo))
1731+
for (i = 0; string_values && string_values[i]; i++)
17291732
{
1730-
meta_topic (META_DEBUG_KEYBINDINGS,
1731-
"Failed to parse value for locate-pointer-key\n");
1732-
return FALSE;
1733-
}
17341733

1735-
combo.modifiers = 0;
1734+
combo = g_malloc0 (sizeof(MetaKeyCombo));
17361735

1737-
if (locate_pointer_key_combo.keysym != combo.keysym ||
1738-
locate_pointer_key_combo.keycode != combo.keycode)
1736+
if (!meta_parse_accelerator (string_values[i], combo))
1737+
{
1738+
meta_topic (META_DEBUG_KEYBINDINGS,
1739+
"Failed to parse keybinding value \"%s\" for locate-pointer-key\n",
1740+
string_values[i]);
1741+
1742+
g_free (combo);
1743+
1744+
output = FALSE;
1745+
}
1746+
1747+
combo->modifiers = 0;
1748+
}
1749+
1750+
if (locate_pointer_key_combo.keysym != combo->keysym ||
1751+
locate_pointer_key_combo.keycode != combo->keycode)
17391752
{
1740-
locate_pointer_key_combo = combo;
1753+
locate_pointer_key_combo = *combo;
17411754
queue_changed (META_PREF_KEYBINDINGS);
17421755
}
17431756

1744-
return TRUE;
1757+
g_free (string_values);
1758+
1759+
return output;
17451760
}
17461761

17471762
static gboolean

0 commit comments

Comments
 (0)