XKB_EXPORT xkb_group_index_t
xkb_key_num_groups(struct xkb_keymap *keymap, xkb_keycode_t kc)
{
- if (XkbKeycodeInRange(keymap, kc))
- return XkbKey(keymap, kc)->num_groups;
- return 0;
+ if (!XkbKeycodeInRange(keymap, kc))
+ return 0;
+
+ return XkbKey(keymap, kc)->num_groups;
}
/**
{
struct xkb_kt_map_entry *entry;
- if (!XkbKeycodeInRange(xkb_state_get_map(state), kc))
- return XKB_LEVEL_INVALID;
-
- entry = get_entry_for_key_state(state, kc);
-
/* If we don't find an explicit match the default is 0. */
+ entry = get_entry_for_key_state(state, kc);
if (!entry)
return 0;
xkb_key_get_group(struct xkb_state *state, xkb_keycode_t kc)
{
struct xkb_keymap *keymap = xkb_state_get_map(state);
+ struct xkb_key *key;
xkb_group_index_t ret = xkb_state_serialize_group(state,
XKB_STATE_EFFECTIVE);
- struct xkb_key *key;
-
- if (!XkbKeycodeInRange(keymap, kc))
- return XKB_GROUP_INVALID;
key = XkbKey(keymap, kc);
if (key->num_groups == 0)
xkb_group_index_t group;
xkb_level_index_t level;
- if (!state || !XkbKeycodeInRange(keymap, kc))
+ if (!XkbKeycodeInRange(keymap, kc))
return -1;
key = XkbKey(keymap, kc);
{
if (!XkbKeycodeInRange(keymap, kc))
return 0;
+
return XkbKey(keymap, kc)->repeats;
}
{
xkb_group_index_t group;
xkb_level_index_t level;
- struct xkb_key *key = NULL;
+ struct xkb_key *key;
- if (XkbKeycodeInRange(state->keymap, kc))
- key = XkbKey(state->keymap, kc);
+ key = XkbKey(state->keymap, kc);
- if (!key || !key->actions)
+ if (!key->actions)
return &fake;
group = xkb_key_get_group(state, kc);
{
struct xkb_state *ret;
- if (!keymap)
- return NULL;
-
ret = calloc(sizeof(*ret), 1);
if (!ret)
return NULL;
XKB_EXPORT void
xkb_state_unref(struct xkb_state *state)
{
- state->refcnt--;
- assert(state->refcnt >= 0);
- if (state->refcnt > 0)
+ if (--state->refcnt > 0)
return;
xkb_map_unref(state->keymap);
xkb_mod_index_t i;
xkb_mod_mask_t bit;
+ if (!XkbKeycodeInRange(state->keymap, kc))
+ return;
+
state->set_mods = 0;
state->clear_mods = 0;