Make the effective mod mask calculation available to other files
We will want to use that function in state.c as well. Signed-off-by: Ran Benita <ran234@gmail.com>master
parent
80ae8e61ff
commit
99184f1614
|
@ -461,6 +461,9 @@ XkbWrapGroupIntoRange(int32_t group,
|
||||||
enum xkb_range_exceed_type out_of_range_group_action,
|
enum xkb_range_exceed_type out_of_range_group_action,
|
||||||
xkb_layout_index_t out_of_range_group_number);
|
xkb_layout_index_t out_of_range_group_number);
|
||||||
|
|
||||||
|
xkb_mod_mask_t
|
||||||
|
mod_mask_get_effective(struct xkb_keymap *keymap, xkb_mod_mask_t mods);
|
||||||
|
|
||||||
struct xkb_keymap_format_ops {
|
struct xkb_keymap_format_ops {
|
||||||
bool (*keymap_new_from_names)(struct xkb_keymap *keymap,
|
bool (*keymap_new_from_names)(struct xkb_keymap *keymap,
|
||||||
const struct xkb_rule_names *names);
|
const struct xkb_rule_names *names);
|
||||||
|
|
22
src/state.c
22
src/state.c
|
@ -1071,6 +1071,28 @@ xkb_state_serialize_layout(struct xkb_state *state,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a modifier mask and returns the resolved effective mask; this
|
||||||
|
* is needed because some modifiers can also map to other modifiers, e.g.
|
||||||
|
* the "NumLock" modifier usually also sets the "Mod2" modifier.
|
||||||
|
*/
|
||||||
|
xkb_mod_mask_t
|
||||||
|
mod_mask_get_effective(struct xkb_keymap *keymap, xkb_mod_mask_t mods)
|
||||||
|
{
|
||||||
|
const struct xkb_mod *mod;
|
||||||
|
xkb_mod_index_t i;
|
||||||
|
xkb_mod_mask_t mask;
|
||||||
|
|
||||||
|
/* The effective mask is only real mods for now. */
|
||||||
|
mask = mods & MOD_REAL_MASK_ALL;
|
||||||
|
|
||||||
|
xkb_mods_enumerate(i, mod, &keymap->mods)
|
||||||
|
if (mods & (1u << i))
|
||||||
|
mask |= mod->mapping;
|
||||||
|
|
||||||
|
return mask;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns 1 if the given modifier is active with the specified type(s), 0 if
|
* Returns 1 if the given modifier is active with the specified type(s), 0 if
|
||||||
* not, or -1 if the modifier is invalid.
|
* not, or -1 if the modifier is invalid.
|
||||||
|
|
|
@ -32,15 +32,7 @@
|
||||||
static void
|
static void
|
||||||
ComputeEffectiveMask(struct xkb_keymap *keymap, struct xkb_mods *mods)
|
ComputeEffectiveMask(struct xkb_keymap *keymap, struct xkb_mods *mods)
|
||||||
{
|
{
|
||||||
const struct xkb_mod *mod;
|
mods->mask = mod_mask_get_effective(keymap, mods->mods);
|
||||||
xkb_mod_index_t i;
|
|
||||||
|
|
||||||
/* The effective mask is only real mods for now. */
|
|
||||||
mods->mask = mods->mods & MOD_REAL_MASK_ALL;
|
|
||||||
|
|
||||||
xkb_mods_enumerate(i, mod, &keymap->mods)
|
|
||||||
if (mods->mods & (1u << i))
|
|
||||||
mods->mask |= mod->mapping;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in New Issue