From a1d8110221dacf90c00620f9b3d9ae22c931fcb6 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Thu, 8 Jan 2015 12:08:51 -0800 Subject: [PATCH] keybindings: Merge rebuild_binding_index into reload_combos The two are always called at the same time. --- src/core/keybindings.c | 47 +++++++++++++----------------------------- 1 file changed, 14 insertions(+), 33 deletions(-) diff --git a/src/core/keybindings.c b/src/core/keybindings.c index 2b0ea31c1..db3f04fd9 100644 --- a/src/core/keybindings.c +++ b/src/core/keybindings.c @@ -507,6 +507,17 @@ devirtualize_modifiers (MetaKeyBindingManager *keys, *mask |= Mod5Mask; } +static void +index_binding (MetaKeyBindingManager *keys, + MetaKeyBinding *binding) +{ + guint32 index_key; + + index_key = key_combo_key (&binding->resolved_combo); + g_hash_table_replace (keys->key_bindings_index, + GINT_TO_POINTER (index_key), binding); +} + static void resolve_key_combo (MetaKeyBindingManager *keys, MetaKeyCombo *combo, @@ -529,11 +540,14 @@ binding_reload_combos_foreach (gpointer key, MetaKeyBinding *binding = value; resolve_key_combo (keys, &binding->combo, &binding->resolved_combo); + index_binding (keys, binding); } static void reload_combos (MetaKeyBindingManager *keys) { + g_hash_table_remove_all (keys->key_bindings_index); + determine_keymap_num_levels (keys); resolve_key_combo (keys, @@ -545,35 +559,6 @@ reload_combos (MetaKeyBindingManager *keys) g_hash_table_foreach (keys->key_bindings, binding_reload_combos_foreach, keys); } -static void -index_binding (MetaKeyBindingManager *keys, - MetaKeyBinding *binding) -{ - guint32 index_key; - - index_key = key_combo_key (&binding->resolved_combo); - g_hash_table_replace (keys->key_bindings_index, - GINT_TO_POINTER (index_key), binding); -} - -static void -binding_index_foreach (gpointer key, - gpointer value, - gpointer data) -{ - MetaKeyBindingManager *keys = data; - MetaKeyBinding *binding = value; - - index_binding (keys, binding); -} - -static void -rebuild_binding_index (MetaKeyBindingManager *keys) -{ - g_hash_table_remove_all (keys->key_bindings_index); - g_hash_table_foreach (keys->key_bindings, binding_index_foreach, keys); -} - static void rebuild_binding_table (MetaKeyBindingManager *keys, GList *prefs, @@ -903,8 +888,6 @@ on_keymap_changed (MetaBackend *backend, reload_combos (keys); - rebuild_binding_index (keys); - grab_key_bindings (display); } @@ -1124,7 +1107,6 @@ prefs_changed_callback (MetaPreference pref, rebuild_key_binding_table (keys); rebuild_special_bindings (keys); reload_combos (keys); - rebuild_binding_index (keys); grab_key_bindings (display); break; case META_PREF_MOUSE_BUTTON_MODS: @@ -4069,7 +4051,6 @@ meta_display_init_keys (MetaDisplay *display) rebuild_special_bindings (keys); reload_combos (keys); - rebuild_binding_index (keys); update_window_grab_modifiers (keys);