[mutter/wip/is-switch-fixes: 1/4] prefs: Fix binding remaining grabbed after clearing all strokes
- From: Rui Matos <rtcm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/is-switch-fixes: 1/4] prefs: Fix binding remaining grabbed after clearing all strokes
- Date: Fri, 5 Apr 2013 15:58:58 +0000 (UTC)
commit f97d8dfb6c753ce143322dc93d283c5a351a5b35
Author: Rui Matos <tiagomatos gmail com>
Date: Sun Mar 31 20:18:54 2013 +0200
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
src/core/prefs.c | 41 ++++++++++++++++++++++++++++++++---------
1 files changed, 32 insertions(+), 9 deletions(-)
---
diff --git a/src/core/prefs.c b/src/core/prefs.c
index 4521264..288a312 100644
--- a/src/core/prefs.c
+++ b/src/core/prefs.c
@@ -1757,10 +1757,11 @@ static gboolean
update_binding (MetaKeyPref *binding,
gchar **strokes)
{
+ GSList *old_bindings, *a, *b;
+ gboolean changed;
unsigned int keysym;
unsigned int keycode;
MetaVirtualModifier mods;
- gboolean changed = FALSE;
MetaKeyCombo *combo;
int i;
@@ -1768,13 +1769,9 @@ update_binding (MetaKeyPref *binding,
"Binding \"%s\" has new GSettings value\n",
binding->name);
- /* Okay, so, we're about to provide a new list of key combos for this
- * action. Delete any pre-existing list.
- */
- g_slist_foreach (binding->bindings, (GFunc) g_free, NULL);
- g_slist_free (binding->bindings);
+ old_bindings = binding->bindings;
binding->bindings = NULL;
-
+
for (i = 0; strokes && strokes[i]; i++)
{
keysym = 0;
@@ -1809,8 +1806,6 @@ update_binding (MetaKeyPref *binding,
* Changing the key in response to a modification could lead to cyclic calls. */
continue;
}
-
- changed = TRUE;
combo = g_malloc0 (sizeof (MetaKeyCombo));
combo->keysym = keysym;
@@ -1825,6 +1820,34 @@ update_binding (MetaKeyPref *binding,
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;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]