summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRan Benita <ran234@gmail.com>2012-11-11 16:06:54 +0200
committerRan Benita <ran234@gmail.com>2012-11-11 16:09:05 +0200
commit7372c9f181b0a6079aaf885be0bc4582d9615da4 (patch)
treeae9e818c2c2f9203a39af4b52fe5e8c65ffdd6cf /src
parent60bd92021b63ecd3f8396704c841a0bf0fdab72b (diff)
downloadlibxkbcommon-7372c9f181b0a6079aaf885be0bc4582d9615da4.tar.gz
libxkbcommon-7372c9f181b0a6079aaf885be0bc4582d9615da4.tar.bz2
libxkbcommon-7372c9f181b0a6079aaf885be0bc4582d9615da4.zip
state: don't keep the previous state components in xkb_state
There is really no need to keep this in the struct, we can just allocate it on the stack when we need to. Don't know why I did it this way. Signed-off-by: Ran Benita <ran234@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/state.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/state.c b/src/state.c
index 19b372a..1b18f21 100644
--- a/src/state.c
+++ b/src/state.c
@@ -89,10 +89,10 @@ struct state_components {
struct xkb_state {
/*
- * Before updating the state, we keep a copy. This allows us to report
- * which components of the state have changed.
+ * Before updating the state, we keep a copy of just this struct. This
+ * allows us to report which components of the state have changed.
*/
- struct state_components cur, prev;
+ struct state_components cur;
/*
* At each event, we accumulate all the needed modifications to the base
@@ -703,12 +703,13 @@ xkb_state_update_key(struct xkb_state *state, xkb_keycode_t kc,
{
xkb_mod_index_t i;
xkb_mod_mask_t bit;
+ struct state_components prev_components;
const struct xkb_key *key = XkbKey(state->keymap, kc);
if (!key)
return 0;
- state->prev = state->cur;
+ prev_components = state->cur;
state->set_mods = 0;
state->clear_mods = 0;
@@ -736,7 +737,7 @@ xkb_state_update_key(struct xkb_state *state, xkb_keycode_t kc,
xkb_state_update_derived(state);
- return get_state_component_changes(&state->prev, &state->cur);
+ return get_state_component_changes(&prev_components, &state->cur);
}
/**
@@ -755,10 +756,11 @@ xkb_state_update_mask(struct xkb_state *state,
xkb_layout_index_t latched_group,
xkb_layout_index_t locked_group)
{
+ struct state_components prev_components;
xkb_mod_index_t num_mods;
xkb_mod_index_t idx;
- state->prev = state->cur;
+ prev_components = state->cur;
state->cur.base_mods = 0;
state->cur.latched_mods = 0;
@@ -781,7 +783,7 @@ xkb_state_update_mask(struct xkb_state *state,
xkb_state_update_derived(state);
- return get_state_component_changes(&state->prev, &state->cur);
+ return get_state_component_changes(&prev_components, &state->cur);
}
/**