state: special case effective group in layout_is_active

Currently, xkb_state_layout_{index,name}_is_active may report multiple
groups as effective, because at looks at base,latched,locked separately.
But there can only be one effective group, which is computed from the
other three. So if XKB_STATE_EFFECTIVE is requested, just compare to the
effective group we have computed.

We also modify mod_{index,name}_is_active similarly, just for symmetry
(there the effective mask is just an OR of the other three so the
current test is correct).

Signed-off-by: Ran Benita <ran234@gmail.com>
master
Ran Benita 2012-09-21 12:45:58 +03:00 committed by Daniel Stone
parent a8b932a032
commit ed78fbcb30
1 changed files with 7 additions and 0 deletions

View File

@ -794,6 +794,9 @@ xkb_state_mod_index_is_active(struct xkb_state *state,
if (idx >= xkb_keymap_num_mods(state->keymap))
return -1;
if (type & XKB_STATE_EFFECTIVE)
return !!(state->mods & (1 << idx));
if (type & XKB_STATE_DEPRESSED)
ret |= (state->base_mods & (1 << idx));
if (type & XKB_STATE_LATCHED)
@ -926,6 +929,10 @@ xkb_state_layout_index_is_active(struct xkb_state *state,
if (idx >= xkb_keymap_num_layouts(state->keymap))
return -1;
/* Can only have one effective group. */
if (type & XKB_STATE_EFFECTIVE)
return state->group == idx;
if (type & XKB_STATE_DEPRESSED)
ret |= (state->base_group == idx);
if (type & XKB_STATE_LATCHED)