kbproto unentanglement: Xkb{Wrap,Clamp,Redirect}IntoRange

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
master
Daniel Stone 2012-09-10 20:44:52 +01:00
parent 461f8a7697
commit 32bf405376
4 changed files with 25 additions and 17 deletions

View File

@ -681,14 +681,17 @@ write_symbols(struct xkb_keymap *keymap, struct buf *buf)
} }
switch (key->out_of_range_group_action) { switch (key->out_of_range_group_action) {
case XkbClampIntoRange: case RANGE_SATURATE:
write_buf(buf, "\n\t\t\tgroupsClamp,"); write_buf(buf, "\n\t\t\tgroupsClamp,");
break; break;
case XkbRedirectIntoRange: case RANGE_REDIRECT:
write_buf(buf, "\n\t\t\tgroupsRedirect= Group%u,", write_buf(buf, "\n\t\t\tgroupsRedirect= Group%u,",
key->out_of_range_group_number + 1); key->out_of_range_group_number + 1);
break; break;
default:
break;
} }
if (key->explicit & XkbExplicitInterpretMask) if (key->explicit & XkbExplicitInterpretMask)

View File

@ -335,17 +335,17 @@ xkb_key_get_group(struct xkb_state *state, xkb_keycode_t kc)
return ret; return ret;
switch (key->out_of_range_group_action) { switch (key->out_of_range_group_action) {
case XkbRedirectIntoRange: case RANGE_REDIRECT:
ret = key->out_of_range_group_number; ret = key->out_of_range_group_number;
if (ret >= key->num_groups) if (ret >= key->num_groups)
ret = 0; ret = 0;
break; break;
case XkbClampIntoRange: case RANGE_SATURATE:
ret = key->num_groups - 1; ret = key->num_groups - 1;
break; break;
case XkbWrapIntoRange: case RANGE_WRAP:
default: default:
ret %= key->num_groups; ret %= key->num_groups;
break; break;

View File

@ -298,6 +298,13 @@ struct xkb_controls {
unsigned int axt_ctrls_values; unsigned int axt_ctrls_values;
}; };
/* Such an awkward name. Oh well. */
enum xkb_range_exceed_type {
RANGE_SATURATE,
RANGE_WRAP,
RANGE_REDIRECT,
};
struct xkb_key { struct xkb_key {
char name[XKB_KEY_NAME_LENGTH]; char name[XKB_KEY_NAME_LENGTH];
@ -316,7 +323,7 @@ struct xkb_key {
/* How many levels the largest group has. */ /* How many levels the largest group has. */
xkb_level_index_t width; xkb_level_index_t width;
uint8_t out_of_range_group_action; enum xkb_range_exceed_type out_of_range_group_action;
xkb_group_index_t out_of_range_group_number; xkb_group_index_t out_of_range_group_number;
/* per level/group index into 'syms' */ /* per level/group index into 'syms' */

View File

@ -85,7 +85,7 @@ typedef struct _KeyInfo {
xkb_mod_mask_t vmodmap; xkb_mod_mask_t vmodmap;
xkb_atom_t dfltType; xkb_atom_t dfltType;
uint8_t out_of_range_group_action; enum xkb_range_exceed_type out_of_range_group_action;
xkb_group_index_t out_of_range_group_number; xkb_group_index_t out_of_range_group_number;
} KeyInfo; } KeyInfo;
@ -116,7 +116,7 @@ InitKeyInfo(KeyInfo *keyi, unsigned file_id)
keyi->dfltType = XKB_ATOM_NONE; keyi->dfltType = XKB_ATOM_NONE;
keyi->vmodmap = 0; keyi->vmodmap = 0;
keyi->repeat = KEY_REPEAT_UNDEFINED; keyi->repeat = KEY_REPEAT_UNDEFINED;
keyi->out_of_range_group_action = 0; keyi->out_of_range_group_action = RANGE_WRAP;
keyi->out_of_range_group_number = 0; keyi->out_of_range_group_number = 0;
} }
@ -1128,9 +1128,9 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
} }
if (set) if (set)
keyi->out_of_range_group_action = XkbWrapIntoRange; keyi->out_of_range_group_action = RANGE_WRAP;
else else
keyi->out_of_range_group_action = XkbClampIntoRange; keyi->out_of_range_group_action = RANGE_SATURATE;
keyi->defined |= KEY_FIELD_GROUPINFO; keyi->defined |= KEY_FIELD_GROUPINFO;
} }
@ -1147,9 +1147,9 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
} }
if (set) if (set)
keyi->out_of_range_group_action = XkbClampIntoRange; keyi->out_of_range_group_action = RANGE_SATURATE;
else else
keyi->out_of_range_group_action = XkbWrapIntoRange; keyi->out_of_range_group_action = RANGE_WRAP;
keyi->defined |= KEY_FIELD_GROUPINFO; keyi->defined |= KEY_FIELD_GROUPINFO;
} }
@ -1165,7 +1165,7 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
return false; return false;
} }
keyi->out_of_range_group_action = XkbRedirectIntoRange; keyi->out_of_range_group_action = RANGE_REDIRECT;
keyi->out_of_range_group_number = grp - 1; keyi->out_of_range_group_number = grp - 1;
keyi->defined |= KEY_FIELD_GROUPINFO; keyi->defined |= KEY_FIELD_GROUPINFO;
} }
@ -1805,10 +1805,8 @@ CopySymbolsDef(SymbolsInfo *info, KeyInfo *keyi,
key->explicit |= XkbExplicitInterpretMask; key->explicit |= XkbExplicitInterpretMask;
} }
if (keyi->defined & KEY_FIELD_GROUPINFO) {
key->out_of_range_group_number = keyi->out_of_range_group_number; key->out_of_range_group_number = keyi->out_of_range_group_number;
key->out_of_range_group_action = keyi->out_of_range_group_action; key->out_of_range_group_action = keyi->out_of_range_group_action;
}
for (i = 0; i < nGroups; i++) { for (i = 0; i < nGroups; i++) {
/* assign kt_index[i] to the index of the type in map->types. /* assign kt_index[i] to the index of the type in map->types.