xkb: refactor keysym compat_init into a separate function
Signed-off-by: Ran Benita <ran234@gmail.com> Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This commit is contained in:
parent
2b540610e4
commit
83b95f643f
@ -74,6 +74,8 @@ static void init_actions(struct xkb_desc *desc);
|
|||||||
static void init_indicators(struct xkb_desc *desc);
|
static void init_indicators(struct xkb_desc *desc);
|
||||||
static void init_autorepeat(struct xkb_desc *desc);
|
static void init_autorepeat(struct xkb_desc *desc);
|
||||||
static int init_compat_for_keycode(struct xkb_desc *desc, KeyCode keycode);
|
static int init_compat_for_keycode(struct xkb_desc *desc, KeyCode keycode);
|
||||||
|
static int init_compat_for_keysym(struct xkb_desc *desc, KeyCode keycode,
|
||||||
|
uint8_t group, uint16_t level);
|
||||||
static int allocate_key_acts(struct xkb_desc *desc, uint8_t keycode);
|
static int allocate_key_acts(struct xkb_desc *desc, uint8_t keycode);
|
||||||
static struct xkb_sym_interpret *find_sym_interpret(struct xkb_desc *desc,
|
static struct xkb_sym_interpret *find_sym_interpret(struct xkb_desc *desc,
|
||||||
uint32_t sym, uint16_t level, uint8_t key_modmap);
|
uint32_t sym, uint16_t level, uint8_t key_modmap);
|
||||||
@ -167,18 +169,12 @@ static int init_compat_for_keycode(struct xkb_desc *desc, KeyCode keycode)
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
int i, bit;
|
int i, bit;
|
||||||
bool allocated;
|
|
||||||
|
|
||||||
uint32_t sym;
|
|
||||||
uint8_t group;
|
uint8_t group;
|
||||||
uint16_t level;
|
uint16_t level;
|
||||||
int num_groups;
|
int num_groups;
|
||||||
int num_levels;
|
int num_levels;
|
||||||
|
|
||||||
struct xkb_sym_interpret *si;
|
|
||||||
union xkb_action *action;
|
|
||||||
uint8_t key_modmap;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* It's possible that someone had set some actions for the keycode
|
* It's possible that someone had set some actions for the keycode
|
||||||
* through the symbols file, and so we shouldn't override with the
|
* through the symbols file, and so we shouldn't override with the
|
||||||
@ -188,7 +184,6 @@ static int init_compat_for_keycode(struct xkb_desc *desc, KeyCode keycode)
|
|||||||
if (XkbKeyHasActions(desc, keycode))
|
if (XkbKeyHasActions(desc, keycode))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
key_modmap = desc->map->modmap[keycode];
|
|
||||||
num_groups = XkbKeyNumGroups(desc, keycode);
|
num_groups = XkbKeyNumGroups(desc, keycode);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -196,35 +191,14 @@ static int init_compat_for_keycode(struct xkb_desc *desc, KeyCode keycode)
|
|||||||
* which is used in some symbol interpretations.
|
* which is used in some symbol interpretations.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
allocated = false;
|
|
||||||
for (group=0, i=0; group < num_groups; group++) {
|
for (group=0, i=0; group < num_groups; group++) {
|
||||||
num_levels = XkbKeyGroupWidth(desc, keycode, group);
|
num_levels = XkbKeyGroupWidth(desc, keycode, group);
|
||||||
|
|
||||||
for (level=0; level < num_levels; level++) {
|
for (level=0; level < num_levels; level++) {
|
||||||
sym = XkbKeySymEntry(desc, keycode, level, group);
|
ret = init_compat_for_keysym(desc, keycode,
|
||||||
si = find_sym_interpret(desc, sym, level, key_modmap);
|
group, level);
|
||||||
|
|
||||||
if (!si)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/* Set the key action mapping. */
|
|
||||||
if (si->act.type != XkbSA_NoAction) {
|
|
||||||
if (!allocated) {
|
|
||||||
ret = allocate_key_acts(desc, keycode);
|
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
allocated = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
action = XkbKeyActionEntry(desc, keycode,
|
|
||||||
level, group);
|
|
||||||
*action = (union xkb_action)si->act;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set the key virtual modifier mapping. */
|
|
||||||
if (si->virtual_mod != XkbNoModifier)
|
|
||||||
desc->server->vmodmap[keycode] |=
|
|
||||||
0x01 << si->virtual_mod;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,6 +214,39 @@ static int init_compat_for_keycode(struct xkb_desc *desc, KeyCode keycode)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int init_compat_for_keysym(struct xkb_desc *desc, KeyCode keycode,
|
||||||
|
uint8_t group, uint16_t level)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
uint8_t key_modmap;
|
||||||
|
uint32_t sym;
|
||||||
|
struct xkb_sym_interpret *si;
|
||||||
|
union xkb_action *action;
|
||||||
|
|
||||||
|
key_modmap = desc->map->modmap[keycode];
|
||||||
|
sym = XkbKeySymEntry(desc, keycode, level, group);
|
||||||
|
si = find_sym_interpret(desc, sym, level, key_modmap);
|
||||||
|
|
||||||
|
if (!si)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* Set the key action mapping. */
|
||||||
|
if (si->act.type != XkbSA_NoAction) {
|
||||||
|
ret = allocate_key_acts(desc, keycode);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
action = XkbKeyActionEntry(desc, keycode, level, group);
|
||||||
|
*action = (union xkb_action)si->act;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set the key virtual modifier mapping. */
|
||||||
|
if (si->virtual_mod != XkbNoModifier)
|
||||||
|
desc->server->vmodmap[keycode] |= 0x01 << si->virtual_mod;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Allocate slots for a keycode in the key-action mapping array. xkbcommon
|
* Allocate slots for a keycode in the key-action mapping array. xkbcommon
|
||||||
* doesn't do this by itself for actions from compat (that is almost all of
|
* doesn't do this by itself for actions from compat (that is almost all of
|
||||||
|
Loading…
x
Reference in New Issue
Block a user