struct xkb_key *key, xkb_group_index_t group)
{
const xkb_keysym_t *syms;
- int num_syms, level;
+ int num_syms;
+ xkb_level_index_t level;
#define OUT_BUF_LEN 128
char out_buf[OUT_BUF_LEN];
/**
* Returns the level to use for the given key and state, or -1 if invalid.
*/
-unsigned int
+xkb_level_index_t
xkb_key_get_level(struct xkb_state *state, xkb_keycode_t kc,
xkb_group_index_t group)
{
struct xkb_keymap *keymap = xkb_state_get_map(state);
struct xkb_key_type *type;
struct xkb_kt_map_entry *entry;
- unsigned int active_mods;
+ xkb_mod_mask_t active_mods;
if (!XkbKeycodeInRange(keymap, kc))
return 0;
*/
int
xkb_key_get_syms_by_level(struct xkb_keymap *keymap, struct xkb_key *key,
- xkb_group_index_t group, unsigned int level,
+ xkb_group_index_t group, xkb_level_index_t level,
const xkb_keysym_t **syms_out)
{
int num_syms;
struct xkb_keymap *keymap = xkb_state_get_map(state);
struct xkb_key *key;
xkb_group_index_t group;
- unsigned int level;
+ xkb_level_index_t level;
if (!state || !XkbKeycodeInRange(keymap, kc))
return -1;
xkb_key_get_action(struct xkb_state *state, xkb_keycode_t kc)
{
xkb_group_index_t group;
- unsigned int level;
+ xkb_level_index_t level;
struct xkb_key *key = NULL;
if (XkbKeycodeInRange(state->keymap, kc))
#include "darray.h"
#include "list.h"
+typedef uint16_t xkb_level_index_t;
+
enum xkb_file_type {
/* The top level file which includes the other component files. */
FILE_TYPE_KEYMAP = (1 << 0),
};
struct xkb_kt_map_entry {
- uint16_t level;
+ xkb_level_index_t level;
struct xkb_mods mods;
};
struct xkb_key_type {
struct xkb_mods mods;
- uint16_t num_levels;
+ xkb_level_index_t num_levels;
darray(struct xkb_kt_map_entry) map;
struct xkb_mods *preserve;
const char *name;
xkb_group_index_t num_groups;
/* How many levels the largest group has. */
- unsigned char width;
+ xkb_level_index_t width;
uint8_t out_of_range_group_action;
xkb_group_index_t out_of_range_group_number;
return &darray_item(keymap->types, XkbKeyTypeIndex(key, group));
}
-static inline uint16_t
+static inline xkb_level_index_t
XkbKeyGroupWidth(struct xkb_keymap *keymap, struct xkb_key *key,
xkb_group_index_t group)
{
}
static inline unsigned int
-XkbKeyNumSyms(struct xkb_key *key, xkb_group_index_t group, unsigned int level)
+XkbKeyNumSyms(struct xkb_key *key, xkb_group_index_t group,
+ xkb_level_index_t level)
{
return key->num_syms[group * key->width + level];
}
static inline int
XkbKeySymOffset(struct xkb_key *key, xkb_group_index_t group,
- unsigned int level)
+ xkb_level_index_t level)
{
return key->sym_index[group * key->width + level];
}
static inline xkb_keysym_t *
-XkbKeySymEntry(struct xkb_key *key, xkb_group_index_t group, unsigned int level)
+XkbKeySymEntry(struct xkb_key *key, xkb_group_index_t group,
+ xkb_level_index_t level)
{
return XkbKeySym(key, XkbKeySymOffset(key, group, level));
}
static inline union xkb_action *
XkbKeyActionEntry(struct xkb_keymap *keymap, struct xkb_key *key,
- xkb_group_index_t group, unsigned int level)
+ xkb_group_index_t group, xkb_level_index_t level)
{
if (XkbKeyHasActions(key))
return &XkbKeyActionsPtr(keymap, key)[key->width * group + level];
xkb_group_index_t
xkb_key_get_group(struct xkb_state *state, xkb_keycode_t kc);
-extern unsigned int
+xkb_level_index_t
xkb_key_get_level(struct xkb_state *state, xkb_keycode_t kc,
xkb_group_index_t group);
extern int
xkb_key_get_syms_by_level(struct xkb_keymap *keymap, struct xkb_key *key,
- xkb_group_index_t group, unsigned int level,
+ xkb_group_index_t group, xkb_level_index_t level,
const xkb_keysym_t **syms_out);
/**
*/
static struct xkb_sym_interpret *
FindInterpForKey(struct xkb_keymap *keymap, struct xkb_key *key,
- xkb_group_index_t group, uint32_t level)
+ xkb_group_index_t group, xkb_level_index_t level)
{
struct xkb_sym_interpret *ret = NULL;
struct xkb_sym_interpret *interp;
xkb_mod_mask_t vmodmask = 0;
int num_acts = 0;
xkb_group_index_t group;
- int level;
- int i;
+ xkb_level_index_t level;
+ unsigned int i;
/* If we've been told not to bind interps to this key, then don't. */
if (key->explicit & XkbExplicitInterpretMask)
bool
ExprResolveLevel(struct xkb_context *ctx, const ExprDef *expr,
- unsigned int *level_rtrn)
+ xkb_level_index_t *level_rtrn)
{
bool ok;
int result;
bool
ExprResolveLevel(struct xkb_context *ctx, const ExprDef *expr,
- unsigned int *level_rtrn);
+ xkb_level_index_t *level_rtrn);
bool
ExprResolveGroup(struct xkb_context *ctx, const ExprDef *expr,
xkb_atom_t name;
xkb_mod_mask_t mask;
xkb_mod_mask_t vmask;
- unsigned numLevels;
+ xkb_level_index_t numLevels;
darray(struct xkb_kt_map_entry) entries;
struct list preserves;
darray(xkb_atom_t) lvlNames;
if ((old = FindMatchingMapEntry(type, new->mods.real_mods,
new->mods.vmods))) {
if (report && (old->level != new->level)) {
- unsigned use, ignore;
+ xkb_level_index_t use, ignore;
if (clobber) {
use = new->level + 1;
ignore = old->level + 1;
static bool
AddLevelName(KeyTypesInfo *info, KeyTypeInfo *type,
- unsigned level, xkb_atom_t name, bool clobber)
+ xkb_level_index_t level, xkb_atom_t name, bool clobber)
{
if (level >= darray_size(type->lvlNames))
darray_resize0(type->lvlNames, level + 1);
SetLevelName(KeyTypesInfo *info, KeyTypeInfo *type, ExprDef *arrayNdx,
ExprDef *value)
{
- unsigned level;
+ xkb_level_index_t level;
xkb_atom_t level_name;
struct xkb_context *ctx = info->keymap->ctx;
const char *str;
*
********************************************************/
-#include <limits.h>
-
#include "xkbcomp-priv.h"
#include "parseutils.h"
#include "action.h"
unsigned char typesDefined;
unsigned char symsDefined;
unsigned char actsDefined;
- unsigned int numLevels[XkbNumKbdGroups];
+ xkb_level_index_t numLevels[XkbNumKbdGroups];
/* syms[group] -> Single array for all the keysyms in the group. */
darray_xkb_keysym_t syms[XkbNumKbdGroups];
}
static bool
-ResizeKeyGroup(KeyInfo *keyi, xkb_group_index_t group, unsigned int numLevels,
- unsigned sizeSyms, bool forceActions)
+ResizeKeyGroup(KeyInfo *keyi, xkb_group_index_t group,
+ xkb_level_index_t numLevels, unsigned sizeSyms,
+ bool forceActions)
{
- int i;
+ xkb_level_index_t i;
if (darray_size(keyi->syms[group]) < sizeSyms)
darray_resize0(keyi->syms[group], sizeSyms);
darray_xkb_keysym_t resultSyms;
enum key_group_selector using = NONE;
darray_xkb_action resultActs;
- unsigned int resultWidth;
+ xkb_level_index_t resultWidth;
unsigned int resultSize = 0;
int cur_idx = 0;
- int i;
+ xkb_level_index_t i;
bool report, clobber;
int verbosity = xkb_get_log_verbosity(info->keymap->ctx);
ExprDef *value)
{
xkb_group_index_t ndx;
- size_t nSyms, nLevels;
- size_t i;
+ size_t nSyms;
+ xkb_level_index_t nLevels;
+ xkb_level_index_t i;
int j;
if (!GetGroupIndex(info, keyi, arrayNdx, SYMBOLS, &ndx))
FindKeyForSymbol(struct xkb_keymap *keymap, xkb_keysym_t sym)
{
struct xkb_key *key, *ret = NULL;
- xkb_group_index_t group, min_group = UINT_MAX;
- unsigned int level, min_level = UINT_MAX;
+ xkb_group_index_t group, min_group = UINT32_MAX;
+ xkb_level_index_t level, min_level = UINT16_MAX;
xkb_foreach_key(key, keymap) {
for (group = 0; group < key->num_groups; group++) {
* symbol per level.
*/
static bool
-FindAutomaticType(struct xkb_keymap *keymap, int width,
+FindAutomaticType(struct xkb_keymap *keymap, xkb_level_index_t width,
const xkb_keysym_t *syms, xkb_atom_t *typeNameRtrn,
bool *autoType)
{
PrepareKeyDef(KeyInfo *keyi)
{
xkb_group_index_t i, lastGroup;
- int j, width, defined;
+ unsigned int defined;
+ xkb_level_index_t j, width;
bool identical;
defined = keyi->symsDefined | keyi->actsDefined | keyi->typesDefined;
struct xkb_key *key;
size_t sizeSyms = 0;
xkb_group_index_t i, nGroups;
- unsigned width, tmp;
+ xkb_level_index_t width, tmp;
struct xkb_key_type * type;
bool haveActions, autoType, useAlias;
unsigned types[XkbNumKbdGroups];