state: don't use xkb_state_serialize_* internally
authorRan Benita <ran234@gmail.com>
Fri, 26 Oct 2012 14:12:28 +0000 (16:12 +0200)
committerRan Benita <ran234@gmail.com>
Fri, 26 Oct 2012 14:12:28 +0000 (16:12 +0200)
The code in these cases is clearer when done directly.

Signed-off-by: Ran Benita <ran234@gmail.com>
src/state.c

index ad8c20368382228814478b7f6d0947629a04baa8..2c126baa1b195f23a8dcbc520ed6975a29fca742 100644 (file)
@@ -118,14 +118,10 @@ static const struct xkb_kt_map_entry *
 get_entry_for_key_state(struct xkb_state *state, const struct xkb_key *key,
                         xkb_layout_index_t group)
 {
-    const struct xkb_key_type *type;
-    xkb_mod_mask_t active_mods;
+    const struct xkb_key_type *type = key->groups[group].type;
+    xkb_mod_mask_t active_mods = state->cur.mods & type->mods.mask;
     unsigned int i;
 
-    type = key->groups[group].type;
-    active_mods = xkb_state_serialize_mods(state, XKB_STATE_MODS_EFFECTIVE);
-    active_mods &= type->mods.mask;
-
     for (i = 0; i < type->num_entries; i++)
         if (type->map[i].mods.mask == active_mods)
             return &type->map[i];
@@ -199,14 +195,12 @@ wrap_group_into_range(int32_t group,
 XKB_EXPORT xkb_layout_index_t
 xkb_state_key_get_layout(struct xkb_state *state, xkb_keycode_t kc)
 {
-    xkb_layout_index_t group =
-        xkb_state_serialize_layout(state, XKB_STATE_LAYOUT_EFFECTIVE);
     const struct xkb_key *key = XkbKey(state->keymap, kc);
 
     if (!key)
         return XKB_LAYOUT_INVALID;
 
-    return wrap_group_into_range(group, key->num_groups,
+    return wrap_group_into_range(state->cur.group, key->num_groups,
                                  key->out_of_range_group_action,
                                  key->out_of_range_group_number);
 }