mirror of
https://github.com/brl/mutter.git
synced 2024-12-24 12:02:04 +00:00
keybindings: Have meta_accelerator_parse take a MetaKeyCombo
This commit is contained in:
parent
3beb187cac
commit
13acf9e35d
@ -1407,7 +1407,7 @@ meta_display_grab_accelerator (MetaDisplay *display,
|
||||
MetaKeyCombo combo;
|
||||
MetaKeyDevirtCombo devirt_combo;
|
||||
|
||||
if (!meta_parse_accelerator (accelerator, &combo.keysym, &combo.keycode, &combo.modifiers))
|
||||
if (!meta_parse_accelerator (accelerator, &combo))
|
||||
{
|
||||
meta_topic (META_DEBUG_KEYBINDINGS,
|
||||
"Failed to parse accelerator\n");
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "meta-accel-parse.h"
|
||||
#include "keybindings-private.h"
|
||||
|
||||
#include <xkbcommon/xkbcommon.h>
|
||||
#include <string.h>
|
||||
@ -173,21 +174,16 @@ is_keycode (const gchar *string)
|
||||
|
||||
static gboolean
|
||||
accelerator_parse (const gchar *accelerator,
|
||||
guint *accelerator_key,
|
||||
guint *accelerator_keycode,
|
||||
MetaVirtualModifier *accelerator_mods)
|
||||
MetaKeyCombo *combo)
|
||||
{
|
||||
gboolean error = FALSE;
|
||||
guint keyval, keycode;
|
||||
MetaVirtualModifier mods;
|
||||
gint len;
|
||||
|
||||
if (accelerator_key)
|
||||
*accelerator_key = 0;
|
||||
if (accelerator_keycode)
|
||||
*accelerator_keycode = 0;
|
||||
if (accelerator_mods)
|
||||
*accelerator_mods = 0;
|
||||
combo->keysym = 0;
|
||||
combo->keycode = 0;
|
||||
combo->modifiers = 0;
|
||||
|
||||
if (accelerator == NULL)
|
||||
{
|
||||
@ -330,34 +326,35 @@ out:
|
||||
if (error)
|
||||
return FALSE;
|
||||
|
||||
if (accelerator_key)
|
||||
*accelerator_key = keyval;
|
||||
if (accelerator_keycode)
|
||||
*accelerator_keycode = keycode;
|
||||
if (accelerator_mods)
|
||||
*accelerator_mods = mods;
|
||||
combo->keysym = keyval;
|
||||
combo->keycode = keycode;
|
||||
combo->modifiers = mods;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
meta_parse_accelerator (const char *accel,
|
||||
unsigned int *keysym,
|
||||
unsigned int *keycode,
|
||||
MetaVirtualModifier *mask)
|
||||
meta_parse_accelerator (const char *accel,
|
||||
MetaKeyCombo *combo)
|
||||
{
|
||||
if (!accel[0] || strcmp (accel, "disabled") == 0)
|
||||
return TRUE;
|
||||
|
||||
return accelerator_parse (accel, keysym, keycode, mask);
|
||||
return accelerator_parse (accel, combo);
|
||||
}
|
||||
|
||||
gboolean
|
||||
meta_parse_modifier (const char *accel,
|
||||
MetaVirtualModifier *mask)
|
||||
{
|
||||
MetaKeyCombo combo;
|
||||
|
||||
if (accel == NULL || !accel[0] || strcmp (accel, "disabled") == 0)
|
||||
return TRUE;
|
||||
|
||||
return accelerator_parse (accel, NULL, NULL, mask);
|
||||
if (!accelerator_parse (accel, &combo))
|
||||
return FALSE;
|
||||
|
||||
*mask = combo.modifiers;
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -27,16 +27,16 @@
|
||||
#include <glib.h>
|
||||
#include <meta/common.h>
|
||||
|
||||
typedef struct _MetaKeyCombo MetaKeyCombo;
|
||||
|
||||
/* Not a real key symbol but means "key above the tab key"; this is
|
||||
* used as the default keybinding for cycle_group.
|
||||
* 0x2xxxxxxx is a range not used by GDK or X. the remaining digits are
|
||||
* randomly chosen */
|
||||
#define META_KEY_ABOVE_TAB 0x2f7259c9
|
||||
|
||||
gboolean meta_parse_accelerator (const char *accel,
|
||||
unsigned int *keysym,
|
||||
unsigned int *keycode,
|
||||
MetaVirtualModifier *mask);
|
||||
gboolean meta_parse_accelerator (const char *accel,
|
||||
MetaKeyCombo *combo);
|
||||
gboolean meta_parse_modifier (const char *accel,
|
||||
MetaVirtualModifier *mask);
|
||||
|
||||
|
@ -1672,10 +1672,7 @@ overlay_key_handler (GVariant *value,
|
||||
*result = NULL; /* ignored */
|
||||
string_value = g_variant_get_string (value, NULL);
|
||||
|
||||
if (string_value && meta_parse_accelerator (string_value,
|
||||
&combo.keysym,
|
||||
&combo.keycode,
|
||||
NULL))
|
||||
if (string_value && meta_parse_accelerator (string_value, &combo))
|
||||
;
|
||||
else
|
||||
{
|
||||
@ -1684,6 +1681,8 @@ overlay_key_handler (GVariant *value,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
combo.modifiers = 0;
|
||||
|
||||
if (overlay_key_combo.keysym != combo.keysym ||
|
||||
overlay_key_combo.keycode != combo.keycode)
|
||||
{
|
||||
@ -1916,10 +1915,6 @@ update_binding (MetaKeyPref *binding,
|
||||
{
|
||||
GSList *old_combos, *a, *b;
|
||||
gboolean changed;
|
||||
unsigned int keysym;
|
||||
unsigned int keycode;
|
||||
MetaVirtualModifier mods;
|
||||
MetaKeyCombo *combo;
|
||||
int i;
|
||||
|
||||
meta_topic (META_DEBUG_KEYBINDINGS,
|
||||
@ -1931,31 +1926,25 @@ update_binding (MetaKeyPref *binding,
|
||||
|
||||
for (i = 0; strokes && strokes[i]; i++)
|
||||
{
|
||||
keysym = 0;
|
||||
keycode = 0;
|
||||
mods = 0;
|
||||
MetaKeyCombo *combo;
|
||||
|
||||
if (!meta_parse_accelerator (strokes[i], &keysym, &keycode, &mods))
|
||||
combo = g_malloc0 (sizeof (MetaKeyCombo));
|
||||
|
||||
if (!meta_parse_accelerator (strokes[i], combo))
|
||||
{
|
||||
meta_topic (META_DEBUG_KEYBINDINGS,
|
||||
"Failed to parse new GSettings value\n");
|
||||
meta_warning ("\"%s\" found in configuration database is not a valid value for keybinding \"%s\"\n",
|
||||
strokes[i], binding->name);
|
||||
|
||||
g_free (combo);
|
||||
|
||||
/* Value is kept and will thus be removed next time we save the key.
|
||||
* Changing the key in response to a modification could lead to cyclic calls. */
|
||||
continue;
|
||||
}
|
||||
|
||||
combo = g_malloc0 (sizeof (MetaKeyCombo));
|
||||
combo->keysym = keysym;
|
||||
combo->keycode = keycode;
|
||||
combo->modifiers = mods;
|
||||
binding->combos = g_slist_prepend (binding->combos, combo);
|
||||
|
||||
meta_topic (META_DEBUG_KEYBINDINGS,
|
||||
"New keybinding for \"%s\" is keysym = 0x%x keycode = 0x%x mods = 0x%x\n",
|
||||
binding->name, keysym, keycode, mods);
|
||||
}
|
||||
|
||||
binding->combos = g_slist_reverse (binding->combos);
|
||||
|
Loading…
Reference in New Issue
Block a user