prefs: Fix binding remaining grabbed after clearing all strokes

If a binding is updated with a clear set of strokes (effectively
disabling it) we aren't signaling that the binding changed and thus
the previous strokes will continue to be grabbed.

This fixes that and tries to do a better effort at checking if the
binding changed or not.

https://bugzilla.gnome.org/show_bug.cgi?id=697000
This commit is contained in:
Rui Matos 2013-03-31 20:18:54 +02:00
parent 5615e36112
commit 1627044c39

View File

@ -1758,10 +1758,11 @@ static gboolean
update_binding (MetaKeyPref *binding, update_binding (MetaKeyPref *binding,
gchar **strokes) gchar **strokes)
{ {
GSList *old_bindings, *a, *b;
gboolean changed;
unsigned int keysym; unsigned int keysym;
unsigned int keycode; unsigned int keycode;
MetaVirtualModifier mods; MetaVirtualModifier mods;
gboolean changed = FALSE;
MetaKeyCombo *combo; MetaKeyCombo *combo;
int i; int i;
@ -1769,11 +1770,7 @@ update_binding (MetaKeyPref *binding,
"Binding \"%s\" has new GSettings value\n", "Binding \"%s\" has new GSettings value\n",
binding->name); binding->name);
/* Okay, so, we're about to provide a new list of key combos for this old_bindings = binding->bindings;
* action. Delete any pre-existing list.
*/
g_slist_foreach (binding->bindings, (GFunc) g_free, NULL);
g_slist_free (binding->bindings);
binding->bindings = NULL; binding->bindings = NULL;
for (i = 0; strokes && strokes[i]; i++) for (i = 0; strokes && strokes[i]; i++)
@ -1811,8 +1808,6 @@ update_binding (MetaKeyPref *binding,
continue; continue;
} }
changed = TRUE;
combo = g_malloc0 (sizeof (MetaKeyCombo)); combo = g_malloc0 (sizeof (MetaKeyCombo));
combo->keysym = keysym; combo->keysym = keysym;
combo->keycode = keycode; combo->keycode = keycode;
@ -1826,6 +1821,34 @@ update_binding (MetaKeyPref *binding,
binding->bindings = g_slist_reverse (binding->bindings); binding->bindings = g_slist_reverse (binding->bindings);
a = old_bindings;
b = binding->bindings;
while (TRUE)
{
if ((!a && b) || (a && !b))
{
changed = TRUE;
break;
}
else if (!a && !b)
{
changed = FALSE;
break;
}
else if (memcmp (a->data, b->data, sizeof (MetaKeyCombo)) != 0)
{
changed = TRUE;
break;
}
else
{
a = a->next;
b = b->next;
}
}
g_slist_free_full (old_bindings, g_free);
return changed; return changed;
} }